Package javax.jmdns.impl
Class DNSRecord
- java.lang.Object
-
- javax.jmdns.impl.DNSEntry
-
- javax.jmdns.impl.DNSRecord
-
- Direct Known Subclasses:
DNSRecord.Address,DNSRecord.HostInformation,DNSRecord.Pointer,DNSRecord.Service,DNSRecord.Text
public abstract class DNSRecord extends DNSEntry
DNS record
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDNSRecord.AddressAddress record.static classDNSRecord.HostInformationstatic classDNSRecord.IPv4Addressstatic classDNSRecord.IPv6Addressstatic classDNSRecord.PointerPointer record.static classDNSRecord.ServiceService record.static classDNSRecord.Text
-
Field Summary
Fields Modifier and Type Field Description private long_createdprivate int_isStaleAndShouldBeRefreshedPercentageprivate int_randomStaleRefreshOffsetprivate java.net.InetAddress_sourceThis source is mainly for debugging purposes, should be the address that sent this record.private int_ttlprivate static org.slf4j.Loggerlogger-
Fields inherited from class javax.jmdns.impl.DNSEntry
_qualifiedNameMap
-
-
Constructor Summary
Constructors Constructor Description DNSRecord(java.lang.String name, DNSRecordType type, DNSRecordClass recordClass, boolean unique, int ttl)Create a DNSRecord with a name, type, class, and ttl.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description (package private) abstract DNSOutgoingaddAnswer(JmDNSImpl dns, DNSIncoming in, java.net.InetAddress addr, int port, DNSOutgoing out)Adds this as an answer to the provided outgoing datagram.booleanequals(java.lang.Object other)longgetCreated()(package private) longgetExpirationTime(int percent)Get the expiration time of this record.java.net.InetAddressgetRecordSource()(package private) intgetRemainingTTL(long now)Get the remaining TTL for this record.abstract ServiceEventgetServiceEvent(JmDNSImpl dns)Creates and return a service event for this record.ServiceInfogetServiceInfo()Return a service information associated with that record if appropriate.abstract ServiceInfogetServiceInfo(boolean persistent)Return a service information associated with that record if appropriate.intgetTTL()(package private) abstract booleanhandleQuery(JmDNSImpl dns, long expirationTime)Handles a query represented by this record.(package private) abstract booleanhandleResponse(JmDNSImpl dns)Handles a response represented by this record.voidincrementRefreshPercentage()booleanisExpired(long now)Check if the record is expired.abstract booleanisSingleValued()Determine if a record can have multiple values in the cache.booleanisStale(long now)Check if the record is stale, i.e.booleanisStaleAndShouldBeRefreshed(long now)Check if the record is stale and whether the record should be refreshed over the network.(package private) voidresetTTL(DNSRecord other)Reset the TTL of a record.(package private) booleansameType(DNSRecord other)True if this record has the same type as some other record.(package private) abstract booleansameValue(DNSRecord other)True if this record has the same value as some other record.voidsetRecordSource(java.net.InetAddress source)voidsetTTL(int ttl)(package private) voidsetWillExpireSoon(long now)When a record flushed we don't remove it immediately, but mark it for rapid decay.(package private) booleansuppressedBy(DNSIncoming msg)True if this record is suppressed by the answers in a message.(package private) booleansuppressedBy(DNSRecord other)True if this record would be suppressed by an answer.protected voidtoString(java.lang.StringBuilder sb)(package private) abstract voidwrite(DNSOutgoing.MessageOutputStream out)Write this record into an outgoing message.-
Methods inherited from class javax.jmdns.impl.DNSEntry
compareTo, getKey, getName, getQualifiedNameMap, getRecordClass, getRecordType, getSubtype, getType, hashCode, isDomainDiscoveryQuery, isReverseLookup, isSameEntry, isSameRecordClass, isSameType, isServicesDiscoveryMetaQuery, isUnique, isV4ReverseLookup, isV6ReverseLookup, matchRecordClass, matchRecordType, sameSubtype, toByteArray, toByteArray, toString
-
-
-
-
Field Detail
-
logger
private static org.slf4j.Logger logger
-
_ttl
private int _ttl
-
_created
private long _created
-
_isStaleAndShouldBeRefreshedPercentage
private int _isStaleAndShouldBeRefreshedPercentage
-
_randomStaleRefreshOffset
private final int _randomStaleRefreshOffset
-
_source
private java.net.InetAddress _source
This source is mainly for debugging purposes, should be the address that sent this record.
-
-
Constructor Detail
-
DNSRecord
DNSRecord(java.lang.String name, DNSRecordType type, DNSRecordClass recordClass, boolean unique, int ttl)Create a DNSRecord with a name, type, class, and ttl.
-
-
Method Detail
-
sameValue
abstract boolean sameValue(DNSRecord other)
True if this record has the same value as some other record.
-
sameType
boolean sameType(DNSRecord other)
True if this record has the same type as some other record.
-
handleQuery
abstract boolean handleQuery(JmDNSImpl dns, long expirationTime)
Handles a query represented by this record.- Returns:
- Returns true if a conflict with one of the services registered with JmDNS or with the hostname occured.
-
handleResponse
abstract boolean handleResponse(JmDNSImpl dns)
Handles a response represented by this record.- Returns:
- Returns true if a conflict with one of the services registered with JmDNS or with the hostname occured.
-
addAnswer
abstract DNSOutgoing addAnswer(JmDNSImpl dns, DNSIncoming in, java.net.InetAddress addr, int port, DNSOutgoing out) throws java.io.IOException
Adds this as an answer to the provided outgoing datagram.- Throws:
java.io.IOException
-
suppressedBy
boolean suppressedBy(DNSIncoming msg)
True if this record is suppressed by the answers in a message.
-
suppressedBy
boolean suppressedBy(DNSRecord other)
True if this record would be suppressed by an answer. This is the case if this record would not have a significantly longer TTL.
-
getExpirationTime
long getExpirationTime(int percent)
Get the expiration time of this record.
-
getRemainingTTL
int getRemainingTTL(long now)
Get the remaining TTL for this record.
-
isExpired
public boolean isExpired(long now)
Description copied from class:DNSEntryCheck if the record is expired.
-
isStale
public boolean isStale(long now)
Description copied from class:DNSEntryCheck if the record is stale, i.e. it has outlived more than half of its TTL.
-
isStaleAndShouldBeRefreshed
public boolean isStaleAndShouldBeRefreshed(long now)
Check if the record is stale and whether the record should be refreshed over the network.- Parameters:
now- update date- Returns:
trueis the record is stale and should be refreshed,falseotherwise.
-
incrementRefreshPercentage
public void incrementRefreshPercentage()
-
resetTTL
void resetTTL(DNSRecord other)
Reset the TTL of a record. This avoids having to update the entire record in the cache.
-
setWillExpireSoon
void setWillExpireSoon(long now)
When a record flushed we don't remove it immediately, but mark it for rapid decay.
-
write
abstract void write(DNSOutgoing.MessageOutputStream out)
Write this record into an outgoing message.
-
isSingleValued
public abstract boolean isSingleValued()
Determine if a record can have multiple values in the cache.- Returns:
falseif this record can have multiple values in the cache,trueotherwise.
-
getServiceInfo
public ServiceInfo getServiceInfo()
Return a service information associated with that record if appropriate.- Returns:
- service information
-
getServiceInfo
public abstract ServiceInfo getServiceInfo(boolean persistent)
Return a service information associated with that record if appropriate.- Parameters:
persistent- iftrueServiceListener.resolveService will be called whenever new new information is received.- Returns:
- service information
-
getServiceEvent
public abstract ServiceEvent getServiceEvent(JmDNSImpl dns)
Creates and return a service event for this record.- Parameters:
dns- DNS serviced by this event- Returns:
- service event
-
setRecordSource
public void setRecordSource(java.net.InetAddress source)
-
getRecordSource
public java.net.InetAddress getRecordSource()
-
setTTL
public void setTTL(int ttl)
-
getTTL
public int getTTL()
-
getCreated
public long getCreated()
-
-