public class HostName extends java.lang.Object implements java.lang.Comparable<HostName>, java.io.Serializable
IPAddressString
.
All manners of domain names are supported. You can add a prefix length to denote the subnet of the resolved address.
Validation is done separately from DNS resolution to avoid unnecessary lookups.
See rfc 3513, 2181, 952, 1035, 1034, 1123, 5890 or the list of rfcs for IPAddress. For IPv6 addresses in host, see rfc 2732 specifying [] notation and 4038 (combining IPv6 [] with prefix or zone) and SMTP rfc 2821 for alternative uses of [] for both IPv4 and IPv6
Modifier and Type | Field and Description |
---|---|
static char |
IPV6_END_BRACKET |
static char |
IPV6_START_BRACKET |
static char |
LABEL_SEPARATOR |
Constructor and Description |
---|
HostName(java.net.InetAddress inetAddr) |
HostName(IPAddress addr) |
HostName(java.lang.String host) |
HostName(java.lang.String host,
HostNameParameters options) |
Modifier and Type | Method and Description |
---|---|
IPAddress |
asAddress()
If this represents an ip address, returns that address.
|
IPAddress |
asAddress(IPAddress.IPVersion version)
If this represents an ip address, returns that address.
|
IPAddressString |
asAddressString()
If this represents an ip address or represents a valid IPAddressString, returns the corresponding address string.
|
int |
compareTo(HostName other) |
boolean |
equals(java.lang.Object o) |
java.lang.String[] |
getNormalizedLabels() |
HostNameParameters |
getValidationOptions() |
int |
hashCode() |
boolean |
isAddress() |
boolean |
isAddress(IPAddress.IPVersion version) |
boolean |
isAddressString() |
boolean |
isAllAddresses() |
boolean |
isEmpty()
Returns true if the address is empty (zero-length).
|
boolean |
isLocalHost() |
boolean |
isLoopback() |
boolean |
isPrefixOnly() |
boolean |
isSelf() |
boolean |
isValid() |
boolean |
matches(HostName host) |
IPAddress |
resolve()
If this represents an ip address, returns that address.
|
boolean |
resolvesToSelf() |
java.net.InetAddress |
toInetAddress() |
java.lang.String |
toNormalizedString()
provides a unique normalized String representation for the host identified by this HostIdentifierString instance
|
IPAddress |
toResolvedAddress() |
java.lang.String |
toString() |
java.lang.String |
toURLString()
If this represents an address that was not bracketed as a host, then it returns the bracketed address as a host.
|
void |
validate() |
public static final char LABEL_SEPARATOR
public static final char IPV6_START_BRACKET
public static final char IPV6_END_BRACKET
public HostName(IPAddress addr)
public HostName(java.net.InetAddress inetAddr)
public HostName(java.lang.String host)
public HostName(java.lang.String host, HostNameParameters options)
public HostNameParameters getValidationOptions()
public void validate() throws HostNameException
HostNameException
public boolean isValid()
public boolean resolvesToSelf()
public boolean isSelf()
public boolean isLocalHost()
public boolean isLoopback()
public java.net.InetAddress toInetAddress() throws HostNameException, java.net.UnknownHostException
HostNameException
java.net.UnknownHostException
public java.lang.String toNormalizedString()
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public boolean matches(HostName host)
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String[] getNormalizedLabels()
public int compareTo(HostName other)
compareTo
in interface java.lang.Comparable<HostName>
public boolean isAddress(IPAddress.IPVersion version)
public boolean isAddress()
public boolean isAddressString()
public boolean isAllAddresses()
public boolean isPrefixOnly()
public boolean isEmpty()
public java.lang.String toURLString()
public IPAddressString asAddressString()
public IPAddress asAddress()
public IPAddress asAddress(IPAddress.IPVersion version)
public IPAddress toResolvedAddress() throws java.net.UnknownHostException, HostNameException
java.net.UnknownHostException
HostNameException
public IPAddress resolve()