java.lang.Object
org.minidns.record.Data
- Direct Known Subclasses:
DelegatingDnssecRR, DNSKEY, InternetAddressRR, MX, NSEC, NSEC3, NSEC3PARAM, OPENPGPKEY, OPT, RRSIG, RRWithTarget, SOA, TLSA, TXT, UNKNOWN
Abstract base class for DNS record data payloads.
All DNS record types extend this class to provide their specific data representation and parsing logic.
All DNS record types extend this class to provide their specific data representation and parsing logic.
Field Summary
FieldsModifier and TypeFieldDescriptionprivate byte[]The record's bytes.private IntegerCache of the computed hash code.Constructor Summary
ConstructorsMethod Summary
Modifier and TypeMethodDescriptionfinal booleanabstract Record.TYPEgetType()The payload type.final inthashCode()final intlength()Serialize this record, if that has not been done already, and report the resulting wire size.protected abstract voidThe internal method used to serialize Data subclasses.private voidsetBytes()Rebuilds the bytes from the parsed fields.final byte[]Serialize this record, if that has not been done already, and return a copy of the result so callers cannot mutate the cached bytes.final voidWrite the binary representation of this payload to the givenDataOutputStream.final voidtoOutputStream(OutputStream outputStream) Write the binary representation to the given OutputStream.
Field Details
bytes
private byte[] bytesThe record's bytes.hashCodeCache
Cache of the computed hash code.
Constructor Details
Data
public Data()Constructor for record types; each subclass sets its own fields.
Method Details
getType
serialize
The internal method used to serialize Data subclasses.- Parameters:
dos- the output stream to serialize to.- Throws:
IOException- if an I/O error occurs.
setBytes
private void setBytes()Rebuilds the bytes from the parsed fields.length
public final int length()Serialize this record, if that has not been done already, and report the resulting wire size.- Returns:
- the number of bytes this record serializes to
toOutputStream
Write the binary representation to the given OutputStream.- Parameters:
outputStream- the OutputStream to write to.- Throws:
IOException- if an I/O error occurs.
toOutputStream
Write the binary representation of this payload to the givenDataOutputStream.- Parameters:
dos- the DataOutputStream to write to.- Throws:
IOException- if an I/O error occurs.
toByteArray
public final byte[] toByteArray()Serialize this record, if that has not been done already, and return a copy of the result so callers cannot mutate the cached bytes.- Returns:
- the binary representation as a byte array
hashCode
equals