Class AbstractDnsMessage

java.lang.Object
io.netty.util.AbstractReferenceCounted
io.netty.handler.codec.dns.AbstractDnsMessage
All Implemented Interfaces:
DnsMessage, ReferenceCounted
Direct Known Subclasses:
DefaultDnsQuery, DefaultDnsResponse

public abstract class AbstractDnsMessage extends AbstractReferenceCounted implements DnsMessage
A skeletal implementation of DnsMessage.
  • Field Details

    • leakDetector

      private static final ResourceLeakDetector<DnsMessage> leakDetector
    • SECTION_QUESTION

      private static final int SECTION_QUESTION
    • SECTION_COUNT

      private static final int SECTION_COUNT
      See Also:
    • leak

      private final ResourceLeakTracker<DnsMessage> leak
    • id

      private short id
    • opCode

      private DnsOpCode opCode
    • recursionDesired

      private boolean recursionDesired
    • z

      private byte z
    • questions

      private java.lang.Object questions
    • answers

      private java.lang.Object answers
    • authorities

      private java.lang.Object authorities
    • additionals

      private java.lang.Object additionals
  • Constructor Details

    • AbstractDnsMessage

      protected AbstractDnsMessage(int id)
      Creates a new instance with the specified id and DnsOpCode.QUERY opCode.
    • AbstractDnsMessage

      protected AbstractDnsMessage(int id, DnsOpCode opCode)
      Creates a new instance with the specified id and opCode.
  • Method Details

    • id

      public int id()
      Description copied from interface: DnsMessage
      Returns the ID of this DNS message.
      Specified by:
      id in interface DnsMessage
    • setId

      public DnsMessage setId(int id)
      Description copied from interface: DnsMessage
      Sets the ID of this DNS message.
      Specified by:
      setId in interface DnsMessage
    • opCode

      public DnsOpCode opCode()
      Description copied from interface: DnsMessage
      Returns the opCode of this DNS message.
      Specified by:
      opCode in interface DnsMessage
    • setOpCode

      public DnsMessage setOpCode(DnsOpCode opCode)
      Description copied from interface: DnsMessage
      Sets the opCode of this DNS message.
      Specified by:
      setOpCode in interface DnsMessage
    • isRecursionDesired

      public boolean isRecursionDesired()
      Description copied from interface: DnsMessage
      Returns the RD (recursion desired} field of this DNS message.
      Specified by:
      isRecursionDesired in interface DnsMessage
    • setRecursionDesired

      public DnsMessage setRecursionDesired(boolean recursionDesired)
      Description copied from interface: DnsMessage
      Sets the RD (recursion desired} field of this DNS message.
      Specified by:
      setRecursionDesired in interface DnsMessage
    • z

      public int z()
      Description copied from interface: DnsMessage
      Returns the Z (reserved for future use) field of this DNS message.
      Specified by:
      z in interface DnsMessage
    • setZ

      public DnsMessage setZ(int z)
      Description copied from interface: DnsMessage
      Sets the Z (reserved for future use) field of this DNS message.
      Specified by:
      setZ in interface DnsMessage
    • count

      public int count(DnsSection section)
      Description copied from interface: DnsMessage
      Returns the number of records in the specified section of this DNS message.
      Specified by:
      count in interface DnsMessage
    • count

      private int count(int section)
    • count

      public int count()
      Description copied from interface: DnsMessage
      Returns the number of records in this DNS message.
      Specified by:
      count in interface DnsMessage
    • recordAt

      public <T extends DnsRecord> T recordAt(DnsSection section)
      Description copied from interface: DnsMessage
      Returns the first record in the specified section of this DNS message. When the specified section is DnsSection.QUESTION, the type of the returned record is always DnsQuestion.
      Specified by:
      recordAt in interface DnsMessage
      Returns:
      null if this message doesn't have any records in the specified section
    • recordAt

      private <T extends DnsRecord> T recordAt(int section)
    • recordAt

      public <T extends DnsRecord> T recordAt(DnsSection section, int index)
      Description copied from interface: DnsMessage
      Returns the record at the specified index of the specified section of this DNS message. When the specified section is DnsSection.QUESTION, the type of the returned record is always DnsQuestion.
      Specified by:
      recordAt in interface DnsMessage
    • recordAt

      private <T extends DnsRecord> T recordAt(int section, int index)
    • setRecord

      public DnsMessage setRecord(DnsSection section, DnsRecord record)
      Description copied from interface: DnsMessage
      Sets the specified section of this DNS message to the specified record, making it a single-record section. When the specified section is DnsSection.QUESTION, the specified record must be a DnsQuestion.
      Specified by:
      setRecord in interface DnsMessage
    • setRecord

      private void setRecord(int section, DnsRecord record)
    • setRecord

      public <T extends DnsRecord> T setRecord(DnsSection section, int index, DnsRecord record)
      Description copied from interface: DnsMessage
      Sets the specified record at the specified index of the specified section of this DNS message. When the specified section is DnsSection.QUESTION, the specified record must be a DnsQuestion.
      Specified by:
      setRecord in interface DnsMessage
      Returns:
      the old record
    • setRecord

      private <T extends DnsRecord> T setRecord(int section, int index, DnsRecord record)
    • addRecord

      public DnsMessage addRecord(DnsSection section, DnsRecord record)
      Description copied from interface: DnsMessage
      Adds the specified record at the end of the specified section of this DNS message. When the specified section is DnsSection.QUESTION, the specified record must be a DnsQuestion.
      Specified by:
      addRecord in interface DnsMessage
    • addRecord

      private void addRecord(int section, DnsRecord record)
    • addRecord

      public DnsMessage addRecord(DnsSection section, int index, DnsRecord record)
      Description copied from interface: DnsMessage
      Adds the specified record at the specified index of the specified section of this DNS message. When the specified section is DnsSection.QUESTION, the specified record must be a DnsQuestion.
      Specified by:
      addRecord in interface DnsMessage
    • addRecord

      private void addRecord(int section, int index, DnsRecord record)
    • removeRecord

      public <T extends DnsRecord> T removeRecord(DnsSection section, int index)
      Description copied from interface: DnsMessage
      Removes the record at the specified index of the specified section from this DNS message. When the specified section is DnsSection.QUESTION, the type of the returned record is always DnsQuestion.
      Specified by:
      removeRecord in interface DnsMessage
      Returns:
      the removed record
    • removeRecord

      private <T extends DnsRecord> T removeRecord(int section, int index)
    • clear

      public DnsMessage clear(DnsSection section)
      Description copied from interface: DnsMessage
      Removes all the records in the specified section of this DNS message.
      Specified by:
      clear in interface DnsMessage
    • clear

      public DnsMessage clear()
      Description copied from interface: DnsMessage
      Removes all the records in this DNS message.
      Specified by:
      clear in interface DnsMessage
    • clear

      private void clear(int section)
    • touch

      public DnsMessage touch()
      Description copied from interface: ReferenceCounted
      Records the current access location of this object for debugging purposes. If this object is determined to be leaked, the information recorded by this operation will be provided to you via ResourceLeakDetector. This method is a shortcut to touch(null).
      Specified by:
      touch in interface DnsMessage
      Specified by:
      touch in interface ReferenceCounted
      Overrides:
      touch in class AbstractReferenceCounted
    • touch

      public DnsMessage touch(java.lang.Object hint)
      Description copied from interface: ReferenceCounted
      Records the current access location of this object with an additional arbitrary information for debugging purposes. If this object is determined to be leaked, the information recorded by this operation will be provided to you via ResourceLeakDetector.
      Specified by:
      touch in interface DnsMessage
      Specified by:
      touch in interface ReferenceCounted
    • retain

      public DnsMessage retain()
      Description copied from interface: ReferenceCounted
      Increases the reference count by 1.
      Specified by:
      retain in interface DnsMessage
      Specified by:
      retain in interface ReferenceCounted
      Overrides:
      retain in class AbstractReferenceCounted
    • retain

      public DnsMessage retain(int increment)
      Description copied from interface: ReferenceCounted
      Increases the reference count by the specified increment.
      Specified by:
      retain in interface DnsMessage
      Specified by:
      retain in interface ReferenceCounted
      Overrides:
      retain in class AbstractReferenceCounted
    • deallocate

      protected void deallocate()
      Description copied from class: AbstractReferenceCounted
      Called once AbstractReferenceCounted.refCnt() is equals 0.
      Specified by:
      deallocate in class AbstractReferenceCounted
    • equals

      public boolean equals(java.lang.Object obj)
      Overrides:
      equals in class java.lang.Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class java.lang.Object
    • sectionAt

      private java.lang.Object sectionAt(int section)
    • setSection

      private void setSection(int section, java.lang.Object value)
    • sectionOrdinal

      private static int sectionOrdinal(DnsSection section)
    • checkQuestion

      private static DnsRecord checkQuestion(int section, DnsRecord record)
    • castRecord

      private static <T extends DnsRecord> T castRecord(java.lang.Object record)
    • newRecordList

      private static java.util.ArrayList<DnsRecord> newRecordList()