Package org.minidns.record
Class Record<D extends Data>
- java.lang.Object
-
- org.minidns.record.Record<D>
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRecord.CLASSThe symbolic class of a DNS record (usuallyRecord.CLASS.INfor Internet).static classRecord.TYPEThe resource record type.
-
Field Summary
Fields Modifier and Type Field Description Record.CLASSclazzThe record class (usually CLASS.IN).intclazzValueThe value of the class field of a RR.DnsNamenameThe generic name of this record.DpayloadDataThe payload object of this record.longttlThe ttl of this record.Record.TYPEtypeThe type (and payload type) of this record.booleanunicastQueryMDNS defines the highest bit of the class as the unicast query bit.
-
Constructor Summary
Constructors Constructor Description Record(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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <E extends Data>
Record<E>as(Class<E> dataClass)Return the record as record with the givenDataclass.booleanequals(Object other)static <E extends Data>
List<Record<E>>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)DgetPayload()The payload data, usually a subclass of data (A, AAAA, CNAME, ...).QuestiongetQuestion()Get the question asking for this resource record.DnsMessage.BuildergetQuestionMessage()longgetTtl()Retrieve the record ttl.inthashCode()<E extends Data>
Record<E>ifPossibleAs(Class<E> dataClass)Return the record if possible as record with the givenDataclass.booleanisAnswer(Question q)Check if this record answers a given query.booleanisUnicastQuery()See if this query/response was a unicast query (highest class bit set).static Record<Data>parse(DataInputStream dis, byte[] data)Parse a given record based on the full message data and the current stream position.byte[]toByteArray()voidtoOutputStream(OutputStream outputStream)StringtoString()Retrieve a textual representation of this resource record.
-
-
-
Field Detail
-
type
public final Record.TYPE type
The type (and payload type) of this record.
-
clazz
public final Record.CLASS clazz
The record class (usually CLASS.IN).
-
clazzValue
public final int 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
public final long ttl
The ttl of this record.
-
payloadData
public final D extends Data payloadData
The payload object of this record.
-
unicastQuery
public final boolean unicastQuery
MDNS defines the highest bit of the class as the unicast query bit.
-
-
Constructor Detail
-
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
public Record(String name, Record.TYPE type, int clazzValue, long ttl, D payloadData)
-
Record
public Record(DnsName name, Record.TYPE type, int clazzValue, long ttl, D payloadData)
-
-
Method Detail
-
parse
public static Record<Data> parse(DataInputStream dis, byte[] data) throws IOException
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
public void toOutputStream(OutputStream outputStream) throws IOException
- Throws:
IOException
-
toByteArray
public byte[] toByteArray()
-
isAnswer
public boolean isAnswer(Question q)
Check if this record answers a given query.- Parameters:
q- The query.- 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
public D 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
public Question 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
public DnsMessage.Builder getQuestionMessage()
-
ifPossibleAs
public <E extends Data> Record<E> ifPossibleAs(Class<E> dataClass)
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
public <E extends Data> Record<E> as(Class<E> dataClass)
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.- Type Parameters:
E- a subtype ofData.- Parameters:
dataClass- a class of theDatatype.- Returns:
- the record with a specialized payload type.
- See Also:
ifPossibleAs(Class)
-
filter
public static <E extends Data> void filter(Collection<Record<E>> result, Class<E> dataClass, Collection<Record<? extends Data>> input)
-
-