Class DnsName

    • Field Detail

      • ROOT

        public static final DnsName ROOT
      • IN_ADDR_ARPA

        public static final DnsName IN_ADDR_ARPA
      • IP6_ARPA

        public static final DnsName IP6_ARPA
      • VALIDATE

        public static boolean VALIDATE
        Whether or not the DNS name is validated on construction.
      • ace

        public final String ace
        The DNS name in ASCII Compatible Encoding (ACE).
    • Method Detail

      • getBytes

        public byte[] getBytes()
        Serialize a domain name under IDN rules.
        Returns:
        The binary domain name representation.
      • getRawBytes

        public byte[] getRawBytes()
      • getRawAce

        public String getRawAce()
      • asIdn

        public String asIdn()
      • getDomainpart

        public String getDomainpart()
        Domainpart in ACE representation.
        Returns:
        the domainpart in ACE representation.
      • getHostpart

        public String getHostpart()
        Hostpart in ACE representation.
        Returns:
        the hostpart in ACE representation.
      • getHostpartLabel

        public DnsLabel getHostpartLabel()
      • size

        public int size()
      • charAt

        public char charAt​(int index)
        Specified by:
        charAt in interface CharSequence
      • from

        public static DnsName from​(DnsName child,
                                   DnsName parent)
        Create 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.
      • parse

        public static DnsName parse​(DataInputStream dis,
                                    byte[] data)
                             throws IOException
        Parse 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.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • isDirectChildOf

        public boolean isDirectChildOf​(DnsName parent)
      • isChildOf

        public boolean isChildOf​(DnsName parent)
      • getLabelCount

        public int getLabelCount()
      • getLabels

        public DnsLabel[] getLabels()
        Get 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

        public DnsLabel getLabel​(int labelNum)
      • getRawLabels

        public DnsLabel[] getRawLabels()
        Get 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

        public DnsName stripToLabels​(int labelCount)
      • getParent

        public DnsName getParent()
        Return 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.
      • isRootLabel

        public boolean isRootLabel()