java.lang.Object
org.minidns.record.Data
org.minidns.record.InternetAddressRR<IA>
Type Parameters:
IA - type of InetAddress stored in this record
Direct Known Subclasses:
A, AAAA

public abstract class InternetAddressRR<IA extends InetAddress>extends Data
Abstract base class for DNS resource records representing internet addresses.
Extended by A and AAAA records to provide common functionality for IP address storage and retrieval.
  • Field Details

    • ip

      protected final byte[] ip
      Target IP.
    • inetAddress

      private transient IA extends InetAddress inetAddress
      Cache for the InetAddress this record presents.
  • Constructor Details

    • InternetAddressRR

      protected InternetAddressRR(byte[] ip)
      Holds the raw address bytes of an address record.
      Parameters:
      ip - raw address bytes, in the record's A/AAAA family order
    • InternetAddressRR

      protected InternetAddressRR(IA inetAddress)
      Holds the raw address bytes and caches the resolved form.
      Parameters:
      inetAddress - resolved address whose cached form this record returns
  • Method Details

    • serialize

      public final void serialize(DataOutputStream dos) throws IOException
      Writes the raw address bytes to the stream.
      Specified by:
      serialize in class Data
      Parameters:
      dos - the output stream to serialize to.
      Throws:
      IOException - if an I/O error occurs.
    • getIp

      public final byte[] getIp()
      Allocates a new byte buffer and fills the buffer with the bytes representing the IP address of this resource record.
      Returns:
      a new byte buffer containing the bytes of the IP.
    • getInetAddress

      public final IA getInetAddress()
      Get the InetAddress for this record.
      Returns:
      the InetAddress, computed lazily and cached
    • from

      public static InternetAddressRR<? extends InetAddress> from(InetAddress inetAddress)
      Create an InternetAddressRR from an InetAddress.
      Parameters:
      inetAddress - the InetAddress to convert
      Returns:
      an A or AAAA record as appropriate