net.sf.ivmaidns.dns
Class DNSRecord

java.lang.Object
  extended by net.sf.ivmaidns.dns.DNSRecord
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Immutable, Indexable, ReallyCloneable, Sortable, Verifiable

public final class DNSRecord
extends java.lang.Object
implements Immutable, ReallyCloneable, java.io.Serializable, Indexable, Sortable, Verifiable

Class for representing DNS resource record (as defined in RFC1035).

Version:
3.0
Author:
Ivan Maidanski
See Also:
Serialized Form

Field Summary
static int A
          NOTE: These are standard DNS resource types (qType or rType).
static int AAAA
           
static int AFSDB
           
static int ANY
          NOTE: This is standard DNS question "*" type/class (qType or qClass).
static int ATMA
           
static int AXFR
           
static int CERT
           
static int CH
           
static int CNAME
           
static int DEFAULT_SOA_EXPIRE
           
static int DEFAULT_SOA_REFRESH
          NOTE: The default values for SOA resource record rData fields (RFC1035).
static int DEFAULT_SOA_RETRY
           
static int DEFAULT_TTL
           
static int DNAME
           
static int EID
           
protected static byte[] EMPTY_BYTES
          NOTE: A constant initialized with an instance of empty byte array.
static int GPOS
           
static int HINFO
           
static int HS
           
static int IN
          NOTE: These are standard DNS resource classes (qClass or rClass).
static int INET_ADDR_LEN
          NOTE: This is the length of an IPv4 address value.
static int ISDN
           
static int IXFR
          NOTE: These are standard DNS additional question types (qType).
static int KEY
           
static int KX
           
static int LOC
           
static int MAILA
           
static int MAILB
           
static int MB
           
static int MD
           
protected static java.lang.String META_RDATA_FIELDS
          NOTE: Same as RDATA_FIELDS table but for query and meta-data records.
static int MF
           
static int MG
           
static int MINFO
           
static int MR
           
static int MX
           
static int NAPTR
           
static int NIMLOC
           
static int NONE
          NOTE: This is standard DNS record "NONE" class (rClass).
static int NS
           
static int NSAP
           
static int NSAP_PTR
           
static int NULL
           
static int NXT
           
static int OPT
          NOTE: These are DNS meta-data records types (rType).
static int PTR
           
static int PX
           
protected  short rClass
          NOTE: rClass is an unsigned short.
static int RCLASS_LENGTH
           
static int RCLASS_MASK
           
static java.lang.String RCLASS_REFER_ABBREVS
          NOTE: This string represents a packed sorted reference list of abbreviations for the standard rClass values (defined in RFC1035).
protected static java.lang.String RDATA_FIELDS
          NOTE: This is padded string-table for codes of rData fields.
static int RDATA_LEN_LENGTH
           
static int RDATA_LEN_MASK
           
protected static int RDATA_MAX_FIELDS
          NOTE: This is (limit + 1) for number of recognized fields in rData.
protected  byte[] rDataBytes
          NOTE: rDataBytes must be !
protected  DNSName rName
          NOTE: rName must be !
static int RP
           
static int RT
           
protected  short rType
          NOTE: rType is an unsigned short.
static int RTYPE_LENGTH
          NOTE: These are lengthes (in bytes) of rType, rClass, ttl, rDataLen.
static int RTYPE_MASK
          NOTE: These are integer bit masks of defined types.
static java.lang.String RTYPE_REFER_ABBREVS
          NOTE: This string represents a packed sorted reference list of abbreviations for the standard rType values (first defined in RFC1035).
static int SIG
           
static int SOA
           
static int SOA_EMAIL_INDEX
           
static int SOA_EXPIRE_INDEX
           
static int SOA_HOST_INDEX
          NOTE: These are all indices for SOA resource record rData fields (RFC1035).
static int SOA_MINTTL_INDEX
           
static int SOA_REFRESH_INDEX
           
static int SOA_RETRY_INDEX
           
static int SOA_SERIAL_INDEX
           
static int SRV
           
static int TKEY
           
static int TSIG
           
protected  int ttl
          NOTE: ttl is unsigned (but should be >= 0, in fact).
static int TTL_LENGTH
           
static int TTL_MASK
           
static int TXT
           
static int WKS
           
static java.lang.String WKS_PORT_ABBREVS
          NOTE: This string represents a packed abbreviations list for the standard wksPort values (defined in RFC1700).
static java.lang.String WKS_PORT_REFER_ABBREVS
          NOTE: This string represents a packed sorted reference list of abbreviations for the standard wksPort values (defined in RFC1700).
static java.lang.String WKS_PROTOCOL_ABBREVS
          NOTE: This string represents a packed abbreviations list for the standard wksProtocol values (defined in RFC1700).
static java.lang.String WKS_PROTOCOL_REFER_ABBREVS
          NOTE: This string represents a packed sorted reference list of abbreviations for the standard wksProtocol values (defined in RFC1700).
static int X25
           
 
Constructor Summary
DNSRecord(byte[] msgBytes, int[] ofsRef, boolean isResource)
          NOTE: Record constructor from msgBytes array (decompression supported). msgBytes must be !
DNSRecord(DNSName rName, int rType, int rClass)
          NOTE: Question record constructor. rName must be !
DNSRecord(DNSName rName, int rType, int rClass, int ttl, byte[] rDataBytes)
          NOTE: rName must be !
DNSRecord(DNSName rName, int rType, int rClass, int ttl, java.lang.Object[] rData)
          NOTE: rName must be !
DNSRecord(DNSRecord record)
          NOTE: record must be !
DNSRecord(DNSRecord record, int ttl)
          NOTE: Constructor for changing ttl. record must be !
 
Method Summary
static java.lang.String addressToString(byte[] address, int offset, int len, boolean lowerCase, boolean zeroPadding, boolean noCompactFormat, boolean noMixedFormat)
          NOTE: address must be !
static boolean canonizeRData(int rType, byte[] rDataBytes)
          NOTE: rDataBytes must be !
 java.lang.Object clone()
          Creates and returns a copy of this object.
static int compareRData(int rType, byte[] rDataBytesA, byte[] rDataBytesB, boolean decodeRData)
          NOTE: rDataBytesA and rDataBytesB must be !
 int compareTo(DNSRecord record, boolean decodeRData)
          NOTE: record must be !
static int compressRData(int rType, byte[] msgBytes, int offset, int rDataBytesLen, int baseNameOffset)
          NOTE: If offset > baseNameOffset then compression of recognized domain names is performed if possible (using only content at baseNameOffset, which must be valid and not compressed). msgBytes array is altered.
static java.lang.Object[] decodeRData(int rType, byte[] rDataBytes)
          NOTE: rDataBytes must be !
static byte[] decompressRData(int rType, byte[] rDataBytes, byte[] msgBytes)
          NOTE: rDataBytes must be !
static byte[] encodeRData(int rType, java.lang.Object[] rData)
          NOTE: rData must be !
 boolean equals(java.lang.Object obj)
          NOTE: ttl is ignored. rData contents are compared in the case-insensitive manner for DNSName fields.
 boolean equalsExact(DNSRecord record)
          NOTE: record may be == null.
 boolean equalsQuery(DNSRecord qdRecord)
          NOTE: qdRecord may be == null.
static java.net.InetAddress fromRevAddressName(DNSName ptr)
          NOTE: ptr must be !
static byte[] fromRevIp6Name(DNSName ptr)
          NOTE: ptr must be !
 java.lang.Object getAt(int index)
          NOTE: Result is (new Object[] { getRName(), new UnsignedInt(getRType()), new UnsignedInt(getRClass()), new UnsignedInt(getTTL()), new ByteVector(getRDataBytes()) })[index].
static java.lang.Object[] getFieldsAt(int field, int rType, DNSRecord[] records, int offset, int len)
          NOTE: records must be !
 int getLevel()
          NOTE: Result >= 0.
 int getRClass()
          NOTE: Result is an unsigned short.
 java.lang.Object[] getRData()
          NOTE: Result !
 byte[] getRDataBytes()
          NOTE: Result !
 int getRDataBytesLen()
          NOTE: Result >= 0.
 DNSName getRName()
          NOTE: Result !
 int getRType()
          NOTE: Result is an unsigned short.
 int getTotalLen()
          NOTE: Result is the total length (in bytes) of this record.
 int getTTL()
          NOTE: Result is unsigned.
 boolean greaterThan(java.lang.Object obj)
          NOTE: Method for canonical ordering (according to RFC2535).
 int hashCode()
          NOTE: ttl is omitted (as if ttl == 0).
static int hashCodeRData(int rType, byte[] rDataBytes)
          NOTE: rDataBytes must be !
 void integrityCheck()
          NOTE: Check record and its name objects for their integrity.
static boolean isIPAddress(java.lang.String str, int beginIndex, int endIndex)
          NOTE: str must be !
 int length()
          NOTE: Result is the number of elements accessible through getAt(int).
static java.lang.String locToString(int value, int index)
          NOTE: Converts geographic location parameter to a string (RFC1876).
static int maxRDataLen(int rType)
          NOTE: Result >= decodeRData(rType, rDataBytes) length.
 int putTo(byte[] msgBytes, int offset, boolean isResource, int baseNameOffset)
          NOTE: Method for putting resource record to (message) byte array.
static java.lang.String quoteString(java.lang.String str)
          NOTE: str must be !
static java.lang.String rClassAbbreviation(int rClass)
          NOTE: Result !
static int rDataIndex(int rType, int textualIndex)
          NOTE: Result is the index for rData array corresponding to textualIndex.
static java.lang.String rDataToString(int rType, java.lang.Object rDataValue, int index, DNSName domain)
          NOTE: rDataValue must be !
static java.lang.String rTypeAbbreviation(int rType)
          NOTE: Result !
static java.lang.String rTypeMapToString(byte[] typeMap, int offset, int len)
          NOTE: typeMap must be !
static java.lang.String timeToString(int value)
          NOTE: Converts UT seconds to a string (as defined in RFC2535).
static DNSName toRevAddressName(java.net.InetAddress host)
          NOTE: host must be !
static DNSName toRevIp6Name(byte[] hostAAAA, int offset, int len)
          NOTE: hostAAAA must be !
 java.lang.String toString()
          NOTE: No default values.
 java.lang.String toString(DNSName domain, DNSRecord prevRecord, boolean tabSeparated)
          NOTE: If domain == null then current zone domain is not specified.
static java.lang.String wksPortMapToString(byte[] portMap, int offset, int len)
          NOTE: portMap must be !
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

A

public static final int A
NOTE: These are standard DNS resource types (qType or rType).

See Also:
Constant Field Values

NS

public static final int NS
See Also:
Constant Field Values

MD

public static final int MD
See Also:
Constant Field Values

MF

public static final int MF
See Also:
Constant Field Values

CNAME

public static final int CNAME
See Also:
Constant Field Values

SOA

public static final int SOA
See Also:
Constant Field Values

MB

public static final int MB
See Also:
Constant Field Values

MG

public static final int MG
See Also:
Constant Field Values

MR

public static final int MR
See Also:
Constant Field Values

NULL

public static final int NULL
See Also:
Constant Field Values

WKS

public static final int WKS
See Also:
Constant Field Values

PTR

public static final int PTR
See Also:
Constant Field Values

HINFO

public static final int HINFO
See Also:
Constant Field Values

MINFO

public static final int MINFO
See Also:
Constant Field Values

MX

public static final int MX
See Also:
Constant Field Values

TXT

public static final int TXT
See Also:
Constant Field Values

RP

public static final int RP
See Also:
Constant Field Values

AFSDB

public static final int AFSDB
See Also:
Constant Field Values

X25

public static final int X25
See Also:
Constant Field Values

ISDN

public static final int ISDN
See Also:
Constant Field Values

RT

public static final int RT
See Also:
Constant Field Values

NSAP

public static final int NSAP
See Also:
Constant Field Values

NSAP_PTR

public static final int NSAP_PTR
See Also:
Constant Field Values

SIG

public static final int SIG
See Also:
Constant Field Values

KEY

public static final int KEY
See Also:
Constant Field Values

PX

public static final int PX
See Also:
Constant Field Values

GPOS

public static final int GPOS
See Also:
Constant Field Values

AAAA

public static final int AAAA
See Also:
Constant Field Values

LOC

public static final int LOC
See Also:
Constant Field Values

NXT

public static final int NXT
See Also:
Constant Field Values

EID

public static final int EID
See Also:
Constant Field Values

NIMLOC

public static final int NIMLOC
See Also:
Constant Field Values

SRV

public static final int SRV
See Also:
Constant Field Values

ATMA

public static final int ATMA
See Also:
Constant Field Values

NAPTR

public static final int NAPTR
See Also:
Constant Field Values

KX

public static final int KX
See Also:
Constant Field Values

CERT

public static final int CERT
See Also:
Constant Field Values

DNAME

public static final int DNAME
See Also:
Constant Field Values

OPT

public static final int OPT
NOTE: These are DNS meta-data records types (rType).

Since:
2.3
See Also:
Constant Field Values

TKEY

public static final int TKEY
See Also:
Constant Field Values

TSIG

public static final int TSIG
See Also:
Constant Field Values

IXFR

public static final int IXFR
NOTE: These are standard DNS additional question types (qType).

See Also:
Constant Field Values

AXFR

public static final int AXFR
See Also:
Constant Field Values

MAILB

public static final int MAILB
See Also:
Constant Field Values

MAILA

public static final int MAILA
See Also:
Constant Field Values

ANY

public static final int ANY
NOTE: This is standard DNS question "*" type/class (qType or qClass).

See Also:
Constant Field Values

IN

public static final int IN
NOTE: These are standard DNS resource classes (qClass or rClass).

See Also:
Constant Field Values

CH

public static final int CH
See Also:
Constant Field Values

HS

public static final int HS
See Also:
Constant Field Values

NONE

public static final int NONE
NOTE: This is standard DNS record "NONE" class (rClass).

See Also:
Constant Field Values

SOA_HOST_INDEX

public static final int SOA_HOST_INDEX
NOTE: These are all indices for SOA resource record rData fields (RFC1035).

Since:
3.0
See Also:
Constant Field Values

SOA_EMAIL_INDEX

public static final int SOA_EMAIL_INDEX
See Also:
Constant Field Values

SOA_SERIAL_INDEX

public static final int SOA_SERIAL_INDEX
See Also:
Constant Field Values

SOA_REFRESH_INDEX

public static final int SOA_REFRESH_INDEX
See Also:
Constant Field Values

SOA_RETRY_INDEX

public static final int SOA_RETRY_INDEX
See Also:
Constant Field Values

SOA_EXPIRE_INDEX

public static final int SOA_EXPIRE_INDEX
See Also:
Constant Field Values

SOA_MINTTL_INDEX

public static final int SOA_MINTTL_INDEX
See Also:
Constant Field Values

DEFAULT_SOA_REFRESH

public static final int DEFAULT_SOA_REFRESH
NOTE: The default values for SOA resource record rData fields (RFC1035).

See Also:
Constant Field Values

DEFAULT_SOA_RETRY

public static final int DEFAULT_SOA_RETRY
See Also:
Constant Field Values

DEFAULT_SOA_EXPIRE

public static final int DEFAULT_SOA_EXPIRE
See Also:
Constant Field Values

DEFAULT_TTL

public static final int DEFAULT_TTL
See Also:
Constant Field Values

RTYPE_LENGTH

public static final int RTYPE_LENGTH
NOTE: These are lengthes (in bytes) of rType, rClass, ttl, rDataLen.

Since:
2.1
See Also:
Constant Field Values

RCLASS_LENGTH

public static final int RCLASS_LENGTH
See Also:
Constant Field Values

TTL_LENGTH

public static final int TTL_LENGTH
See Also:
Constant Field Values

RDATA_LEN_LENGTH

public static final int RDATA_LEN_LENGTH
See Also:
Constant Field Values

INET_ADDR_LEN

public static final int INET_ADDR_LEN
NOTE: This is the length of an IPv4 address value.

Since:
2.2
See Also:
Constant Field Values

RTYPE_MASK

public static final int RTYPE_MASK
NOTE: These are integer bit masks of defined types.

Since:
2.1
See Also:
Constant Field Values

RCLASS_MASK

public static final int RCLASS_MASK
See Also:
Constant Field Values

TTL_MASK

public static final int TTL_MASK
See Also:
Constant Field Values

RDATA_LEN_MASK

public static final int RDATA_LEN_MASK
See Also:
Constant Field Values

RCLASS_REFER_ABBREVS

public static final java.lang.String RCLASS_REFER_ABBREVS
NOTE: This string represents a packed sorted reference list of abbreviations for the standard rClass values (defined in RFC1035). This string is used only by UnsignedInt parseAbbreviation(str) method.

Since:
3.0
See Also:
Constant Field Values

RTYPE_REFER_ABBREVS

public static final java.lang.String RTYPE_REFER_ABBREVS
NOTE: This string represents a packed sorted reference list of abbreviations for the standard rType values (first defined in RFC1035). This string is used only by UnsignedInt parseAbbreviation(str) method.

Since:
3.0
See Also:
Constant Field Values

WKS_PROTOCOL_ABBREVS

public static final java.lang.String WKS_PROTOCOL_ABBREVS
NOTE: This string represents a packed abbreviations list for the standard wksProtocol values (defined in RFC1700). The string is used only by UnsignedInt toAbbreviation(wksProtocol) method.

Since:
3.0
See Also:
Constant Field Values

WKS_PROTOCOL_REFER_ABBREVS

public static final java.lang.String WKS_PROTOCOL_REFER_ABBREVS
NOTE: This string represents a packed sorted reference list of abbreviations for the standard wksProtocol values (defined in RFC1700). The string is used only by UnsignedInt parseAbbreviation(str) method.

Since:
3.0
See Also:
Constant Field Values

WKS_PORT_ABBREVS

public static final java.lang.String WKS_PORT_ABBREVS
NOTE: This string represents a packed abbreviations list for the standard wksPort values (defined in RFC1700). The string is used only by UnsignedInt toAbbreviation(wksPort) method.

Since:
3.0
See Also:
Constant Field Values

WKS_PORT_REFER_ABBREVS

public static final java.lang.String WKS_PORT_REFER_ABBREVS
NOTE: This string represents a packed sorted reference list of abbreviations for the standard wksPort values (defined in RFC1700). The string is used only by UnsignedInt parseAbbreviation(str) method.

Since:
3.0
See Also:
Constant Field Values

RDATA_MAX_FIELDS

protected static final int RDATA_MAX_FIELDS
NOTE: This is (limit + 1) for number of recognized fields in rData.

Since:
2.3
See Also:
Constant Field Values

RDATA_FIELDS

protected static final java.lang.String RDATA_FIELDS
NOTE: This is padded string-table for codes of rData fields. Field types are encoded as follows: '0' - '9' - UnsignedInt, 'I' - InetAddress (INET_ADDR_LEN bytes), 'N' - DNSName (case-insensitive), 'T' - ByteVector (till the end of rDataBytes), 'S' - String (case-insensitive, with unsigned byte prefix for length), 'R' - ByteVector (with unsigned RDATA_LEN_LENGTH prefix for length), ',' - undefined. Each line contains exactly RDATA_MAX_FIELDS characters (including last ',' to terminate line). The rest fields and the rest record types are undefined.

Since:
2.3
See Also:
Constant Field Values

META_RDATA_FIELDS

protected static final java.lang.String META_RDATA_FIELDS
NOTE: Same as RDATA_FIELDS table but for query and meta-data records.

Since:
2.3
See Also:
Constant Field Values

EMPTY_BYTES

protected static final byte[] EMPTY_BYTES
NOTE: A constant initialized with an instance of empty byte array.

Since:
3.0

rName

protected final DNSName rName
NOTE: rName must be != null.


rType

protected final short rType
NOTE: rType is an unsigned short.


rClass

protected final short rClass
NOTE: rClass is an unsigned short.


ttl

protected final int ttl
NOTE: ttl is unsigned (but should be >= 0, in fact).


rDataBytes

protected final byte[] rDataBytes
NOTE: rDataBytes must be != null and (rDataBytes length & ~RDATA_LEN_MASK) == 0.

Constructor Detail

DNSRecord

public DNSRecord(DNSName rName,
                 int rType,
                 int rClass)
          throws java.lang.NullPointerException,
                 java.lang.IllegalArgumentException
NOTE: Question record constructor. rName must be != null. rType and rClass must be valid. ttl is set to 0, rDataBytes is set to an empty byte array.

Throws:
java.lang.NullPointerException
java.lang.IllegalArgumentException

DNSRecord

public DNSRecord(DNSName rName,
                 int rType,
                 int rClass,
                 int ttl,
                 java.lang.Object[] rData)
          throws java.lang.NullPointerException,
                 java.lang.IllegalArgumentException
NOTE: rName must be != null, rData must be != null, rData[index] must be != null for any index. rType, rClass and rData must be valid.

Throws:
java.lang.NullPointerException
java.lang.IllegalArgumentException

DNSRecord

public DNSRecord(DNSName rName,
                 int rType,
                 int rClass,
                 int ttl,
                 byte[] rDataBytes)
          throws java.lang.NullPointerException,
                 java.lang.IllegalArgumentException
NOTE: rName must be != null, rDataBytes must be != null. rType, rClass and rDataBytes length must be valid. rDataBytes array is cloned (its content is not verified).

Throws:
java.lang.NullPointerException
java.lang.IllegalArgumentException

DNSRecord

public DNSRecord(DNSRecord record)
          throws java.lang.NullPointerException
NOTE: record must be != null. Constructed DNS record is with canonized rName and all recognized names in rDataBytes.

Throws:
java.lang.NullPointerException
Since:
2.3

DNSRecord

public DNSRecord(DNSRecord record,
                 int ttl)
          throws java.lang.NullPointerException
NOTE: Constructor for changing ttl. record must be != null. Constructed record is the same as specified one except ttl.

Throws:
java.lang.NullPointerException
Since:
2.3

DNSRecord

public DNSRecord(byte[] msgBytes,
                 int[] ofsRef,
                 boolean isResource)
          throws java.lang.NullPointerException,
                 java.lang.ArrayIndexOutOfBoundsException,
                 java.lang.IllegalArgumentException
NOTE: Record constructor from msgBytes array (decompression supported). msgBytes must be != null, ofsRef must be != null and ofsRef length > 0 (only ofsRef[0] is used). If !isResource then ttl is set to 0, rDataBytes is set to empty byte array (without reading them from msgBytes). ArrayIndexOutOfBoundsException is thrown only if ofsRef length == 0 or 0 > ofsRef[0] or ofsRef[0] >= msgBytes length. On return ofsRef[0] is new offset (just after constructed record). If IllegalArgumentException is thrown then if ofsRef[0] > msgBytes length then out of msgBytes array else the content of msgBytes array is invalid.

Throws:
java.lang.NullPointerException
java.lang.ArrayIndexOutOfBoundsException
java.lang.IllegalArgumentException
Since:
2.3
Method Detail

putTo

public int putTo(byte[] msgBytes,
                 int offset,
                 boolean isResource,
                 int baseNameOffset)
          throws java.lang.NullPointerException,
                 java.lang.ArrayIndexOutOfBoundsException
NOTE: Method for putting resource record to (message) byte array. msgBytes must be != null. Enough capacity must be ensured (at least getTotalLen() bytes). If !isResource then ttl and rDataBytes are ignored. If msgBytes length > baseNameOffset then domain names compression is performed (using only content at baseNameOffset, which must be valid and not compressed). msgBytes array is altered. Result is new offset (just after this record).

Throws:
java.lang.NullPointerException
java.lang.ArrayIndexOutOfBoundsException
Since:
2.3

getTotalLen

public int getTotalLen()
NOTE: Result is the total length (in bytes) of this record. Result > 0.

Since:
2.3

getRName

public final DNSName getRName()
NOTE: Result != null.


getLevel

public int getLevel()
NOTE: Result >= 0. Result is the same as of getRName() getLevel().

Since:
3.0

getRType

public final int getRType()
NOTE: Result is an unsigned short.


getRClass

public final int getRClass()
NOTE: Result is an unsigned short.


getTTL

public final int getTTL()
NOTE: Result is unsigned.


getRData

public final java.lang.Object[] getRData()
NOTE: Result != null, result[index] != null for any index. Expected/required length for rType >= result length.


getRDataBytes

public final byte[] getRDataBytes()
NOTE: Result != null, result is a copy.


getRDataBytesLen

public final int getRDataBytesLen()
NOTE: Result >= 0.


length

public int length()
NOTE: Result is the number of elements accessible through getAt(int).

Specified by:
length in interface Indexable
Returns:
amount (non-negative value) of elements.
Since:
2.2
See Also:
Indexable.getAt(int)

getAt

public java.lang.Object getAt(int index)
                       throws java.lang.ArrayIndexOutOfBoundsException
NOTE: Result is (new Object[] { getRName(), new UnsignedInt(getRType()), new UnsignedInt(getRClass()), new UnsignedInt(getTTL()), new ByteVector(getRDataBytes()) })[index].

Specified by:
getAt in interface Indexable
Parameters:
index - the index (must be in the range) at which to return an element.
Returns:
an element (may be null) at index.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if index is negative or is not less than length().
Since:
2.2
See Also:
Indexable.length()

encodeRData

public static final byte[] encodeRData(int rType,
                                       java.lang.Object[] rData)
                                throws java.lang.NullPointerException,
                                       java.lang.IllegalArgumentException
NOTE: rData must be != null, rData[index] must be != null for any index. rData length may be not adequate to rType. rData elements/fields must be instances of ByteArray, DNSName, InetAddress, String or UnsignedInt (according to rType and field number). Result != null (result length is not verified).

Throws:
java.lang.NullPointerException
java.lang.IllegalArgumentException

decodeRData

public static final java.lang.Object[] decodeRData(int rType,
                                                   byte[] rDataBytes)
                                            throws java.lang.NullPointerException
NOTE: rDataBytes must be != null (may be ill-formed). Extra bytes are ignored. Result != null and result[index] != null for any index (each result[index] is instance of ByteArray, DNSName, InetAddress, String or UnsignedInt according to rType). Result length may be less than expected.

Throws:
java.lang.NullPointerException

decompressRData

public static final byte[] decompressRData(int rType,
                                           byte[] rDataBytes,
                                           byte[] msgBytes)
                                    throws java.lang.NullPointerException
NOTE: rDataBytes must be != null, msgBytes must be != null. Result != null. DNS name decompression is supported through msgBytes. If result == rDataBytes then rDataBytes content is not compressed. Original rDataBytes array itself and msgBytes array are not altered.

Throws:
java.lang.NullPointerException

compressRData

public static final int compressRData(int rType,
                                      byte[] msgBytes,
                                      int offset,
                                      int rDataBytesLen,
                                      int baseNameOffset)
                               throws java.lang.NullPointerException,
                                      java.lang.ArrayIndexOutOfBoundsException
NOTE: If offset > baseNameOffset then compression of recognized domain names is performed if possible (using only content at baseNameOffset, which must be valid and not compressed). msgBytes array is altered. Result is new offset (just after this processed rData bytes).

Throws:
java.lang.NullPointerException
java.lang.ArrayIndexOutOfBoundsException
Since:
2.3

canonizeRData

public static final boolean canonizeRData(int rType,
                                          byte[] rDataBytes)
                                   throws java.lang.NullPointerException
NOTE: rDataBytes must be != null. All found domain names in rData are canonized as specified in RFC2535. Result is true if and only if rDataBytes array is altered.

Throws:
java.lang.NullPointerException
Since:
2.3

hashCodeRData

public static final int hashCodeRData(int rType,
                                      byte[] rDataBytes)
                               throws java.lang.NullPointerException
NOTE: rDataBytes must be != null. Only recognized rData fields are hashed. Domain names and strings are hashed ignoring letters case (to comply with RFC2535).

Throws:
java.lang.NullPointerException

compareRData

public static final int compareRData(int rType,
                                     byte[] rDataBytesA,
                                     byte[] rDataBytesB,
                                     boolean decodeRData)
                              throws java.lang.NullPointerException
NOTE: rDataBytesA and rDataBytesB must be != null. If !decodeRData then rData contents are treated as unsigned byte arrays with upper-case letters in domain names converted to lower-case (as specified in RFC2535). Else any recognized domain name in rData is compared in label-by-label lower-case manner, any found string is compared (before comparing length of string) in the lower-case manner, content of any recognized ByteVector is compared before its length.

Throws:
java.lang.NullPointerException

maxRDataLen

public static final int maxRDataLen(int rType)
NOTE: Result >= decodeRData(rType, rDataBytes) length.

Since:
3.0

isIPAddress

public static final boolean isIPAddress(java.lang.String str,
                                        int beginIndex,
                                        int endIndex)
                                 throws java.lang.NullPointerException,
                                        java.lang.StringIndexOutOfBoundsException
NOTE: str must be != null, beginIndex and endIndex must be in the range. Result is true if and only if str region represents a valid IP address according to RFC1123 (that is, has a form of 'd.d.d.d' (with a possible '.' at the end), where 'd' is a decimal value within the unsigned byte range with some possible leading zeros).

Throws:
java.lang.NullPointerException
java.lang.StringIndexOutOfBoundsException
Since:
2.0

toRevAddressName

public static final DNSName toRevAddressName(java.net.InetAddress host)
                                      throws java.lang.NullPointerException
NOTE: host must be != null. host address is converted to reversed Inet host address name (according to RFC1035). Result != null.

Throws:
java.lang.NullPointerException
Since:
2.0

fromRevAddressName

public static final java.net.InetAddress fromRevAddressName(DNSName ptr)
                                                     throws java.lang.NullPointerException,
                                                            java.lang.IllegalArgumentException
NOTE: ptr must be != null. Host ptr is converted to Inet host address (according to RFC1035). Result != null.

Throws:
java.lang.NullPointerException
java.lang.IllegalArgumentException
Since:
2.0

toRevIp6Name

public static final DNSName toRevIp6Name(byte[] hostAAAA,
                                         int offset,
                                         int len)
                                  throws java.lang.NullPointerException,
                                         java.lang.ArrayIndexOutOfBoundsException
NOTE: hostAAAA must be != null, offset and len must be valid. hostAAAA IPv6 address is converted to reversed Inet IPv6 host address name (according to RFC1886). Result != null.

Throws:
java.lang.NullPointerException
java.lang.ArrayIndexOutOfBoundsException
Since:
2.0

fromRevIp6Name

public static final byte[] fromRevIp6Name(DNSName ptr)
                                   throws java.lang.NullPointerException,
                                          java.lang.IllegalArgumentException
NOTE: ptr must be != null. Host IPv6 ptr is converted to Inet IPv6 host address (according to RFC1886). Result != null, result length >= 0.

Throws:
java.lang.NullPointerException
java.lang.IllegalArgumentException
Since:
2.0

rClassAbbreviation

public static final java.lang.String rClassAbbreviation(int rClass)
NOTE: Result != null, result length() > 0, result is 'in-line'. These abbreviations are defined in RFC1035.


rTypeAbbreviation

public static final java.lang.String rTypeAbbreviation(int rType)
NOTE: Result != null, result length() > 0, result is 'in-line'. These abbreviations are first defined in RFC1035.


wksPortMapToString

public static final java.lang.String wksPortMapToString(byte[] portMap,
                                                        int offset,
                                                        int len)
                                                 throws java.lang.NullPointerException,
                                                        java.lang.ArrayIndexOutOfBoundsException
NOTE: portMap must be != null, offset and len must be valid. Result != null, result is 'in-line' (defined in RFC1035).

Throws:
java.lang.NullPointerException
java.lang.ArrayIndexOutOfBoundsException

rTypeMapToString

public static final java.lang.String rTypeMapToString(byte[] typeMap,
                                                      int offset,
                                                      int len)
                                               throws java.lang.NullPointerException,
                                                      java.lang.ArrayIndexOutOfBoundsException
NOTE: typeMap must be != null, offset and len must be valid. Result != null, result is 'in-line' (defined in RFC2065).

Throws:
java.lang.NullPointerException
java.lang.ArrayIndexOutOfBoundsException

addressToString

public static final java.lang.String addressToString(byte[] address,
                                                     int offset,
                                                     int len,
                                                     boolean lowerCase,
                                                     boolean zeroPadding,
                                                     boolean noCompactFormat,
                                                     boolean noMixedFormat)
                                              throws java.lang.NullPointerException,
                                                     java.lang.ArrayIndexOutOfBoundsException
NOTE: address must be != null, offset and len must be valid. Result != null, result is 'in-line' (defined in RFC1884).

Throws:
java.lang.NullPointerException
java.lang.ArrayIndexOutOfBoundsException
Since:
3.0

quoteString

public static final java.lang.String quoteString(java.lang.String str)
                                          throws java.lang.NullPointerException
NOTE: str must be != null (RFC1035). Escaping is not allowed in str. Result != null, result length() > 0, result is 'in-line' (escaped).

Throws:
java.lang.NullPointerException

locToString

public static final java.lang.String locToString(int value,
                                                 int index)
NOTE: Converts geographic location parameter to a string (RFC1876). Default fields index order is 4, 5, 6, 1, 2, 3 (Latitude, Longitude, Altitude, Size, Horiz_Pre, Vert_Pre). Other fields are converted to empty strings. Result != null, result length() > 0 (for valid indices), result is 'in-line'.


timeToString

public static final java.lang.String timeToString(int value)
NOTE: Converts UT seconds to a string (as defined in RFC2535). value is the unsigned number of seconds elapsed since the midnight of the 1st January, 1970 (Gregorian), GMT, ignoring leap seconds. The output date/time format is "yyyyMMddHHmmss". Result != null, result length() > 0, result is 'in-line'.

Since:
2.3

rDataToString

public static final java.lang.String rDataToString(int rType,
                                                   java.lang.Object rDataValue,
                                                   int index,
                                                   DNSName domain)
                                            throws java.lang.NullPointerException
NOTE: rDataValue must be != null. domain may be == null. Result != null, result is 'in-line', result is as defined in RFC1035.

Throws:
java.lang.NullPointerException

rDataIndex

public static final int rDataIndex(int rType,
                                   int textualIndex)
NOTE: Result is the index for rData array corresponding to textualIndex. Negative textualIndex is treated as zero. In fact, textualIndex should be iterated from 0 to maxRDataLen(rType) - 1, inclusive. Result >= 0, result may be >= rData length.

Since:
3.0

getFieldsAt

public static final java.lang.Object[] getFieldsAt(int field,
                                                   int rType,
                                                   DNSRecord[] records,
                                                   int offset,
                                                   int len)
                                            throws java.lang.NullPointerException,
                                                   java.lang.ArrayIndexOutOfBoundsException
NOTE: records must be != null, records[index] != null for any index. Negative len is treated as zero. If rType != ANY then only records with specified rType are accepted. If field is missing or field value is equal to the previous one then it is ignored. Only values of the specified field of rData of records are included into resulting array. Result is exact instanceof Object[], result[index] != null for any index, max(len, 0) >= result length.

Throws:
java.lang.NullPointerException
java.lang.ArrayIndexOutOfBoundsException
Since:
2.1

equalsQuery

public boolean equalsQuery(DNSRecord qdRecord)
NOTE: qdRecord may be == null. ANY qClass and IXFR, AXFR, MAILB, MAILA and ANY qTypes of qdRecord are treated specially (like wildcards).

Since:
2.0

equalsExact

public boolean equalsExact(DNSRecord record)
NOTE: record may be == null.

Since:
2.3

clone

public java.lang.Object clone()
Description copied from interface: ReallyCloneable
Creates and returns a copy of this object. By the clone() standard definition, this method creates a new instance of the class of this object and initializes all its fields with exactly the contents of the corresponding fields of this object. Typically, native clone() method of Object class is used inside this method.

Specified by:
clone in interface ReallyCloneable
Overrides:
clone in class java.lang.Object
Returns:
a copy (not null and != this) of this instance.

hashCode

public int hashCode()
NOTE: ttl is omitted (as if ttl == 0).

Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
NOTE: ttl is ignored. rData contents are compared in the case-insensitive manner for DNSName fields. All unrecognized fields are ignored too.

Overrides:
equals in class java.lang.Object

greaterThan

public boolean greaterThan(java.lang.Object obj)
NOTE: Method for canonical ordering (according to RFC2535).

Specified by:
greaterThan in interface Sortable
Parameters:
obj - the second compared object (may be null).
Returns:
true if obj is comparable with this and this object is greater than obj, else false.
Since:
2.3

compareTo

public int compareTo(DNSRecord record,
                     boolean decodeRData)
              throws java.lang.NullPointerException
NOTE: record must be != null. rClass is compared first, then rName is compared, then rType is compared (SOA is handled specially to be less than other types, SIG(rType) for any rType is handled specially to be greater than rType and less than rType + 1), and then rData contents are compared as byte arrays (with upper-case letters in DNSName fields set to lower-case). ttl is ignored. If decodeRData then rData contents are compared in the field-by-field manner, each recognized field is compared according to its type (in addition, strings are case-insensitive). Records canonical order (decodeRData == false) is defined in RFC2535 (except for SOA handling but it is important since SOA record must be the first record in a zone).

Throws:
java.lang.NullPointerException

toString

public java.lang.String toString(DNSName domain,
                                 DNSRecord prevRecord,
                                 boolean tabSeparated)
NOTE: If domain == null then current zone domain is not specified. If prevRecord == null then default rName, rClass and ttl values are not specified. Else all defaults are omitted in the result. The textual output format is "[relativeRName] [rClassAbbr] [ttl] rTypeAbbr [rData]" (as specified in RFC1035). If tabSeparated then all fields are separated with a single tab character else these fields are separated (and padded to be mostly aligned) with blanks. All rData elements are separated with a single blank. Result != null, result length() > 0, result is 'in-line'.


toString

public java.lang.String toString()
NOTE: No default values. Result length > 0, result is 'in-line', result format is specified in RFC1035 (fields are separated with blanks).

Overrides:
toString in class java.lang.Object

integrityCheck

public void integrityCheck()
NOTE: Check record and its name objects for their integrity. For debug purpose only.

Specified by:
integrityCheck in interface Verifiable
Since:
2.3