Record (dnsjava documentation)
Date: 2013-04-10

org.xbill.DNS

## Class Record

- java.lang.Object
- - org.xbill.DNS.Record

- All Implemented Interfaces:
    Serializable, Cloneable, Comparable
  Direct Known Subclasses:
    A6Record, AAAARecord, AFSDBRecord, APLRecord, ARecord, CERTRecord, CNAMERecord, DHCIDRecord, DLVRecord, DNAMERecord, DNSKEYRecord, DSRecord, GPOSRecord, HINFORecord, IPSECKEYRecord, ISDNRecord, KEYRecord, KXRecord, LOCRecord, MBRecord, MDRecord, MFRecord, MGRecord, MINFORecord, MRRecord, MXRecord, NAPTRRecord, NSAP_PTRRecord, NSAPRecord, NSEC3PARAMRecord, NSEC3Record, NSECRecord, NSRecord, NULLRecord, NXTRecord, OPTRecord, PTRRecord, PXRecord, RPRecord, RRSIGRecord, RTRecord, SIGRecord, SOARecord, SPFRecord, SRVRecord, SSHFPRecord, TKEYRecord, TLSARecord, TSIGRecord, TXTRecord, UNKRecord, WKSRecord, X25Record

      public abstract class Record
      extends Object
      implements Cloneable, Comparable, Serializable

  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:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected int` | `dclass`
    `protected Name` | `name`
    `protected long` | `ttl`
    `protected int` | `type`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `Record()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected static byte[]` | `byteArrayFromString(String s)` Converts a String into a byte array.
    `protected static String` | `byteArrayToString(byte[] array, boolean quote)` Converts a byte array into a String.
    `int` | `compareTo(Object o)` Compares this Record to another Object.
    `boolean` | `equals(Object arg)` Determines if two Records are identical.
    `static Record` | `fromString(Name name, int type, int dclass, long ttl, 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.
    `Name` | `getAdditionalName()` Returns the name for which additional data processing should be done for this record.
    `int` | `getDClass()` Returns the record's class
    `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.
    `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).
    `boolean` | `sameRRset(Record rec)` Determines if two Records could be part of the same RRset.
    `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).
    `protected static String` | `unknownToString(byte[] data)` Converts a byte array into the unknown RR format.
    `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 int type

    - #### dclass

          protected int dclass

    - #### ttl

          protected long ttl

  - ### Constructor Detail

    - #### Record

          protected Record()

  - ### Method Detail

    - #### newRecord

          public static Record newRecord(Name name,
                         int type,
                         int dclass,
                         long ttl,
                         int length,
                         byte[] data)

      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

          public static Record newRecord(Name name,
                         int type,
                         int dclass,
                         long ttl,
                         byte[] data)

      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

          public static Record newRecord(Name name,
                         int type,
                         int dclass,
                         long ttl)

      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

          public static Record newRecord(Name name,
                         int type,
                         int 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.
      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

          public static Record fromWire(byte[] b,
                        int section)
                                 throws IOException

      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).

    - #### rdataToString

          public String rdataToString()

      Converts the rdata portion of a Record into a String representation

    - #### toString

          public String toString()

      Converts a Record into a String representation
      Overrides:
        `toString` in class `Object`

    - #### byteArrayFromString

          protected static byte[] byteArrayFromString(String s)
                                               throws TextParseException

      Converts a String into a byte array.
      Throws:
        `TextParseException`

    - #### byteArrayToString

          protected static String byteArrayToString(byte[] array,
                                 boolean quote)

      Converts a byte array into a String.

    - #### unknownToString

          protected static String unknownToString(byte[] data)

      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

          public Name getName()

      Returns the record's name
      See Also:
        `Name`

    - #### getType

          public int getType()

      Returns the record's type
      See Also:
        `Type`

    - #### getRRsetType

          public int getRRsetType()

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

    - #### getDClass

          public int getDClass()

      Returns the record's class

    - #### getTTL

          public long getTTL()

      Returns the record's TTL

    - #### sameRRset

          public boolean sameRRset(Record rec)

      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.

    - #### equals

          public boolean equals(Object arg)

      Determines if two Records are identical. This compares the name, type, class, and rdata (with names canonicalized). The TTLs are not compared.
      Overrides:
        `equals` in class `Object`
      Parameters:
        `arg` - The record to compare to
      Returns:
        true if the records are equal, false otherwise.

    - #### 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.

    - #### compareTo

          public int compareTo(Object o)

      Compares this Record to another Object.
      Specified by:
        `compareTo` in interface `Comparable`
      Parameters:
        `o` - 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

          public Name 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.