DnsName implements compound names for DNS as specified by
RFCs 1034 and 1035, and as updated and clarified by RFCs 1123 and 2181.
The labels in a domain name correspond to JNDI atomic names. Each label must be less than 64 octets in length, and only the optional root label at the end of the name may be 0 octets long. The sum of the lengths of all labels in a name, plus the number of non-root labels plus 1, must be less than 256. The textual representation of a domain name consists of the labels, escaped as needed, dot-separated, and ordered right-to-left.
A label consists of a sequence of octets, each of which may have any value from 0 to 255.
Host names are a subset of domain names. Their labels contain only ASCII letters, digits, and hyphens, and none may begin or end with a hyphen. While names not conforming to these rules may be valid domain names, they will not be usable by a number of DNS applications, and should in most cases be avoided.
DNS does not specify an encoding (such as UTF-8) to use for
octets with non-ASCII values. As of this writing there is some
work going on in this area, but it is not yet finalized.
DnsName currently converts any non-ASCII octets into
characters using ISO-LATIN-1 encoding, in effect taking the
value of each octet and storing it directly into the low-order byte
of a Java character and vice versa. As a consequence, no
character in a DNS name will ever have a non-zero high-order byte.
When the work on internationalizing domain names has stabilized
(see for example draft-ietf-idn-idna-10.txt), DnsName
may be updated to conform to that work.
Backslash (\) is used as the escape character in the
textual representation of a domain name. The character sequence
`\DDD', where DDD is a 3-digit decimal number
(with leading zeros if needed), represents the octet whose value
is DDD. The character sequence `\C', where
C is a character other than '0' through
'9', represents the octet whose value is that of
C (again using ISO-LATIN-1 encoding); this is particularly
useful for escaping '.' or backslash itself. Backslash is
otherwise not allowed in a domain name. Note that escape characters
are interpreted when a name is parsed. So, for example, the character
sequences `S', `\S', and `\083' each
represent the same one-octet name. The toString() method
does not generally insert escape sequences except where necessary.
If, however, the DnsName was constructed using unneeded
escapes, those escapes may appear in the toString result.
Atomic names passed as parameters to methods of
DnsName, and those returned by them, are unescaped. So,
for example, (new DnsName()).add("a.b") creates an
object representing the one-label domain name a\.b, and
calling get(0) on this object returns "a.b".
While DNS names are case-preserving, comparisons between them
are case-insensitive. When comparing names containing non-ASCII
octets, DnsName uses case-insensitive comparison
between pairs of ASCII values, and exact binary comparison
otherwise.
A DnsName instance is not synchronized against
concurrent access by multiple threads.
| Modifier and Type | Field and Description |
|---|---|
| private String | |
| private ArrayList | |
| private short | |
| private static final long |
| Access | Constructor and Description |
|---|---|
| public | |
| public | |
| private |
| Modifier and Type | Method and Description |
|---|---|
| public Name | |
| public Name | add(int pos, String comp)
Implements javax. Adds a single component at a specified position within this name. |
| public Name | addAll(Name suffix)
Implements javax. Adds the components of a name -- in order -- to the end of this name. |
| public Name | addAll(int pos, Name n)
Implements javax. Adds the components of a name -- in order -- at a specified position within this name. |
| public Object | clone()
Overrides java. Implements javax. Generates a new copy of this name. |
| private static int | |
| private int | |
| public int | compareTo(Object obj)
Implements javax. Compares this name with another name for order. |
| public boolean | endsWith(Name n)
Implements javax. Determines whether this name ends with a specified suffix. |
| public boolean | equals(Object obj)
Overrides java. Indicates whether some other object is "equal to" this one. |
| private static void | |
| public String | |
| public Enumeration | getAll()
Implements javax. Retrieves the components of this name as an enumeration of strings. |
| private static char | |
| pack-priv String | |
| public short | |
| public Name | getPrefix(int pos)
Implements javax. Creates a name whose components consist of a prefix of the components of this name. |
| public Name | getSuffix(int pos)
Implements javax. Creates a name whose components consist of a suffix of the components in this name. |
| public int | |
| pack-priv boolean | |
| private static boolean | |
| public boolean | |
| public boolean | |
| private static boolean | |
| private static boolean | |
| private static String | |
| private void | |
| private void | |
| public Object | |
| public int | |
| public boolean | startsWith(Name n)
Implements javax. Determines whether this name starts with a specified prefix. |
| public String | |
| private static void | |
| private void | writeObject(ObjectOutputStream s)
Serializes only the domain name string, for compactness and to avoid any implementation dependency. |
| domain | back to summary |
|---|---|
| private String domain | |
| labels | back to summary |
|---|---|
| private ArrayList<String> labels | |
| octets | back to summary |
|---|---|
| private short octets | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID | |
| DnsName | back to summary |
|---|---|
| public DnsName() Constructs a | |
| DnsName | back to summary |
|---|---|
| public DnsName(String name) throws InvalidNameException Constructs a
| |
| DnsName | back to summary |
|---|---|
| private DnsName(DnsName n, int beg, int end) | |
| add | back to summary |
|---|---|
| public Name add(String comp) throws InvalidNameException Implements javax. Doc from javax. Adds a single component to the end of this name.
| |
| add | back to summary |
|---|---|
| public Name add(int pos, String comp) throws InvalidNameException Implements javax. Doc from javax. Adds a single component at a specified position within this name. Components of this name at or after the index of the new component are shifted up by one (away from index 0) to accommodate the new component.
| |
| addAll | back to summary |
|---|---|
| public Name addAll(Name suffix) throws InvalidNameException Implements javax. Doc from javax. Adds the components of a name -- in order -- to the end of this name.
| |
| addAll | back to summary |
|---|---|
| public Name addAll(int pos, Name n) throws InvalidNameException Implements javax. Doc from javax. Adds the components of a name -- in order -- at a specified position within this name. Components of this name at or after the index of the first new component are shifted up (away from 0) to accommodate the new components.
| |
| clone | back to summary |
|---|---|
| public Object clone() Overrides java. Implements javax. Doc from javax. Generates a new copy of this name. Subsequent changes to the components of this name will not affect the new copy, and vice versa. | |
| compareLabels | back to summary |
|---|---|
| private static int compareLabels(String label1, String label2) | |
| compareRange | back to summary |
|---|---|
| private int compareRange(int beg, int end, Name n) | |
| compareTo | back to summary |
|---|---|
| public int compareTo(Object obj) Implements javax. Doc from javax. Compares this name with another name for order. Returns a negative integer, zero, or a positive integer as this name is less than, equal to, or greater than the given name. As with | |
| endsWith | back to summary |
|---|---|
| public boolean endsWith(Name n) Implements javax. Doc from javax. Determines whether this name ends with a specified suffix.
A name | |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes. | |
| escape | back to summary |
|---|---|
| private static void escape(StringBuilder buf, String label) | |
| get | back to summary |
|---|---|
| public String get(int pos) Implements javax. Doc from javax. Retrieves a component of this name. | |
| getAll | back to summary |
|---|---|
| public Enumeration Implements javax. Doc from javax. Retrieves the components of this name as an enumeration of strings. The effect on the enumeration of updates to this name is undefined. If the name has zero components, an empty (non-null) enumeration is returned. | |
| getEscapedOctet | back to summary |
|---|---|
| private static char getEscapedOctet(String name, int pos) throws InvalidNameException | |
| getKey | back to summary |
|---|---|
| pack-priv String getKey(int i) | |
| getOctets | back to summary |
|---|---|
| public short getOctets() | |
| getPrefix | back to summary |
|---|---|
| public Name getPrefix(int pos) Implements javax. Doc from javax. Creates a name whose components consist of a prefix of the components of this name. Subsequent changes to this name will not affect the name that is returned and vice versa. | |
| getSuffix | back to summary |
|---|---|
| public Name getSuffix(int pos) Implements javax. Doc from javax. Creates a name whose components consist of a suffix of the components in this name. Subsequent changes to this name do not affect the name that is returned and vice versa. | |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for this object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| hasRootLabel | back to summary |
|---|---|
| pack-priv boolean hasRootLabel() | |
| isDigit | back to summary |
|---|---|
| private static boolean isDigit(char c) | |
| isEmpty | back to summary |
|---|---|
| public boolean isEmpty() Implements javax. Doc from javax. Determines whether this name is empty. An empty name is one with zero components. | |
| isHostName | back to summary |
|---|---|
| public boolean isHostName() Does this domain name follow host name syntax? | |
| isHostNameChar | back to summary |
|---|---|
| private static boolean isHostNameChar(char c) | |
| isHostNameLabel | back to summary |
|---|---|
| private static boolean isHostNameLabel(String label) | |
| keyForLabel | back to summary |
|---|---|
| private static String keyForLabel(String label) | |
| parse | back to summary |
|---|---|
| private void parse(String name) throws InvalidNameException | |
| readObject | back to summary |
|---|---|
| private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException | |
| remove | back to summary |
|---|---|
| public Object remove(int pos) Implements javax. Doc from javax. Removes a component from this name. The component of this name at the specified position is removed. Components with indexes greater than this position are shifted down (toward index 0) by one. | |
| size | back to summary |
|---|---|
| public int size() Implements javax. Doc from javax. Returns the number of components in this name. | |
| startsWith | back to summary |
|---|---|
| public boolean startsWith(Name n) Implements javax. Doc from javax. Determines whether this name starts with a specified prefix.
A name | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- | |
| verifyLabel | back to summary |
|---|---|
| private static void verifyLabel(String label) throws InvalidNameException | |
| writeObject | back to summary |
|---|---|
| private void writeObject(ObjectOutputStream s) throws IOException Serializes only the domain name string, for compactness and to avoid any implementation dependency.
| |