org.minidns.dnslabel

## Class DnsLabel

- java.lang.Object
- - org.minidns.dnslabel.DnsLabel

- All Implemented Interfaces:
    CharSequence, Comparable<DnsLabel>
  Direct Known Subclasses:
    LdhLabel, NonLdhLabel

      public abstract class DnsLabel
      extends Object
      implements CharSequence, Comparable<DnsLabel>

  A DNS label is an individual component of a DNS name. Labels are usually shown separated by dots.

  This class implements `Comparable` which compares DNS labels according to the Canonical DNS Name Order as specified in RFC 4034 § 6.1.

  Note that as per RFC 2181 § 11 DNS labels may contain any byte.

  See Also:
    RFC 5890 § 2.2. DNS-Related Terminology

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `DnsLabel.LabelToLongException` Exception thrown when a DNS label exceeds the maximum allowed length. DNS labels are limited to 63 characters according to RFC 1035.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `String` | `label`
    `static int` | `MAX_LABEL_LENGTH_IN_OCTETS` The maximum length of a DNS label in octets.
    `static boolean` | `VALIDATE` Whether or not the DNS label is validated on construction.
    `static DnsLabel` | `WILDCARD_LABEL`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `DnsLabel(String label)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `DnsLabel` | `asLowercaseVariant()`
    `char` | `charAt(int index)`
    `int` | `compareTo(DnsLabel other)`
    `boolean` | `equals(Object other)`
    `static DnsLabel` | `from(String label)`
    `static DnsLabel[]` | `from(String[] labels)`
    `String` | `getInternationalizedRepresentation()`
    `protected String` | `getInternationalizedRepresentationInternal()` Gets the internal internationalized representation.
    `String` | `getLabelType()`
    `int` | `hashCode()`
    `static boolean` | `isIdnAcePrefixed(String string)`
    `int` | `length()`
    `CharSequence` | `subSequence(int start, int end)`
    `String` | `toString()`
    `void` | `writeToBoas(ByteArrayOutputStream byteArrayOutputStream)`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface java.lang.CharSequence

      `chars, codePoints`

- - ### Field Detail

    - #### label

          public final String label

    - #### MAX_LABEL_LENGTH_IN_OCTETS

          public static final int MAX_LABEL_LENGTH_IN_OCTETS

      The maximum length of a DNS label in octets.
      See Also:
        RFC 1035 § 2.3.4., Constant Field Values

    - #### VALIDATE

          public static final boolean VALIDATE

      Whether or not the DNS label is validated on construction.
      See Also:
        Constant Field Values

    - #### WILDCARD_LABEL

          public static final DnsLabel WILDCARD_LABEL

  - ### Constructor Detail

    - #### DnsLabel

          protected DnsLabel(String label)

  - ### Method Detail

    - #### asLowercaseVariant

          public final DnsLabel asLowercaseVariant()

    - #### charAt

          public final char charAt(int index)

      Specified by:
        `charAt` in interface `CharSequence`

    - #### compareTo

          public final int compareTo(DnsLabel other)

      Specified by:
        `compareTo` in interface `Comparable<DnsLabel>`

    - #### equals

          public final boolean equals(Object other)

      Overrides:
        `equals` in class `Object`

    - #### from

          public static DnsLabel from(String label)

    - #### from

          public static DnsLabel[] from(String[] labels)

    - #### getInternationalizedRepresentation

          public final String getInternationalizedRepresentation()

    - #### getInternationalizedRepresentationInternal

          protected String getInternationalizedRepresentationInternal()

      Gets the internal internationalized representation.
      Returns:
        label string

    - #### getLabelType

          public final String getLabelType()

    - #### hashCode

          public final int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### isIdnAcePrefixed

          public static boolean isIdnAcePrefixed(String string)

    - #### length

          public final int length()

      Specified by:
        `length` in interface `CharSequence`

    - #### subSequence

          public final CharSequence subSequence(int start,
                                                int end)

      Specified by:
        `subSequence` in interface `CharSequence`

    - #### toString

          public final String toString()

      Specified by:
        `toString` in interface `CharSequence`
      Overrides:
        `toString` in class `Object`

    - #### writeToBoas

          public final void writeToBoas(ByteArrayOutputStream byteArrayOutputStream)