public abstract class Record extends java.lang.Object implements java.lang.Cloneable, java.lang.Comparable<Record>, java.io.Serializable
Modifier and Type | Class and Description |
---|---|
private static class |
Record.RecordSerializationProxy |
Modifier and Type | Field and Description |
---|---|
private static java.text.DecimalFormat |
byteFormat |
protected int |
dclass |
protected Name |
name |
protected long |
ttl |
protected int |
type |
Modifier | Constructor and Description |
---|---|
protected |
Record() |
protected |
Record(Name name,
int type,
int dclass,
long ttl) |
Modifier and Type | Method and Description |
---|---|
protected static byte[] |
byteArrayFromString(java.lang.String s)
Converts a String into a byte array.
|
protected static java.lang.String |
byteArrayToString(byte[] array,
boolean quote)
Converts a byte array into a String.
|
(package private) static byte[] |
checkByteArrayLength(java.lang.String field,
byte[] array,
int maxLength) |
(package private) static Name |
checkName(java.lang.String field,
Name name) |
(package private) static int |
checkU16(java.lang.String field,
int val) |
(package private) static long |
checkU32(java.lang.String field,
long val) |
(package private) static int |
checkU8(java.lang.String field,
int val) |
(package private) Record |
cloneRecord() |
int |
compareTo(Record arg)
Compares this Record to another Object.
|
boolean |
equals(java.lang.Object arg)
Determines if two Records are identical.
|
static Record |
fromString(Name name,
int type,
int dclass,
long ttl,
java.lang.String s,
Name origin)
Builds a new Record from its textual representation
|
static Record |
fromString(Name name,
int type,
int dclass,
long ttl,
Tokenizer st,
Name origin)
Builds a new Record from its textual representation
|
static Record |
fromWire(byte[] b,
int section)
Builds a Record from DNS uncompressed wire format.
|
(package private) static Record |
fromWire(DNSInput in,
int section) |
(package private) static Record |
fromWire(DNSInput in,
int section,
boolean isUpdate) |
Name |
getAdditionalName()
Returns the name for which additional data processing should be done for this record.
|
int |
getDClass()
Returns the record's class
|
private static Record |
getEmptyRecord(Name name,
int type,
int dclass,
long ttl,
boolean hasData) |
Name |
getName()
Returns the record's name
|
int |
getRRsetType()
Returns the type of RRset that this record would belong to.
|
long |
getTTL()
Returns the record's TTL
|
int |
getType()
Returns the record's type
|
int |
hashCode()
Generates a hash code based on the Record's data.
|
static Record |
newRecord(Name name,
int type,
int dclass)
Creates a new empty record, with the given parameters.
|
static Record |
newRecord(Name name,
int type,
int dclass,
long ttl)
Creates a new empty record, with the given parameters.
|
static Record |
newRecord(Name name,
int type,
int dclass,
long ttl,
byte[] data)
Creates a new record, with the given parameters.
|
static Record |
newRecord(Name name,
int type,
int dclass,
long ttl,
int length,
byte[] data)
Creates a new record, with the given parameters.
|
private static Record |
newRecord(Name name,
int type,
int dclass,
long ttl,
int length,
DNSInput in) |
protected abstract void |
rdataFromString(Tokenizer st,
Name origin)
Converts the text format of an RR to the internal format - must be overriden
|
java.lang.String |
rdataToString()
Converts the rdata portion of a Record into a String representation
|
byte[] |
rdataToWireCanonical()
Converts the rdata in a Record into canonical DNS uncompressed wire format (all names are
converted to lowercase).
|
private void |
readObject(java.io.ObjectInputStream ois) |
protected abstract void |
rrFromWire(DNSInput in)
Converts the type-specific RR to wire format - must be overridden
|
protected abstract java.lang.String |
rrToString()
Converts the type-specific RR to text format - must be overridden.
|
protected abstract void |
rrToWire(DNSOutput out,
Compression c,
boolean canonical)
Converts the type-specific RR to wire format - must be overridden.
|
boolean |
sameRRset(Record rec)
Determines if two Records could be part of the same RRset.
|
(package private) void |
setTTL(long ttl) |
java.lang.String |
toString()
Converts a Record into a String representation
|
(package private) void |
toWire(DNSOutput out,
int section,
Compression c) |
byte[] |
toWire(int section)
Converts a Record into DNS uncompressed wire format.
|
byte[] |
toWireCanonical()
Converts a Record into canonical DNS uncompressed wire format (all names are converted to
lowercase).
|
private byte[] |
toWireCanonical(boolean noTTL) |
private void |
toWireCanonical(DNSOutput out,
boolean noTTL) |
protected static java.lang.String |
unknownToString(byte[] data)
Converts a byte array into the unknown RR format.
|
(package private) Record |
withDClass(int dclass,
long ttl)
Creates a new record identical to the current record, but with a different class and ttl.
|
Record |
withName(Name name)
Creates a new record identical to the current record, but with a different name.
|
(package private) java.lang.Object |
writeReplace() |
protected Name name
protected int type
protected int dclass
protected long ttl
private static final java.text.DecimalFormat byteFormat
protected Record()
protected Record(Name name, int type, int dclass, long ttl)
java.lang.Object writeReplace()
private void readObject(java.io.ObjectInputStream ois) throws java.io.InvalidObjectException
java.io.InvalidObjectException
private static Record getEmptyRecord(Name name, int type, int dclass, long ttl, boolean hasData)
protected abstract void rrFromWire(DNSInput in) throws java.io.IOException
java.io.IOException
private static Record newRecord(Name name, int type, int dclass, long ttl, int length, DNSInput in) throws java.io.IOException
java.io.IOException
public static Record newRecord(Name name, int type, int dclass, long ttl, int length, byte[] data)
name
- The owner name of the record.type
- The record's type.dclass
- The record's class.ttl
- The record's time to live.length
- The length of the record's data.data
- The rdata of the record, in uncompressed DNS wire format. Only the first length
bytes are used.public static Record newRecord(Name name, int type, int dclass, long ttl, byte[] data)
name
- The owner name of the record.type
- The record's type.dclass
- The record's class.ttl
- The record's time to live.data
- The complete rdata of the record, in uncompressed DNS wire format.public static Record newRecord(Name name, int type, int dclass, long ttl)
name
- The owner name of the record.type
- The record's type.dclass
- The record's class.ttl
- The record's time to live.public static Record newRecord(Name name, int type, int dclass)
name
- The owner name of the record.type
- The record's type.dclass
- The record's class.static Record fromWire(DNSInput in, int section, boolean isUpdate) throws java.io.IOException
java.io.IOException
static Record fromWire(DNSInput in, int section) throws java.io.IOException
java.io.IOException
public static Record fromWire(byte[] b, int section) throws java.io.IOException
java.io.IOException
void toWire(DNSOutput out, int section, Compression c)
public byte[] toWire(int section)
private void toWireCanonical(DNSOutput out, boolean noTTL)
private byte[] toWireCanonical(boolean noTTL)
public byte[] toWireCanonical()
public byte[] rdataToWireCanonical()
protected abstract java.lang.String rrToString()
public java.lang.String rdataToString()
public java.lang.String toString()
toString
in class java.lang.Object
protected abstract void rdataFromString(Tokenizer st, Name origin) throws java.io.IOException
java.io.IOException
protected static byte[] byteArrayFromString(java.lang.String s) throws TextParseException
TextParseException
protected static java.lang.String byteArrayToString(byte[] array, boolean quote)
protected static java.lang.String unknownToString(byte[] data)
public static Record fromString(Name name, int type, int dclass, long ttl, Tokenizer st, Name origin) throws java.io.IOException
name
- The owner name of the record.type
- The record's type.dclass
- The record's class.ttl
- The record's time to live.st
- A tokenizer containing the textual representation of the rdata.origin
- The default origin to be appended to relative domain names.java.io.IOException
- The text format was invalid.public static Record fromString(Name name, int type, int dclass, long ttl, java.lang.String s, Name origin) throws java.io.IOException
name
- The owner name of the record.type
- The record's type.dclass
- The record's class.ttl
- The record's time to live.s
- The textual representation of the rdata.origin
- The default origin to be appended to relative domain names.java.io.IOException
- The text format was invalid.public int getType()
Type
public int getRRsetType()
Type
,
RRset
,
SIGBase.getRRsetType()
public int getDClass()
public long getTTL()
protected abstract void rrToWire(DNSOutput out, Compression c, boolean canonical)
public boolean sameRRset(Record rec)
public boolean equals(java.lang.Object arg)
equals
in class java.lang.Object
arg
- The record to compare topublic int hashCode()
hashCode
in class java.lang.Object
Record cloneRecord()
public Record withName(Name name)
Record withDClass(int dclass, long ttl)
void setTTL(long ttl)
public int compareTo(Record arg)
compareTo
in interface java.lang.Comparable<Record>
arg
- The Object to be compared.java.lang.ClassCastException
- if the argument is not a Record.public Name getAdditionalName()
static int checkU8(java.lang.String field, int val)
static int checkU16(java.lang.String field, int val)
static long checkU32(java.lang.String field, long val)
static byte[] checkByteArrayLength(java.lang.String field, byte[] array, int maxLength)