Package org.xbill.DNS
Class Record
java.lang.Object
org.xbill.DNS.Record
- All Implemented Interfaces:
Serializable,Cloneable,Comparable<Record>
- Direct Known Subclasses:
A6Record,AAAARecord,AFSDBRecord,APLRecord,ARecord,CAARecord,CERTRecord,CNAMERecord,DHCIDRecord,DLVRecord,DNAMERecord,DNSKEYRecord,DSRecord,GPOSRecord,HINFORecord,HIPRecord,IPSECKEYRecord,ISDNRecord,KEYRecord,KXRecord,LOCRecord,MBRecord,MDRecord,MFRecord,MGRecord,MINFORecord,MRRecord,MXRecord,NAPTRRecord,NSAP_PTRRecord,NSAPRecord,NSEC3PARAMRecord,NSEC3Record,NSECRecord,NSRecord,NULLRecord,NXTRecord,OPENPGPKEYRecord,OPTRecord,PTRRecord,PXRecord,RPRecord,RRSIGRecord,RTRecord,SIGRecord,SOARecord,SPFRecord,SRVRecord,SSHFPRecord,SVCBBase,TKEYRecord,TLSARecord,TSIGRecord,TXTRecord,UNKRecord,URIRecord,WKSRecord,X25Record,ZoneMDRecord
A generic DNS resource record. The specific record types extend this class. A record contains a
name, type, class, ttl, and rdata.
- Author:
- Brian Wellington
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static byte[]Converts a String into a byte array.protected static StringbyteArrayToString(byte[] array, boolean quote) Converts a byte array into a String.intCompares this Record to another Object.booleanDetermines if two Records are identical.static RecordfromString(Name name, int type, int dclass, long ttl, String s, Name origin) Builds a new Record from its textual representationstatic RecordfromString(Name name, int type, int dclass, long ttl, Tokenizer st, Name origin) Builds a new Record from its textual representationstatic RecordfromWire(byte[] b, int section) Builds a Record from DNS uncompressed wire format.Returns the name for which additional data processing should be done for this record.intReturns the record's classgetName()Returns the record's nameintReturns the type of RRset that this record would belong to.longgetTTL()Returns the record's TTLintgetType()Returns the record's typeinthashCode()Generates a hash code based on the Record's data.static RecordCreates a new empty record, with the given parameters.static RecordCreates a new empty record, with the given parameters.static RecordCreates a new record, with the given parameters.static RecordCreates a new record, with the given parameters.protected abstract voidrdataFromString(Tokenizer st, Name origin) Converts the text format of an RR to the internal format - must be overridenConverts the rdata portion of a Record into a String representationbyte[]Converts the rdata in a Record into canonical DNS uncompressed wire format (all names are converted to lowercase).protected abstract voidrrFromWire(DNSInput in) Converts the type-specific RR to wire format - must be overriddenprotected abstract StringConverts the type-specific RR to text format - must be overridden.protected abstract voidrrToWire(DNSOutput out, Compression c, boolean canonical) Converts the type-specific RR to wire format - must be overridden.booleanDetermines if two Records could be part of the same RRset.booleanDetermines if this Record could be part of the passed RRset.toString()Converts a Record into a String representationbyte[]toWire(int section) Converts a Record into DNS uncompressed wire format.byte[]Converts a Record into canonical DNS uncompressed wire format (all names are converted to lowercase).protected static StringunknownToString(byte[] data) Converts a byte array into the unknown RR format.Creates a new record identical to the current record, but with a different name.
-
Field Details
-
name
-
type
protected int type -
dclass
protected int dclass -
ttl
protected long ttl
-
-
Constructor Details
-
Record
protected Record() -
Record
Initialize the basic fields of a record.- Since:
- 3.1
-
-
Method Details
-
rrFromWire
Converts the type-specific RR to wire format - must be overridden- Throws:
IOException- Since:
- 3.1
-
newRecord
Creates a new record, with the given parameters.- Parameters:
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.
-
newRecord
Creates a new record, with the given parameters.- Parameters:
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.
-
newRecord
Creates a new empty record, with the given parameters.- Parameters:
name- The owner name of the record.type- The record's type.dclass- The record's class.ttl- The record's time to live.- Returns:
- An object of a subclass of Record
-
newRecord
Creates a new empty record, with the given parameters. This method is designed to create records that will be added to the QUERY section of a message.- Parameters:
name- The owner name of the record.type- The record's type.dclass- The record's class.- Returns:
- An object of a subclass of Record
-
fromWire
Builds a Record from DNS uncompressed wire format.- Throws:
IOException
-
toWire
public byte[] toWire(int section) Converts a Record into DNS uncompressed wire format. -
toWireCanonical
public byte[] toWireCanonical()Converts a Record into canonical DNS uncompressed wire format (all names are converted to lowercase). -
rdataToWireCanonical
public byte[] rdataToWireCanonical()Converts the rdata in a Record into canonical DNS uncompressed wire format (all names are converted to lowercase). -
rrToString
Converts the type-specific RR to text format - must be overridden.- Since:
- 3.1
-
rdataToString
Converts the rdata portion of a Record into a String representation -
toString
Converts a Record into a String representation -
rdataFromString
Converts the text format of an RR to the internal format - must be overriden- Throws:
IOException- Since:
- 3.1
-
byteArrayFromString
Converts a String into a byte array.- Throws:
TextParseException
-
byteArrayToString
Converts a byte array into a String. -
unknownToString
Converts a byte array into the unknown RR format. -
fromString
public static Record fromString(Name name, int type, int dclass, long ttl, Tokenizer st, Name origin) throws IOException Builds a new Record from its textual representation- Parameters:
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.- Returns:
- The new record
- Throws:
IOException- The text format was invalid.
-
fromString
public static Record fromString(Name name, int type, int dclass, long ttl, String s, Name origin) throws IOException Builds a new Record from its textual representation- Parameters:
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.- Returns:
- The new record
- Throws:
IOException- The text format was invalid.
-
getName
Returns the record's name- See Also:
-
getType
public int getType()Returns the record's type- See Also:
-
getRRsetType
public int getRRsetType()Returns the type of RRset that this record would belong to. For all types except SIG/RRSIG, this is equivalent to getType().- Returns:
- The type of record
- See Also:
-
getDClass
public int getDClass()Returns the record's class -
getTTL
public long getTTL()Returns the record's TTL -
rrToWire
Converts the type-specific RR to wire format - must be overridden.- Since:
- 3.1
-
sameRRset
Determines if two Records could be part of the same RRset. This compares the name, type, and class of the Records; the ttl and rdata are not compared. -
sameRRset
Determines if this Record could be part of the passed RRset. This compares the name, type, and class of the Record and the set.- Since:
- 3.6
-
equals
Determines if two Records are identical. This compares the name, type, class, and rdata (with names canonicalized). The TTLs are not compared. -
hashCode
public int hashCode()Generates a hash code based on the Record's data. -
withName
Creates a new record identical to the current record, but with a different name. This is most useful for replacing the name of a wildcard record. -
compareTo
Compares this Record to another Object.- Specified by:
compareToin interfaceComparable<Record>- Parameters:
arg- The Object to be compared.- Returns:
- The value 0 if the argument is a record equivalent to this record; a value less than 0 if the argument is less than this record in the canonical ordering, and a value greater than 0 if the argument is greater than this record in the canonical ordering. The canonical ordering is defined to compare by name, class, type, and rdata.
- Throws:
ClassCastException- if the argument is not a Record.
-
getAdditionalName
Returns the name for which additional data processing should be done for this record. This can be used both for building responses and parsing responses.- Returns:
- The name to used for additional data processing, or null if this record type does not require additional data processing.
-