Class DnsName
- All Implemented Interfaces:
- Serializable,- CharSequence,- Comparable<DnsName>
 Instances of this class can be created by using from(String).
 
 This class holds three representations of a DNS name: ACE, raw ACE and IDN. ACE (ASCII Compatible Encoding), which
 can be accessed via ace, represents mostly the data that got send over the wire. But since DNS names are
 case insensitive, the ACE value is normalized to lower case. You can use getRawAce() to get the raw ACE data
 that was received, which possibly includes upper case characters. The IDN (Internationalized Domain Name), that is
 the DNS name as it should be shown to the user, can be retrieved using asIdn().
 
- Author:
- Florian Schmaus
- See Also:
- 
Field SummaryFields
- 
Method SummaryModifier and TypeMethodDescriptionasIdn()charcharAt(int index) intbooleanstatic DnsNamefrom(CharSequence name) static DnsNamestatic DnsNamestatic DnsNamestatic DnsNamestatic DnsNamestatic DnsNameCreate a DNS name by "concatenating" the child under the parent name.byte[]getBytes()Serialize a domain name under IDN rules.Domainpart in ACE representation.Hostpart in ACE representation.getLabel(int labelNum) intDnsLabel[]Get a copy of the labels of this DNS name.Return the parent of this DNS label.byte[]DnsLabel[]Get a copy of the raw labels of this DNS name.inthashCode()booleanbooleanisDirectChildOf(DnsName parent) booleanintlength()static DnsNameparse(DataInputStream dis, byte[] data) Parse a domain name starting at the current offset and moving the input stream pointer past this domain name (even if cross references occure).intsize()stripToLabels(int labelCount) subSequence(int start, int end) toString()voidMethods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.CharSequencechars, codePoints, isEmpty
- 
Field Details- 
MAX_DNSNAME_LENGTH_IN_OCTETSstatic final int MAX_DNSNAME_LENGTH_IN_OCTETS- See Also:
 
- 
MAX_LABELSpublic static final int MAX_LABELS- See Also:
 
- 
ROOT
- 
IN_ADDR_ARPA
- 
IP6_ARPA
- 
VALIDATEpublic static boolean VALIDATEWhether or not the DNS name is validated on construction.
- 
aceThe DNS name in ASCII Compatible Encoding (ACE).
 
- 
- 
Method Details- 
writeToStream- Throws:
- IOException
 
- 
getBytespublic byte[] getBytes()Serialize a domain name under IDN rules.- Returns:
- The binary domain name representation.
 
- 
getRawBytespublic byte[] getRawBytes()
- 
getRawAce
- 
asIdn
- 
getDomainpartDomainpart in ACE representation.- Returns:
- the domainpart in ACE representation.
 
- 
getHostpartHostpart in ACE representation.- Returns:
- the hostpart in ACE representation.
 
- 
getHostpartLabel
- 
sizepublic int size()
- 
lengthpublic int length()- Specified by:
- lengthin interface- CharSequence
 
- 
charAtpublic char charAt(int index) - Specified by:
- charAtin interface- CharSequence
 
- 
subSequence- Specified by:
- subSequencein interface- CharSequence
 
- 
toString- Specified by:
- toStringin interface- CharSequence
- Overrides:
- toStringin class- Object
 
- 
from
- 
from
- 
fromCreate a DNS name by "concatenating" the child under the parent name. The child can also be seen as the "left" part of the resulting DNS name and the parent is the "right" part.For example using "i.am.the.child" as child and "of.this.parent.example" as parent, will result in a DNS name: "i.am.the.child.of.this.parent.example". - Parameters:
- child- the child DNS name.
- parent- the parent DNS name.
- Returns:
- the resulting of DNS name.
 
- 
from
- 
from
- 
from
- 
from
- 
parseParse a domain name starting at the current offset and moving the input stream pointer past this domain name (even if cross references occure).- Parameters:
- dis- The input stream.
- data- The raw data (for cross references).
- Returns:
- The domain name string.
- Throws:
- IOException- Should never happen.
 
- 
compareTo- Specified by:
- compareToin interface- Comparable<DnsName>
 
- 
equals
- 
hashCodepublic int hashCode()
- 
isDirectChildOf
- 
isChildOf
- 
getLabelCountpublic int getLabelCount()
- 
getLabelsGet a copy of the labels of this DNS name. The resulting array will contain the labels in reverse order, that is, the top-level domain will be at res[0].- Returns:
- an array of the labels in reverse order.
 
- 
getLabel
- 
getRawLabelsGet a copy of the raw labels of this DNS name. The resulting array will contain the labels in reverse order, that is, the top-level domain will be at res[0].- Returns:
- an array of the raw labels in reverse order.
 
- 
stripToLabels
- 
getParentReturn the parent of this DNS label. Will return the root label if this label itself is the root label (because there is no parent of root).For example: - "foo.bar.org".getParent() == "bar.org"
- ".".getParent() == "."
 - Returns:
- the parent of this DNS label.
 
- 
isRootLabelpublic boolean isRootLabel()
 
-