| 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.
author: Scott Seligman version: 1.15 07/05/05 |