java.lang.Object
com.aoapps.net.HostAddress
- All Implemented Interfaces:
DtoFactory<HostAddress>,Internable<HostAddress>,Serializable,Comparable<HostAddress>
public final class HostAddress
extends Object
implements Comparable<HostAddress>, Serializable, DtoFactory<HostAddress>, Internable<HostAddress>
Represents a host's address as either a
DomainName or an InetAddress.
To not allow the IP address representation, use DomainName instead.
No DNS lookups are performed during validation.- Author:
- AO Industries, Inc.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionintcompareTo(HostAddress other) Sorts IP addresses before domain names.booleangetDto()inthashCode()intern()Interns this host address much in the same fashion asString.intern().toString()static ValidationResultValidates a host address, must be either a valid domain name or a valid IP address.static HostAddressvalueOf(DomainName domainName) If domainName is null, returns null.static HostAddressvalueOf(InetAddress ip) If ip is null, returns null.static HostAddressWhen enclosed in brackets"[...]"
-
Method Details
-
validate
Validates a host address, must be either a valid domain name or a valid IP address.When enclosed in brackets
"[...]", will be validated as an IPv6InetAddress(seetoBracketedString()).TODO: Must be non-arpa
-
valueOf
- Parameters:
address- whennull, returnsnull- Throws:
ValidationException
-
valueOf
If domainName is null, returns null. -
valueOf
If ip is null, returns null. -
equals
-
hashCode
public int hashCode() -
compareTo
Sorts IP addresses before domain names.- Specified by:
compareToin interfaceComparable<HostAddress>
-
toString
-
toBracketedString
-
intern
Interns this host address much in the same fashion asString.intern().- Specified by:
internin interfaceInternable<HostAddress>- See Also:
-
getDomainName
-
getInetAddress
-
getDto
- Specified by:
getDtoin interfaceDtoFactory<HostAddress>
-
