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
public abstract class AbstractDnsMessage extends AbstractReferenceCounted implements DnsMessage
A skeletal implementation ofDnsMessage
.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Object
additionals
private java.lang.Object
answers
private java.lang.Object
authorities
private short
id
private ResourceLeakTracker<DnsMessage>
leak
private static ResourceLeakDetector<DnsMessage>
leakDetector
private DnsOpCode
opCode
private java.lang.Object
questions
private boolean
recursionDesired
private static int
SECTION_COUNT
private static int
SECTION_QUESTION
private byte
z
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractDnsMessage(int id)
Creates a new instance with the specifiedid
andDnsOpCode.QUERY
opCode.protected
AbstractDnsMessage(int id, DnsOpCode opCode)
Creates a new instance with the specifiedid
andopCode
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addRecord(int section, int index, DnsRecord record)
private void
addRecord(int section, DnsRecord record)
DnsMessage
addRecord(DnsSection section, int index, DnsRecord record)
Adds the specifiedrecord
at the specifiedindex
of the specifiedsection
of this DNS message.DnsMessage
addRecord(DnsSection section, DnsRecord record)
Adds the specifiedrecord
at the end of the specifiedsection
of this DNS message.private static <T extends DnsRecord>
TcastRecord(java.lang.Object record)
private static DnsRecord
checkQuestion(int section, DnsRecord record)
DnsMessage
clear()
Removes all the records in this DNS message.private void
clear(int section)
DnsMessage
clear(DnsSection section)
Removes all the records in the specifiedsection
of this DNS message.int
count()
Returns the number of records in this DNS message.private int
count(int section)
int
count(DnsSection section)
Returns the number of records in the specifiedsection
of this DNS message.protected void
deallocate()
Called onceAbstractReferenceCounted.refCnt()
is equals 0.boolean
equals(java.lang.Object obj)
int
hashCode()
int
id()
Returns theID
of this DNS message.boolean
isRecursionDesired()
Returns theRD
(recursion desired} field of this DNS message.private static java.util.ArrayList<DnsRecord>
newRecordList()
DnsOpCode
opCode()
Returns theopCode
of 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 specifiedsection
of this DNS message.<T extends DnsRecord>
TrecordAt(DnsSection section, int index)
Returns the record at the specifiedindex
of the specifiedsection
of 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 specifiedindex
of the specifiedsection
from this DNS message.DnsMessage
retain()
Increases the reference count by1
.DnsMessage
retain(int increment)
Increases the reference count by the specifiedincrement
.private java.lang.Object
sectionAt(int section)
private static int
sectionOrdinal(DnsSection section)
DnsMessage
setId(int id)
Sets theID
of this DNS message.DnsMessage
setOpCode(DnsOpCode opCode)
Sets theopCode
of this DNS message.private <T extends DnsRecord>
TsetRecord(int section, int index, DnsRecord record)
private void
setRecord(int section, DnsRecord record)
<T extends DnsRecord>
TsetRecord(DnsSection section, int index, DnsRecord record)
Sets the specifiedrecord
at the specifiedindex
of the specifiedsection
of this DNS message.DnsMessage
setRecord(DnsSection section, DnsRecord record)
Sets the specifiedsection
of this DNS message to the specifiedrecord
, making it a single-record section.DnsMessage
setRecursionDesired(boolean recursionDesired)
Sets theRD
(recursion desired} field of this DNS message.private void
setSection(int section, java.lang.Object value)
DnsMessage
setZ(int z)
Sets theZ
(reserved for future use) field of this DNS message.DnsMessage
touch()
Records the current access location of this object for debugging purposes.DnsMessage
touch(java.lang.Object hint)
Records the current access location of this object with an additional arbitrary information for debugging purposes.int
z()
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 specifiedid
andDnsOpCode.QUERY
opCode.
-
AbstractDnsMessage
protected AbstractDnsMessage(int id, DnsOpCode opCode)
Creates a new instance with the specifiedid
andopCode
.
-
-
Method Detail
-
id
public int id()
Description copied from interface:DnsMessage
Returns theID
of this DNS message.- Specified by:
id
in interfaceDnsMessage
-
setId
public DnsMessage setId(int id)
Description copied from interface:DnsMessage
Sets theID
of this DNS message.- Specified by:
setId
in interfaceDnsMessage
-
opCode
public DnsOpCode opCode()
Description copied from interface:DnsMessage
Returns theopCode
of this DNS message.- Specified by:
opCode
in interfaceDnsMessage
-
setOpCode
public DnsMessage setOpCode(DnsOpCode opCode)
Description copied from interface:DnsMessage
Sets theopCode
of this DNS message.- Specified by:
setOpCode
in interfaceDnsMessage
-
isRecursionDesired
public boolean isRecursionDesired()
Description copied from interface:DnsMessage
Returns theRD
(recursion desired} field of this DNS message.- Specified by:
isRecursionDesired
in interfaceDnsMessage
-
setRecursionDesired
public DnsMessage setRecursionDesired(boolean recursionDesired)
Description copied from interface:DnsMessage
Sets theRD
(recursion desired} field of this DNS message.- Specified by:
setRecursionDesired
in interfaceDnsMessage
-
z
public int z()
Description copied from interface:DnsMessage
Returns theZ
(reserved for future use) field of this DNS message.- Specified by:
z
in interfaceDnsMessage
-
setZ
public DnsMessage setZ(int z)
Description copied from interface:DnsMessage
Sets theZ
(reserved for future use) field of this DNS message.- Specified by:
setZ
in interfaceDnsMessage
-
count
public int count(DnsSection section)
Description copied from interface:DnsMessage
Returns the number of records in the specifiedsection
of this DNS message.- Specified by:
count
in interfaceDnsMessage
-
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 interfaceDnsMessage
-
recordAt
public <T extends DnsRecord> T recordAt(DnsSection section)
Description copied from interface:DnsMessage
Returns the first record in the specifiedsection
of this DNS message. When the specifiedsection
isDnsSection.QUESTION
, the type of the returned record is alwaysDnsQuestion
.- Specified by:
recordAt
in interfaceDnsMessage
- Returns:
null
if 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:DnsMessage
Returns the record at the specifiedindex
of the specifiedsection
of this DNS message. When the specifiedsection
isDnsSection.QUESTION
, the type of the returned record is alwaysDnsQuestion
.- Specified by:
recordAt
in interfaceDnsMessage
-
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 specifiedsection
of this DNS message to the specifiedrecord
, making it a single-record section. When the specifiedsection
isDnsSection.QUESTION
, the specifiedrecord
must be aDnsQuestion
.- Specified by:
setRecord
in 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:DnsMessage
Sets the specifiedrecord
at the specifiedindex
of the specifiedsection
of this DNS message. When the specifiedsection
isDnsSection.QUESTION
, the specifiedrecord
must be aDnsQuestion
.- Specified by:
setRecord
in interfaceDnsMessage
- Returns:
- the old record
-
addRecord
public DnsMessage addRecord(DnsSection section, DnsRecord record)
Description copied from interface:DnsMessage
Adds the specifiedrecord
at the end of the specifiedsection
of this DNS message. When the specifiedsection
isDnsSection.QUESTION
, the specifiedrecord
must be aDnsQuestion
.- Specified by:
addRecord
in interfaceDnsMessage
-
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 specifiedrecord
at the specifiedindex
of the specifiedsection
of this DNS message. When the specifiedsection
isDnsSection.QUESTION
, the specifiedrecord
must be aDnsQuestion
.- Specified by:
addRecord
in 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:DnsMessage
Removes the record at the specifiedindex
of the specifiedsection
from this DNS message. When the specifiedsection
isDnsSection.QUESTION
, the type of the returned record is alwaysDnsQuestion
.- Specified by:
removeRecord
in 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:DnsMessage
Removes all the records in the specifiedsection
of this DNS message.- Specified by:
clear
in interfaceDnsMessage
-
clear
public DnsMessage clear()
Description copied from interface:DnsMessage
Removes all the records in this DNS message.- Specified by:
clear
in interfaceDnsMessage
-
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 viaResourceLeakDetector
. This method is a shortcut totouch(null)
.- Specified by:
touch
in interfaceDnsMessage
- Specified by:
touch
in interfaceReferenceCounted
- Overrides:
touch
in classAbstractReferenceCounted
-
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 viaResourceLeakDetector
.- Specified by:
touch
in interfaceDnsMessage
- Specified by:
touch
in interfaceReferenceCounted
-
retain
public DnsMessage retain()
Description copied from interface:ReferenceCounted
Increases the reference count by1
.- Specified by:
retain
in interfaceDnsMessage
- Specified by:
retain
in interfaceReferenceCounted
- Overrides:
retain
in classAbstractReferenceCounted
-
retain
public DnsMessage retain(int increment)
Description copied from interface:ReferenceCounted
Increases the reference count by the specifiedincrement
.- Specified by:
retain
in interfaceDnsMessage
- Specified by:
retain
in interfaceReferenceCounted
- Overrides:
retain
in classAbstractReferenceCounted
-
deallocate
protected void deallocate()
Description copied from class:AbstractReferenceCounted
Called onceAbstractReferenceCounted.refCnt()
is equals 0.- Specified by:
deallocate
in classAbstractReferenceCounted
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in 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()
-
-