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

public abstract class Dataextends Object
Abstract base class for DNS record data payloads.
All DNS record types extend this class to provide their specific data representation and parsing logic.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private byte[]
    The record's bytes.
    private Integer
    Cache of the computed hash code.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor for record types; each subclass sets its own fields.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    equals(Object other)
     
    abstract Record.TYPE
    The payload type.
    final int
     
    final int
    Serialize this record, if that has not been done already, and report the resulting wire size.
    protected abstract void
    The internal method used to serialize Data subclasses.
    private void
    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 void
    Write the binary representation of this payload to the given DataOutputStream.
    final void
    Write the binary representation to the given OutputStream.

    Methods inherited from class Object

    clone, getClass, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • bytes

      private byte[] bytes
      The record's bytes.
    • hashCodeCache

      private transient Integer 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

      public abstract Record.TYPE getType()
      The payload type.
      Returns:
      The DNS record type of this payload.
    • serialize

      protected abstract void serialize(DataOutputStream dos) throws IOException
      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

      public final void toOutputStream(OutputStream outputStream) throws IOException
      Write the binary representation to the given OutputStream.
      Parameters:
      outputStream - the OutputStream to write to.
      Throws:
      IOException - if an I/O error occurs.
    • toOutputStream

      public final void toOutputStream(DataOutputStream dos) throws IOException
      Write the binary representation of this payload to the given DataOutputStream.
      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

      public final int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public final boolean equals(Object other)
      Overrides:
      equals in class Object