Package io.netty.handler.codec.dns
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
@UnstableApi public abstract class AbstractDnsMessage extends AbstractReferenceCounted implements DnsMessage
A skeletal implementation ofDnsMessage.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Objectadditionalsprivate java.lang.Objectanswersprivate java.lang.Objectauthoritiesprivate shortidprivate ResourceLeakTracker<DnsMessage>leakprivate static ResourceLeakDetector<DnsMessage>leakDetectorprivate DnsOpCodeopCodeprivate java.lang.Objectquestionsprivate booleanrecursionDesiredprivate static intSECTION_COUNTprivate static intSECTION_QUESTIONprivate bytez
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractDnsMessage(int id)Creates a new instance with the specifiedidandDnsOpCode.QUERYopCode.protectedAbstractDnsMessage(int id, DnsOpCode opCode)Creates a new instance with the specifiedidandopCode.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidaddRecord(int section, int index, DnsRecord record)private voidaddRecord(int section, DnsRecord record)DnsMessageaddRecord(DnsSection section, int index, DnsRecord record)Adds the specifiedrecordat the specifiedindexof the specifiedsectionof this DNS message.DnsMessageaddRecord(DnsSection section, DnsRecord record)Adds the specifiedrecordat the end of the specifiedsectionof this DNS message.private static <T extends DnsRecord>
TcastRecord(java.lang.Object record)private static DnsRecordcheckQuestion(int section, DnsRecord record)DnsMessageclear()Removes all the records in this DNS message.private voidclear(int section)DnsMessageclear(DnsSection section)Removes all the records in the specifiedsectionof this DNS message.intcount()Returns the number of records in this DNS message.private intcount(int section)intcount(DnsSection section)Returns the number of records in the specifiedsectionof this DNS message.protected voiddeallocate()Called onceAbstractReferenceCounted.refCnt()is equals 0.booleanequals(java.lang.Object obj)inthashCode()intid()Returns theIDof this DNS message.booleanisRecursionDesired()Returns theRD(recursion desired} field of this DNS message.private static java.util.ArrayList<DnsRecord>newRecordList()DnsOpCodeopCode()Returns theopCodeof this DNS message.private <T extends DnsRecord>
TrecordAt(int section)private <T extends DnsRecord>
TrecordAt(int section, int index)<T extends DnsRecord>
TrecordAt(DnsSection section)Returns the first record in the specifiedsectionof this DNS message.<T extends DnsRecord>
TrecordAt(DnsSection section, int index)Returns the record at the specifiedindexof the specifiedsectionof this DNS message.private <T extends DnsRecord>
TremoveRecord(int section, int index)<T extends DnsRecord>
TremoveRecord(DnsSection section, int index)Removes the record at the specifiedindexof the specifiedsectionfrom this DNS message.DnsMessageretain()Increases the reference count by1.DnsMessageretain(int increment)Increases the reference count by the specifiedincrement.private java.lang.ObjectsectionAt(int section)private static intsectionOrdinal(DnsSection section)DnsMessagesetId(int id)Sets theIDof this DNS message.DnsMessagesetOpCode(DnsOpCode opCode)Sets theopCodeof this DNS message.private <T extends DnsRecord>
TsetRecord(int section, int index, DnsRecord record)private voidsetRecord(int section, DnsRecord record)<T extends DnsRecord>
TsetRecord(DnsSection section, int index, DnsRecord record)Sets the specifiedrecordat the specifiedindexof the specifiedsectionof this DNS message.DnsMessagesetRecord(DnsSection section, DnsRecord record)Sets the specifiedsectionof this DNS message to the specifiedrecord, making it a single-record section.DnsMessagesetRecursionDesired(boolean recursionDesired)Sets theRD(recursion desired} field of this DNS message.private voidsetSection(int section, java.lang.Object value)DnsMessagesetZ(int z)Sets theZ(reserved for future use) field of this DNS message.DnsMessagetouch()Records the current access location of this object for debugging purposes.DnsMessagetouch(java.lang.Object hint)Records the current access location of this object with an additional arbitrary information for debugging purposes.intz()Returns theZ(reserved for future use) field of this DNS message.-
Methods inherited from class io.netty.util.AbstractReferenceCounted
refCnt, release, release, setRefCnt
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.netty.util.ReferenceCounted
refCnt, release, release
-
-
-
-
Field Detail
-
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:
- Constant Field Values
-
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 Detail
-
AbstractDnsMessage
protected AbstractDnsMessage(int id)
Creates a new instance with the specifiedidandDnsOpCode.QUERYopCode.
-
AbstractDnsMessage
protected AbstractDnsMessage(int id, DnsOpCode opCode)Creates a new instance with the specifiedidandopCode.
-
-
Method Detail
-
id
public int id()
Description copied from interface:DnsMessageReturns theIDof this DNS message.- Specified by:
idin interfaceDnsMessage
-
setId
public DnsMessage setId(int id)
Description copied from interface:DnsMessageSets theIDof this DNS message.- Specified by:
setIdin interfaceDnsMessage
-
opCode
public DnsOpCode opCode()
Description copied from interface:DnsMessageReturns theopCodeof this DNS message.- Specified by:
opCodein interfaceDnsMessage
-
setOpCode
public DnsMessage setOpCode(DnsOpCode opCode)
Description copied from interface:DnsMessageSets theopCodeof this DNS message.- Specified by:
setOpCodein interfaceDnsMessage
-
isRecursionDesired
public boolean isRecursionDesired()
Description copied from interface:DnsMessageReturns theRD(recursion desired} field of this DNS message.- Specified by:
isRecursionDesiredin interfaceDnsMessage
-
setRecursionDesired
public DnsMessage setRecursionDesired(boolean recursionDesired)
Description copied from interface:DnsMessageSets theRD(recursion desired} field of this DNS message.- Specified by:
setRecursionDesiredin interfaceDnsMessage
-
z
public int z()
Description copied from interface:DnsMessageReturns theZ(reserved for future use) field of this DNS message.- Specified by:
zin interfaceDnsMessage
-
setZ
public DnsMessage setZ(int z)
Description copied from interface:DnsMessageSets theZ(reserved for future use) field of this DNS message.- Specified by:
setZin interfaceDnsMessage
-
count
public int count(DnsSection section)
Description copied from interface:DnsMessageReturns the number of records in the specifiedsectionof this DNS message.- Specified by:
countin interfaceDnsMessage
-
count
private int count(int section)
-
count
public int count()
Description copied from interface:DnsMessageReturns the number of records in this DNS message.- Specified by:
countin interfaceDnsMessage
-
recordAt
public <T extends DnsRecord> T recordAt(DnsSection section)
Description copied from interface:DnsMessageReturns the first record in the specifiedsectionof this DNS message. When the specifiedsectionisDnsSection.QUESTION, the type of the returned record is alwaysDnsQuestion.- Specified by:
recordAtin interfaceDnsMessage- Returns:
nullif this message doesn't have any records in the specifiedsection
-
recordAt
private <T extends DnsRecord> T recordAt(int section)
-
recordAt
public <T extends DnsRecord> T recordAt(DnsSection section, int index)
Description copied from interface:DnsMessageReturns the record at the specifiedindexof the specifiedsectionof this DNS message. When the specifiedsectionisDnsSection.QUESTION, the type of the returned record is alwaysDnsQuestion.- Specified by:
recordAtin interfaceDnsMessage
-
recordAt
private <T extends DnsRecord> T recordAt(int section, int index)
-
setRecord
public DnsMessage setRecord(DnsSection section, DnsRecord record)
Description copied from interface:DnsMessageSets the specifiedsectionof this DNS message to the specifiedrecord, making it a single-record section. When the specifiedsectionisDnsSection.QUESTION, the specifiedrecordmust be aDnsQuestion.- Specified by:
setRecordin interfaceDnsMessage
-
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:DnsMessageSets the specifiedrecordat the specifiedindexof the specifiedsectionof this DNS message. When the specifiedsectionisDnsSection.QUESTION, the specifiedrecordmust be aDnsQuestion.- Specified by:
setRecordin interfaceDnsMessage- Returns:
- the old record
-
addRecord
public DnsMessage addRecord(DnsSection section, DnsRecord record)
Description copied from interface:DnsMessageAdds the specifiedrecordat the end of the specifiedsectionof this DNS message. When the specifiedsectionisDnsSection.QUESTION, the specifiedrecordmust be aDnsQuestion.- Specified by:
addRecordin interfaceDnsMessage
-
addRecord
private void addRecord(int section, DnsRecord record)
-
addRecord
public DnsMessage addRecord(DnsSection section, int index, DnsRecord record)
Description copied from interface:DnsMessageAdds the specifiedrecordat the specifiedindexof the specifiedsectionof this DNS message. When the specifiedsectionisDnsSection.QUESTION, the specifiedrecordmust be aDnsQuestion.- Specified by:
addRecordin interfaceDnsMessage
-
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:DnsMessageRemoves the record at the specifiedindexof the specifiedsectionfrom this DNS message. When the specifiedsectionisDnsSection.QUESTION, the type of the returned record is alwaysDnsQuestion.- Specified by:
removeRecordin interfaceDnsMessage- 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:DnsMessageRemoves all the records in the specifiedsectionof this DNS message.- Specified by:
clearin interfaceDnsMessage
-
clear
public DnsMessage clear()
Description copied from interface:DnsMessageRemoves all the records in this DNS message.- Specified by:
clearin interfaceDnsMessage
-
clear
private void clear(int section)
-
touch
public DnsMessage touch()
Description copied from interface:ReferenceCountedRecords 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 viaResourceLeakDetector. This method is a shortcut totouch(null).- Specified by:
touchin interfaceDnsMessage- Specified by:
touchin interfaceReferenceCounted- Overrides:
touchin classAbstractReferenceCounted
-
touch
public DnsMessage touch(java.lang.Object hint)
Description copied from interface:ReferenceCountedRecords 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 viaResourceLeakDetector.- Specified by:
touchin interfaceDnsMessage- Specified by:
touchin interfaceReferenceCounted
-
retain
public DnsMessage retain()
Description copied from interface:ReferenceCountedIncreases the reference count by1.- Specified by:
retainin interfaceDnsMessage- Specified by:
retainin interfaceReferenceCounted- Overrides:
retainin classAbstractReferenceCounted
-
retain
public DnsMessage retain(int increment)
Description copied from interface:ReferenceCountedIncreases the reference count by the specifiedincrement.- Specified by:
retainin interfaceDnsMessage- Specified by:
retainin interfaceReferenceCounted- Overrides:
retainin classAbstractReferenceCounted
-
deallocate
protected void deallocate()
Description copied from class:AbstractReferenceCountedCalled onceAbstractReferenceCounted.refCnt()is equals 0.- Specified by:
deallocatein classAbstractReferenceCounted
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.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)
-
castRecord
private static <T extends DnsRecord> T castRecord(java.lang.Object record)
-
newRecordList
private static java.util.ArrayList<DnsRecord> newRecordList()
-
-