Package javax.jmdns.impl
Class DNSEntry
- java.lang.Object
-
- javax.jmdns.impl.DNSEntry
-
- Direct Known Subclasses:
DNSQuestion,DNSRecord
public abstract class DNSEntry extends java.lang.ObjectDNS entry with a name, type, and class. This is the base class for questions and records.
-
-
Field Summary
Fields Modifier and Type Field Description private DNSRecordClass_dnsClassprivate java.lang.String_keyprivate java.lang.String_name(package private) java.util.Map<ServiceInfo.Fields,java.lang.String>_qualifiedNameMapprivate DNSRecordType_recordTypeprivate java.lang.String_typeprivate boolean_unique
-
Constructor Summary
Constructors Constructor Description DNSEntry(java.lang.String name, DNSRecordType type, DNSRecordClass recordClass, boolean unique)Create an entry.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description intcompareTo(DNSEntry that)Does a lexicographic comparison of the byte array representation of this record and that record.booleanequals(java.lang.Object obj)java.lang.StringgetKey()Returns the key for this entry.java.lang.StringgetName()Returns the name of this entryjava.util.Map<ServiceInfo.Fields,java.lang.String>getQualifiedNameMap()DNSRecordClassgetRecordClass()DNSRecordTypegetRecordType()java.lang.StringgetSubtype()Returns the subtype of this entryjava.lang.StringgetType()inthashCode()Overriden, to return a value which is consistent with the value returned by equals(Object).booleanisDomainDiscoveryQuery()abstract booleanisExpired(long now)Check if the record is expired.booleanisReverseLookup()booleanisSameEntry(DNSEntry entry)Check if two entries have exactly the same name, type, and class.booleanisSameRecordClass(DNSEntry entry)Check that 2 entries are of the same class.booleanisSameType(DNSEntry entry)Check that 2 entries are of the same type.booleanisServicesDiscoveryMetaQuery()abstract booleanisStale(long now)Check if the record is stale, i.e.booleanisUnique()booleanisV4ReverseLookup()booleanisV6ReverseLookup()booleanmatchRecordClass(DNSRecordClass recordClass)Check if the requested record class match the current record classbooleanmatchRecordType(DNSRecordType recordType)Check if the requested record tyep match the current record typebooleansameSubtype(DNSEntry other)Check if two entries have the same subtype.protected byte[]toByteArray()Creates a byte array representation of this record.protected voidtoByteArray(java.io.DataOutputStream dout)java.lang.StringtoString()protected voidtoString(java.lang.StringBuilder sb)
-
-
-
Field Detail
-
_key
private final java.lang.String _key
-
_name
private final java.lang.String _name
-
_type
private final java.lang.String _type
-
_recordType
private final DNSRecordType _recordType
-
_dnsClass
private final DNSRecordClass _dnsClass
-
_unique
private final boolean _unique
-
_qualifiedNameMap
final java.util.Map<ServiceInfo.Fields,java.lang.String> _qualifiedNameMap
-
-
Constructor Detail
-
DNSEntry
DNSEntry(java.lang.String name, DNSRecordType type, DNSRecordClass recordClass, boolean unique)Create an entry.
-
-
Method Detail
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
isSameEntry
public boolean isSameEntry(DNSEntry entry)
Check if two entries have exactly the same name, type, and class.- Parameters:
entry-- Returns:
trueif the two entries have are for the same record,falseotherwise
-
sameSubtype
public boolean sameSubtype(DNSEntry other)
Check if two entries have the same subtype.- Parameters:
other-- Returns:
trueif the two entries have are for the same subtype,falseotherwise
-
matchRecordClass
public boolean matchRecordClass(DNSRecordClass recordClass)
Check if the requested record class match the current record class- Parameters:
recordClass-- Returns:
trueif the two entries have compatible class,falseotherwise
-
matchRecordType
public boolean matchRecordType(DNSRecordType recordType)
Check if the requested record tyep match the current record type- Parameters:
recordType-- Returns:
trueif the two entries have compatible type,falseotherwise
-
getSubtype
public java.lang.String getSubtype()
Returns the subtype of this entry- Returns:
- subtype of this entry
-
getName
public java.lang.String getName()
Returns the name of this entry- Returns:
- name of this entry
-
getType
public java.lang.String getType()
- Returns:
- the type
-
getKey
public java.lang.String getKey()
Returns the key for this entry. The key is the lower case name.- Returns:
- key for this entry
-
getRecordType
public DNSRecordType getRecordType()
- Returns:
- record type
-
getRecordClass
public DNSRecordClass getRecordClass()
- Returns:
- record class
-
isUnique
public boolean isUnique()
- Returns:
- true if unique
-
getQualifiedNameMap
public java.util.Map<ServiceInfo.Fields,java.lang.String> getQualifiedNameMap()
-
isServicesDiscoveryMetaQuery
public boolean isServicesDiscoveryMetaQuery()
-
isDomainDiscoveryQuery
public boolean isDomainDiscoveryQuery()
-
isReverseLookup
public boolean isReverseLookup()
-
isV4ReverseLookup
public boolean isV4ReverseLookup()
-
isV6ReverseLookup
public boolean isV6ReverseLookup()
-
isStale
public abstract boolean isStale(long now)
Check if the record is stale, i.e. it has outlived more than half of its TTL.- Parameters:
now- update date- Returns:
trueis the record is stale,falseotherwise.
-
isExpired
public abstract boolean isExpired(long now)
Check if the record is expired.- Parameters:
now- update date- Returns:
trueis the record is expired,falseotherwise.
-
isSameRecordClass
public boolean isSameRecordClass(DNSEntry entry)
Check that 2 entries are of the same class.- Parameters:
entry-- Returns:
trueis the two class are the same,falseotherwise.
-
isSameType
public boolean isSameType(DNSEntry entry)
Check that 2 entries are of the same type.- Parameters:
entry-- Returns:
trueis the two type are the same,falseotherwise.
-
toByteArray
protected void toByteArray(java.io.DataOutputStream dout) throws java.io.IOException- Parameters:
dout-- Throws:
java.io.IOException
-
toByteArray
protected byte[] toByteArray()
Creates a byte array representation of this record. This is needed for tie-break tests according to draft-cheshire-dnsext-multicastdns-04.txt chapter 9.2.- Returns:
- byte array representation
-
compareTo
public int compareTo(DNSEntry that)
Does a lexicographic comparison of the byte array representation of this record and that record. This is needed for tie-break tests according to draft-cheshire-dnsext-multicastdns-04.txt chapter 9.2.- Parameters:
that-- Returns:
- a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
-
hashCode
public int hashCode()
Overriden, to return a value which is consistent with the value returned by equals(Object).- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
toString
protected void toString(java.lang.StringBuilder sb)
- Parameters:
sb-
-
-