java.lang.Object
org.minidns.record.Record<D>
- Type Parameters:
D- type of data stored in this record
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe symbolic class of a DNS record (usuallyRecord.CLASS.INfor Internet).static enumThe resource record type.Field Summary
Modifier and TypeFieldDescriptionprivate byte[]Cached serialized bytes.final Record.CLASSThe record class (usually CLASS.IN).final intThe value of the class field of a RR.private IntegerCached hash code.final DnsNameThe generic name of this record.final DThe payload object of this record.final longThe ttl of this record.final Record.TYPEThe type (and payload type) of this record.final booleanMDNS defines the highest bit of the class as the unicast query bit.Constructor Summary
ModifierConstructorDescriptionRecord(String name, Record.TYPE type, int clazzValue, long ttl, D payloadData) Create a new record with a raw class value.Record(String name, Record.TYPE type, Record.CLASS clazz, long ttl, D payloadData, boolean unicastQuery) Create a new record.Record(DnsName name, Record.TYPE type, int clazzValue, long ttl, D payloadData) Create a new record with a raw class value.privateRecord(DnsName name, Record.TYPE type, Record.CLASS clazz, int clazzValue, long ttl, D payloadData, boolean unicastQuery) Builds a record from its fields.Record(DnsName name, Record.TYPE type, Record.CLASS clazz, long ttl, D payloadData, boolean unicastQuery) Create a new record.Method Summary
Modifier and TypeMethodDescriptionReturn the record as record with the givenDataclass.booleanfilter(Class<E> dataClass, Collection<Record<? extends Data>> input) Filter a collection of records by data class, returning a new list.static <E extends Data>
voidfilter(Collection<Record<E>> result, Class<E> dataClass, Collection<Record<? extends Data>> input) Filter a collection of records by data class, adding matching records to the result.The payload data, usually a subclass of data (A, AAAA, CNAME, ...).Get the question asking for this resource record.Get a message builder for the question that this record answers.longgetTtl()Retrieve the record ttl.inthashCode()ifPossibleAs(Class<E> dataClass) Return the record if possible as record with the givenDataclass.booleanCheck if this record answers a given query.booleanSee 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[]Serialize this record to a byte array.voidtoOutputStream(OutputStream outputStream) Write this record to the given output stream.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
public final int clazzValueThe value of the class field of a RR. According to RFC 2671 (OPT RR) this is not necessarily representable using clazz field and unicastQuery bitttl
public final long ttlThe ttl of this record.payloadData
unicastQuery
public final boolean unicastQueryMDNS defines the highest bit of the class as the unicast query bit.bytes
private transient byte[] bytesCached serialized bytes.hashCodeCache
Cached hash code.
Constructor Details
Record
public Record(DnsName name, Record.TYPE type, Record.CLASS clazz, long ttl, D payloadData, boolean unicastQuery) Create a new record.- Parameters:
name- the record nametype- the record typeclazz- the record classttl- the time to livepayloadData- the record payload dataunicastQuery- whether the unicast query bit is set
Record
public Record(String name, Record.TYPE type, Record.CLASS clazz, long ttl, D payloadData, boolean unicastQuery) Create a new record.- Parameters:
name- the record nametype- the record typeclazz- the record classttl- the time to livepayloadData- the record payload dataunicastQuery- whether the unicast query bit is set
Record
Create a new record with a raw class value.- Parameters:
name- the record nametype- the record typeclazzValue- the raw class valuettl- the time to livepayloadData- the record payload data
Record
Create a new record with a raw class value.- Parameters:
name- the record nametype- the record typeclazzValue- the raw class valuettl- the time to livepayloadData- the record payload data
Record
private Record(DnsName name, Record.TYPE type, Record.CLASS clazz, int clazzValue, long ttl, D payloadData, boolean unicastQuery) Builds a record from its fields.- Parameters:
name- the record nametype- the record typeclazz- the record classclazzValue- the class number from the wirettl- the time to live in secondspayloadData- the record's dataunicastQuery- true when this is a unicast query
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
Write this record to the given output stream.- Parameters:
outputStream- the output stream to write to- Throws:
IOException- if an I/O error occurs
toByteArray
public byte[] toByteArray()Serialize this record to a byte array.- Returns:
- the serialized record bytes
toString
isAnswer
Check if this record answers a given query.- Parameters:
q- The query; its type and class match when equal to that value or to ANY- Returns:
- True if this record is a valid answer.
isUnicastQuery
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
The payload data, usually a subclass of data (A, AAAA, CNAME, ...).- Returns:
- The payload data.
getTtl
public long getTtl()Retrieve the record ttl.- Returns:
- The record ttl.
getQuestion
Get the question asking for this resource record. This will returnnullif the record is not retrievable, i.e.Record.TYPE.OPT.- Returns:
- the question for this resource record or
null.
getQuestionMessage
Get a message builder for the question that this record answers.- Returns:
- the message builder, or null if the record type is not retrievable
hashCode
equals
ifPossibleAs
Return the record if possible as record with the givenDataclass. If the record does not hold payload of the given data class type, thennullwill be returned.as
Return the record as record with the givenDataclass. If the record does not hold payload of the given data class type, then aIllegalArgumentExceptionwill be thrown.filter
public static <E extends Data> void filter(Collection<Record<E>> result, Class<E> dataClass, Collection<Record<? extends Data>> input) Filter a collection of records by data class, adding matching records to the result.- Type Parameters:
E- the target data type- Parameters:
result- the collection to add filtered records todataClass- the class to filter byinput- the input collection of records
filter
public static <E extends Data> List<Record<E>> filter(Class<E> dataClass, Collection<Record<? extends Data>> input) Filter a collection of records by data class, returning a new list.- Type Parameters:
E- the target data type- Parameters:
dataClass- the class to filter byinput- the input collection of records- Returns:
- a list of records matching the data class