public class Name extends java.lang.Object implements java.lang.Comparable<Name>, java.io.Serializable
Modifier and Type | Field and Description |
---|---|
static Name |
empty
The root name
|
private static byte[] |
emptyLabel |
private int |
hashcode |
private static int |
LABEL_COMPRESSION |
private static int |
LABEL_MASK |
private static int |
LABEL_NORMAL |
private int |
labels |
private static byte[] |
lowercase |
private static int |
MAXLABEL
The maximum length of a label a Name
|
private static int |
MAXNAME
The maximum length of a Name
|
private static int |
MAXOFFSETS
The maximum number of cached offsets, the first offset (always zero) is not stored.
|
private byte[] |
name |
private long |
offsets |
static Name |
root
The root name
|
private static long |
serialVersionUID |
private static Name |
wild |
private static byte[] |
wildLabel |
Modifier | Constructor and Description |
---|---|
private |
Name() |
|
Name(byte[] b)
Create a new name from DNS wire format
|
|
Name(DNSInput in)
Create a new name from DNS a wire format message
|
|
Name(Name src,
int n)
Create a new name by removing labels from the beginning of an existing Name
|
|
Name(java.lang.String s)
Create a new name from a string.
|
|
Name(java.lang.String s,
Name origin)
Create a new name from a string and an origin.
|
Modifier and Type | Method and Description |
---|---|
private void |
append(byte[] array,
int arrayOffset,
int numLabels) |
private void |
append(char[] label,
int len) |
private void |
appendFromString(java.lang.String fullName,
byte[] label,
int n) |
private void |
appendFromString(java.lang.String fullName,
char[] label,
int length) |
private java.lang.String |
byteString(byte[] array,
int pos) |
Name |
canonicalize()
Returns a canonicalized version of the Name (all lowercase).
|
int |
compareTo(Name arg)
Compares this Name to another Object.
|
static Name |
concatenate(Name prefix,
Name suffix)
Creates a new name by concatenating two existing names.
|
private static void |
copy(Name src,
Name dst) |
private boolean |
equals(byte[] b,
int bpos) |
boolean |
equals(java.lang.Object arg)
Are these two Names equivalent?
|
static Name |
fromConstantString(java.lang.String s)
Create a new name from a constant string.
|
Name |
fromDNAME(DNAMERecord dname)
Generates a new Name to be used when following a DNAME.
|
static Name |
fromString(java.lang.String s)
Create a new name from a string.
|
static Name |
fromString(java.lang.String s,
Name origin)
Create a new name from a string and an origin.
|
byte[] |
getLabel(int n)
Retrieve the nth label of a Name.
|
java.lang.String |
getLabelString(int n)
Convert the nth label in a Name to a String
|
int |
hashCode()
Computes a hashcode based on the value
|
boolean |
isAbsolute()
Is this name absolute?
|
boolean |
isWild()
Is this name a wildcard?
|
int |
labels()
The number of labels in the name.
|
short |
length()
The length of the name (in bytes).
|
private int |
offset(int n) |
private int |
prepareAppend(int len) |
Name |
relativize(Name origin)
If this name is a subdomain of origin, return a new name relative to origin with the same
value.
|
private void |
setoffset(int n,
int offset) |
boolean |
subdomain(Name domain)
Is the current Name a subdomain of the specified name?
|
java.lang.String |
toString()
Convert a Name to a String
|
java.lang.String |
toString(boolean omitFinalDot)
Convert a Name to a String
|
byte[] |
toWire()
Emit a Name in DNS wire format
|
void |
toWire(DNSOutput out,
Compression c)
Emit a Name in DNS wire format
|
void |
toWire(DNSOutput out,
Compression c,
boolean canonical)
Emit a Name in DNS wire format
|
byte[] |
toWireCanonical()
Emit a Name in canonical DNS wire format (all lowercase)
|
void |
toWireCanonical(DNSOutput out)
Emit a Name in canonical DNS wire format (all lowercase)
|
Name |
wild(int n)
Generates a new Name with the first n labels replaced by a wildcard
|
private static final long serialVersionUID
private static final int LABEL_NORMAL
private static final int LABEL_COMPRESSION
private static final int LABEL_MASK
private byte[] name
private long offsets
private transient int hashcode
private int labels
private static final byte[] emptyLabel
private static final byte[] wildLabel
public static final Name root
public static final Name empty
private static final int MAXNAME
private static final int MAXLABEL
private static final int MAXOFFSETS
private static final byte[] lowercase
private static final Name wild
private Name()
public Name(java.lang.String s, Name origin) throws TextParseException
s
- The string to be convertedorigin
- If the name is not absolute, the origin to be appended.TextParseException
- The name is invalid.public Name(java.lang.String s) throws TextParseException
s
- The string to be convertedTextParseException
- The name is invalid.public Name(DNSInput in) throws WireParseException
in
- A stream containing the DNS message which is currently positioned at the start of the
name to be read.WireParseException
public Name(byte[] b) throws java.io.IOException
b
- A byte array containing the wire format of the name.java.io.IOException
public Name(Name src, int n)
src
- An existing Namen
- The number of labels to remove from the beginning in the copyprivate void setoffset(int n, int offset)
private int offset(int n)
private void append(byte[] array, int arrayOffset, int numLabels) throws NameTooLongException
NameTooLongException
private void append(char[] label, int len) throws NameTooLongException
NameTooLongException
private int prepareAppend(int len) throws NameTooLongException
NameTooLongException
private void appendFromString(java.lang.String fullName, char[] label, int length) throws TextParseException
TextParseException
private void appendFromString(java.lang.String fullName, byte[] label, int n) throws TextParseException
TextParseException
public static Name fromString(java.lang.String s, Name origin) throws TextParseException
s
- The string to be convertedorigin
- If the name is not absolute, the origin to be appended.TextParseException
- The name is invalid.public static Name fromString(java.lang.String s) throws TextParseException
s
- The string to be convertedTextParseException
- The name is invalid.public static Name fromConstantString(java.lang.String s)
s
- The string to be convertedjava.lang.IllegalArgumentException
- The name is invalid.public static Name concatenate(Name prefix, Name suffix) throws NameTooLongException
prefix
name is absolute
prefix
is returned unmodified.prefix
- The prefix name. Must be relative.suffix
- The suffix name.NameTooLongException
- The name is too long.public Name relativize(Name origin)
origin
- The origin to remove.public Name wild(int n)
public Name canonicalize()
public Name fromDNAME(DNAMERecord dname) throws NameTooLongException
dname
- The DNAME record to follow.null
if this Name is not a subdomain of the dname
name.NameTooLongException
- The resulting name is too long.public boolean isWild()
public boolean isAbsolute()
public short length()
public int labels()
public boolean subdomain(Name domain)
private java.lang.String byteString(byte[] array, int pos)
public java.lang.String toString(boolean omitFinalDot)
omitFinalDot
- If true, and the name is absolute, omit the final dot.public java.lang.String toString()
toString
in class java.lang.Object
public byte[] getLabel(int n)
n
- The label to be retrieved. The first label is 0.public java.lang.String getLabelString(int n)
n
- The label to be converted to a (printable) String. The first label is 0.public void toWire(DNSOutput out, Compression c)
out
- The output stream containing the DNS message.c
- The compression context, or null of no compression is desired.java.lang.IllegalArgumentException
- The name is not absolute.public byte[] toWire()
java.lang.IllegalArgumentException
- The name is not absolute.public void toWireCanonical(DNSOutput out)
out
- The output stream to which the message is written.public byte[] toWireCanonical()
public void toWire(DNSOutput out, Compression c, boolean canonical)
out
- The output stream containing the DNS message.c
- The compression context, or null of no compression is desired.canonical
- If true, emit the name in canonicalized form (all lowercase).java.lang.IllegalArgumentException
- The name is not absolute.private boolean equals(byte[] b, int bpos)
public boolean equals(java.lang.Object arg)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public int compareTo(Name arg)
compareTo
in interface java.lang.Comparable<Name>
arg
- The name to be compared.java.lang.ClassCastException
- if the argument is not a Name.