Package org.minidns.record
Class Record<D extends Data>
java.lang.Object
org.minidns.record.Record<D>
A generic DNS record.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
The symbolic class of a DNS record (usuallyRecord.CLASS.IN
for Internet).static enum
The resource record type. -
Field Summary
Modifier and TypeFieldDescriptionfinal Record.CLASS
The record class (usually CLASS.IN).final int
The value of the class field of a RR.final DnsName
The generic name of this record.final D
The payload object of this record.final long
The ttl of this record.final Record.TYPE
The type (and payload type) of this record.final boolean
MDNS defines the highest bit of the class as the unicast query bit. -
Constructor Summary
ConstructorDescriptionRecord
(String name, Record.TYPE type, int clazzValue, long ttl, D payloadData) Record
(String name, Record.TYPE type, Record.CLASS clazz, long ttl, D payloadData, boolean unicastQuery) Record
(DnsName name, Record.TYPE type, int clazzValue, long ttl, D payloadData) Record
(DnsName name, Record.TYPE type, Record.CLASS clazz, long ttl, D payloadData, boolean unicastQuery) -
Method Summary
Modifier and TypeMethodDescriptionReturn the record as record with the givenData
class.boolean
filter
(Class<E> dataClass, Collection<Record<? extends Data>> input) static <E extends Data>
voidfilter
(Collection<Record<E>> result, Class<E> dataClass, Collection<Record<? extends Data>> input) The payload data, usually a subclass of data (A, AAAA, CNAME, ...).Get the question asking for this resource record.long
getTtl()
Retrieve the record ttl.int
hashCode()
ifPossibleAs
(Class<E> dataClass) Return the record if possible as record with the givenData
class.boolean
Check if this record answers a given query.boolean
See if this query/response was a unicast query (highest class bit set).parse
(DataInputStream dis, byte[] data) Parse a given record based on the full message data and the current stream position.byte[]
void
toOutputStream
(OutputStream outputStream) toString()
Retrieve a textual representation of this resource record.
-
Field Details
-
name
The generic name of this record. -
type
The type (and payload type) of this record. -
clazz
The record class (usually CLASS.IN). -
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
The ttl of this record. -
payloadData
The payload object of this record. -
unicastQuery
MDNS defines the highest bit of the class as the unicast query bit.
-
-
Constructor Details
-
Record
public Record(DnsName name, Record.TYPE type, Record.CLASS clazz, long ttl, D payloadData, boolean unicastQuery) -
Record
public Record(String name, Record.TYPE type, Record.CLASS clazz, long ttl, D payloadData, boolean unicastQuery) -
Record
-
Record
-
-
Method Details
-
parse
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
- Throws:
IOException
-
toByteArray
-
toString
Retrieve a textual representation of this resource record. -
isAnswer
Check if this record answers a given query.- Parameters:
q
- The query.- Returns:
- True if this record is a valid answer.
-
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
The payload data, usually a subclass of data (A, AAAA, CNAME, ...).- Returns:
- The payload data.
-
getTtl
Retrieve the record ttl.- Returns:
- The record ttl.
-
getQuestion
Get the question asking for this resource record. This will returnnull
if the record is not retrievable, i.e.Record.TYPE.OPT
.- Returns:
- the question for this resource record or
null
.
-
getQuestionMessage
-
hashCode
-
equals
-
ifPossibleAs
Return the record if possible as record with the givenData
class. If the record does not hold payload of the given data class type, thennull
will be returned. -
as
Return the record as record with the givenData
class. If the record does not hold payload of the given data class type, then aIllegalArgumentException
will be thrown. -
filter
public static <E extends Data> void filter(Collection<Record<E>> result, Class<E> dataClass, Collection<Record<? extends Data>> input) -
filter
-