Class Record<D extends Data>

java.lang.Object
org.minidns.record.Record<D>

public final class Record<D extends Data> extends Object
A generic DNS record.
  • Field Details Link icon

    • name Link icon

      public final DnsName name
      The generic name of this record.
    • type Link icon

      public final Record.TYPE type
      The type (and payload type) of this record.
    • clazz Link icon

      public final Record.CLASS clazz
      The record class (usually CLASS.IN).
    • clazzValue Link icon

      public final int clazzValue
      The value of the class field of a RR. According to RFC 2671 (OPT RR) this is not necessarily representable using clazz field and unicastQuery bit
    • ttl Link icon

      public final long ttl
      The ttl of this record.
    • payloadData Link icon

      public final D extends Data payloadData
      The payload object of this record.
    • unicastQuery Link icon

      public final boolean unicastQuery
      MDNS defines the highest bit of the class as the unicast query bit.
  • Constructor Details Link icon

  • Method Details Link icon

    • parse Link icon

      public static Record<Data> parse(DataInputStream dis, byte[] data) throws 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.
      Returns:
      the record which was parsed.
      Throws:
      IOException - In case of malformed replies.
    • toOutputStream Link icon

      public void toOutputStream(OutputStream outputStream) throws IOException
      Throws:
      IOException
    • toByteArray Link icon

      public byte[] toByteArray()
    • toString Link icon

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

      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 Link icon

      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.
    • getPayload Link icon

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

      public long getTtl()
      Retrieve the record ttl.
      Returns:
      The record ttl.
    • getQuestion Link icon

      Get the question asking for this resource record. This will return null if the record is not retrievable, i.e. Record.TYPE.OPT.
      Returns:
      the question for this resource record or null.
    • getQuestionMessage Link icon

    • hashCode Link icon

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

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • ifPossibleAs Link icon

      public <E extends Data> Record<E> ifPossibleAs(Class<E> dataClass)
      Return the record if possible as record with the given Data class. If the record does not hold payload of the given data class type, then null will be returned.
      Type Parameters:
      E - a subtype of Data.
      Parameters:
      dataClass - a class of the Data type.
      Returns:
      the record with a specialized payload type or null.
      See Also:
    • as Link icon

      public <E extends Data> Record<E> as(Class<E> dataClass)
      Return the record as record with the given Data class. If the record does not hold payload of the given data class type, then a IllegalArgumentException will be thrown.
      Type Parameters:
      E - a subtype of Data.
      Parameters:
      dataClass - a class of the Data type.
      Returns:
      the record with a specialized payload type.
      See Also:
    • filter Link icon

      public static <E extends Data> void filter(Collection<Record<E>> result, Class<E> dataClass, Collection<Record<? extends Data>> input)
    • filter Link icon

      public static <E extends Data> List<Record<E>> filter(Class<E> dataClass, Collection<Record<? extends Data>> input)