Class Record


  • public class Record
    extends java.lang.Object
    A generic DNS record.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Record.CLASS
      The symbolic class of a DNS record (usually IN for Internet).
      static class  Record.TYPE
      The record type.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected Record.CLASS clazz
      The record class (usually CLASS.IN).
      private static java.util.logging.Logger LOGGER  
      protected java.lang.String name
      The generic name of this record.
      protected Data payloadData
      The payload object of this record.
      protected long ttl
      The ttl of this record.
      protected Record.TYPE type
      The type (and payload type) of this record.
      protected boolean unicastQuery
      MDNS defines the highest bit of the class as the unicast query bit.
    • Constructor Summary

      Constructors 
      Constructor Description
      Record()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getName()
      The generic record name, e.g.
      Data getPayload()
      The payload data, usually a subclass of data (A, AAAA, CNAME, ...).
      long getTtl()
      Retrieve the record ttl.
      boolean isAnswer​(Question q)
      Check if this record answers a given query.
      boolean isUnicastQuery()
      See if this query/response was a unicast query (highest class bit set).
      void parse​(java.io.DataInputStream dis, byte[] data)
      Parse a given record based on the full message data and the current stream position.
      java.lang.String toString()
      Retrieve a textual representation of this resource record.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • LOGGER

        private static final java.util.logging.Logger LOGGER
      • name

        protected java.lang.String name
        The generic name of this record.
      • type

        protected Record.TYPE type
        The type (and payload type) of this record.
      • clazz

        protected Record.CLASS clazz
        The record class (usually CLASS.IN).
      • ttl

        protected long ttl
        The ttl of this record.
      • payloadData

        protected Data payloadData
        The payload object of this record.
      • unicastQuery

        protected boolean unicastQuery
        MDNS defines the highest bit of the class as the unicast query bit.
    • Constructor Detail

      • Record

        public Record()
    • Method Detail

      • parse

        public void parse​(java.io.DataInputStream dis,
                          byte[] data)
                   throws java.io.IOException
        Parse a given record based on the full message data and the current stream position.
        Parameters:
        dis - The DataInputStream positioned at the first record byte.
        data - The full message data.
        Throws:
        java.io.IOException - In case of malformed replies.
      • toString

        public java.lang.String toString()
        Retrieve a textual representation of this resource record.
        Overrides:
        toString in class java.lang.Object
        Returns:
        String
      • isAnswer

        public boolean isAnswer​(Question q)
        Check if this record answers a given query.
        Parameters:
        q - The query.
        Returns:
        True if this record is a valid answer.
      • isUnicastQuery

        public boolean isUnicastQuery()
        See if this query/response was a unicast query (highest class bit set).
        Returns:
        True if it is a unicast query/response record.
      • getName

        public java.lang.String getName()
        The generic record name, e.g. "measite.de".
        Returns:
        The record name.
      • getPayload

        public Data getPayload()
        The payload data, usually a subclass of data (A, AAAA, CNAME, ...).
        Returns:
        The payload data.
      • getTtl

        public long getTtl()
        Retrieve the record ttl.
        Returns:
        The record ttl.