java.lang.Object
com.aoapps.net.DomainName
- All Implemented Interfaces:
DtoFactory<DomainName>
,FastExternalizable
,Internable<DomainName>
,Externalizable
,Serializable
,Comparable<DomainName>
public final class DomainName
extends Object
implements Comparable<DomainName>, FastExternalizable, DtoFactory<DomainName>, Internable<DomainName>
Represents a DNS domain name. Domain names must:
- Be non-null
- Be non-empty
- May not be "default" (case-insensitive) - to avoid conflicts with Cyrus no-domain configurations.
- Conform to definition in https://wikipedia.org/wiki/Hostname#Internet_hostnames and https://wikipedia.org/wiki/DNS_label#Parts_of_a_domain_name
- May be "localhost" or "localhost.localdomain" - other checks that conflict with this are skipped.
- Last domain label must be alphabetic (not be all numeric)
- Last label must be a valid top level domain.
- For reverse IP address delegation, if the domain ends with ".in-addr.arpa", the first label may also be in the format "##/##".
- Not end with a period (.)
- Author:
- AO Industries, Inc.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final DomainName
static final DomainName
static final int
-
Constructor Summary
ConstructorDescriptionDeprecated.Only required for implementation, do not use directly. -
Method Summary
Modifier and TypeMethodDescriptionstatic int
compareLabels
(String labels1, String labels2) TODO: Should not be public once all classes using validator types.int
compareTo
(DomainName other) Sorts by top level domain, then subdomain, then sub-subdomain, ...boolean
getDto()
long
int
hashCode()
intern()
Interns this domain much in the same fashion asString.intern()
.boolean
isArpa()
static boolean
Checks if ends with .in-addr.arpa (case insensitive).void
Gets the lower-case form of the domain.toString()
static ValidationResult
Validates a domain name, but doesn't allow an ending period.static DomainName
void
-
Field Details
-
MAX_LENGTH
public static final int MAX_LENGTH- See Also:
-
LOCALHOST
-
LOCALHOST_LOCALDOMAIN
-
-
Constructor Details
-
DomainName
Deprecated.Only required for implementation, do not use directly.- See Also:
-
-
Method Details
-
isArpa
Checks if ends with .in-addr.arpa (case insensitive).Performance measurement of new implementation versus old (10,000,000 iterations): "This is not an arpa" Old: 2911.130028 ms New: 37.805258 ms Improvement: 77.0 times "this is not an arpa" Old: 1746.381520 ms New: 50.407891 ms Improvement: 34.7 times "subnet0.144.71.64.in-addr.arpa" Old: 2712.463721 ms New: 284.561373 ms Improvement: 9.5 times
-
validate
Validates a domain name, but doesn't allow an ending period.- See Also:
-
valueOf
- Parameters:
domain
- whennull
, returnsnull
- Throws:
ValidationException
-
equals
-
hashCode
public int hashCode() -
compareLabels
TODO: Should not be public once all classes using validator types. -
compareTo
Sorts by top level domain, then subdomain, then sub-subdomain, ...- Specified by:
compareTo
in interfaceComparable<DomainName>
-
toString
-
toLowerCase
Gets the lower-case form of the domain. If two different domains are interned and their toLowerCase is the same String instance, then they are equal in case-insensitive manner. -
isArpa
public boolean isArpa() -
intern
Interns this domain much in the same fashion asString.intern()
.- Specified by:
intern
in interfaceInternable<DomainName>
- See Also:
-
getDto
- Specified by:
getDto
in interfaceDtoFactory<DomainName>
-
getSerialVersionUID
public long getSerialVersionUID()- Specified by:
getSerialVersionUID
in interfaceFastExternalizable
-
writeExternal
- Specified by:
writeExternal
in interfaceExternalizable
- Throws:
IOException
-
readExternal
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
ClassNotFoundException
-