Package org.minidns.dnslabel
Class DnsLabel
- java.lang.Object
-
- org.minidns.util.SafeCharSequence
-
- org.minidns.dnslabel.DnsLabel
-
- All Implemented Interfaces:
java.lang.CharSequence,java.lang.Comparable<DnsLabel>
- Direct Known Subclasses:
LdhLabel,NonLdhLabel
public abstract class DnsLabel extends SafeCharSequence implements java.lang.Comparable<DnsLabel>
A DNS label is an individual component of a DNS name. Labels are usually shown separated by dots.This class implements
Comparablewhich 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 Description static classDnsLabel.LabelToLongException
-
Field Summary
Fields Modifier and Type Field Description java.lang.Stringlabelstatic intMAX_LABEL_LENGTH_IN_OCTETSThe maximum length of a DNS label in octets.static booleanVALIDATEWhether or not the DNS label is validated on construction.static DnsLabelWILDCARD_LABEL
-
Constructor Summary
Constructors Modifier Constructor Description protectedDnsLabel(java.lang.String label)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description DnsLabelasLowercaseVariant()intcompareTo(DnsLabel other)static booleanconsistsOnlyOfLettersDigitsAndHypen(java.lang.String string)static booleanconsistsOnlyOfLettersDigitsHypenAndUnderscore(java.lang.String string)booleanequals(java.lang.Object other)static DnsLabelfrom(java.lang.String label)static DnsLabel[]from(java.lang.String[] labels)java.lang.StringgetInternationalizedRepresentation()protected java.lang.StringgetInternationalizedRepresentationInternal()java.lang.StringgetLabelType()java.lang.StringgetRawLabel()Get the raw label.inthashCode()static booleanisIdnAcePrefixed(java.lang.String string)static java.lang.StringtoSafeRepesentation(java.lang.String dnsLabel)java.lang.StringtoString()voidwriteToBoas(java.io.ByteArrayOutputStream byteArrayOutputStream)-
Methods inherited from class org.minidns.util.SafeCharSequence
charAt, length, subSequence, toSafeString
-
-
-
-
Field Detail
-
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
-
WILDCARD_LABEL
public static final DnsLabel WILDCARD_LABEL
-
VALIDATE
public static boolean VALIDATE
Whether or not the DNS label is validated on construction.
-
label
public final java.lang.String label
-
-
Constructor Detail
-
DnsLabel
protected DnsLabel(java.lang.String label)
-
-
Method Detail
-
getInternationalizedRepresentation
public final java.lang.String getInternationalizedRepresentation()
-
getInternationalizedRepresentationInternal
protected java.lang.String getInternationalizedRepresentationInternal()
-
getLabelType
public final java.lang.String getLabelType()
-
toString
public final java.lang.String toString()
- Specified by:
toStringin interfacejava.lang.CharSequence- Overrides:
toStringin classjava.lang.Object
-
getRawLabel
public final java.lang.String getRawLabel()
Get the raw label. Note that this may return a String containing null bytes. Those Strings are notoriously difficult to handle from a security perspective. Therefore it is recommended to usetoString()instead, which will return a sanitized String.- Returns:
- the raw label.
- Since:
- 1.1.0
-
equals
public final boolean equals(java.lang.Object other)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public final int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
asLowercaseVariant
public final DnsLabel asLowercaseVariant()
-
writeToBoas
public final void writeToBoas(java.io.ByteArrayOutputStream byteArrayOutputStream)
-
compareTo
public final int compareTo(DnsLabel other)
- Specified by:
compareToin interfacejava.lang.Comparable<DnsLabel>
-
isIdnAcePrefixed
public static boolean isIdnAcePrefixed(java.lang.String string)
-
toSafeRepesentation
public static java.lang.String toSafeRepesentation(java.lang.String dnsLabel)
-
consistsOnlyOfLettersDigitsAndHypen
public static boolean consistsOnlyOfLettersDigitsAndHypen(java.lang.String string)
-
consistsOnlyOfLettersDigitsHypenAndUnderscore
public static boolean consistsOnlyOfLettersDigitsHypenAndUnderscore(java.lang.String string)
-
-