org.xbill.DNS
Class Record

java.lang.Object
  |
  +--org.xbill.DNS.Record
Direct Known Subclasses:
A6Record, AAAARecord, ARecord, CERTRecord, HINFORecord, KEYRecord, LOCRecord, MX_KXRecord, NAPTRRecord, NS_CNAME_PTRRecord, NXTRecord, OPTRecord, RPRecord, SIGRecord, SOARecord, SRVRecord, TKEYRecord, TSIGRecord, TXTRecord, UNKRecord

public abstract class Record
extends Object
implements Cloneable

The base class that all records are derived from.


Field Summary
protected  short dclass
           
protected  Name name
           
protected  int ttl
           
protected  short type
           
protected  int wireLength
           
 
Constructor Summary
protected Record()
           
 
Method Summary
 boolean equals(Object arg)
          Determines if two Records are identical
static Record fromString(Name name, short type, short dclass, int ttl, MyStringTokenizer 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.
 short getDClass()
          Returns the record's class
 Name getName()
          Returns the record's name
 short getRRsetType()
          Returns the type of RRset that this record would belong to.
 int getTTL()
          Returns the record's TTL
 short getType()
          Returns record's type
 short getWireLength()
          Returns the length of this record in wire format, based on the last time this record was parsed from data or converted to data.
 int hashCode()
          Generates a hash code based on the Record's data
static Record newRecord(Name name, short type, short dclass)
          Creates a new empty record, with the given parameters.
static Record newRecord(Name name, short type, short dclass, int ttl)
          Creates a new empty record, with the given parameters.
static Record newRecord(Name name, short type, short dclass, int ttl, int length, byte[] data)
          Creates a new record, with the given parameters.
 String toString()
          Converts a Record into a String representation
 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).
 Record withName(Name name)
          Creates a new record identical to the current record, but with a different name.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

name

protected Name name

type

protected short type

dclass

protected short dclass

ttl

protected int ttl

wireLength

protected int wireLength
Constructor Detail

Record

protected Record()
Method Detail

newRecord

public static Record newRecord(Name name,
                               short type,
                               short dclass,
                               int ttl,
                               int length,
                               byte[] data)
Creates a new record, with the given parameters.
Returns:
An object of a type extending Record

newRecord

public static Record newRecord(Name name,
                               short type,
                               short dclass,
                               int ttl)
Creates a new empty record, with the given parameters.
Returns:
An object of a type extending Record

newRecord

public static Record newRecord(Name name,
                               short type,
                               short dclass)
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.
Returns:
An object of a type extending Record

fromWire

public static Record fromWire(byte[] b,
                              int section)
                       throws IOException
Builds a Record from DNS uncompressed wire format.

toWire

public byte[] toWire(int section)
              throws IOException
Converts a Record into DNS uncompressed wire format.

toWireCanonical

public byte[] toWireCanonical()
                       throws IOException
Converts a Record into canonical DNS uncompressed wire format (all names are converted to lowercase).

toString

public String toString()
Converts a Record into a String representation
Overrides:
toString in class Object

fromString

public static Record fromString(Name name,
                                short type,
                                short dclass,
                                int ttl,
                                MyStringTokenizer st,
                                Name origin)
                         throws IOException
Builds a new Record from its textual representation

getName

public Name getName()
Returns the record's name
See Also:
Name

getType

public short getType()
Returns record's type
See Also:
Type

getRRsetType

public short getRRsetType()
Returns the type of RRset that this record would belong to. For all types except SIGRecord, this is equivalent to getType().
Returns:
The type of record, if not SIGRecord. If the type is SIGRecord, the type covered is returned.
See Also:
Type, RRset, SIGRecord

getDClass

public short getDClass()
Returns the record's class

getTTL

public int getTTL()
Returns the record's TTL

getWireLength

public short getWireLength()
Returns the length of this record in wire format, based on the last time this record was parsed from data or converted to data. The wire format may or may not be compressed
Returns:
The last known length, or -1 if the record has never been in wire format

equals

public boolean equals(Object arg)
Determines if two Records are identical
Overrides:
equals in class Object

hashCode

public int hashCode()
Generates a hash code based on the Record's data
Overrides:
hashCode in class Object

withName

public Record withName(Name name)
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.