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
DNS record
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Address record.static class
static class
static class
static class
Pointer record.static class
Service record.static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate long
private int
private final int
private InetAddress
This source is mainly for debugging purposes, should be the address that sent this record.private int
private static org.slf4j.Logger
Fields inherited from class javax.jmdns.impl.DNSEntry
_qualifiedNameMap
-
Constructor Summary
ConstructorsConstructorDescriptionDNSRecord
(String name, DNSRecordType type, DNSRecordClass recordClass, boolean unique, int ttl) Create a DNSRecord with a name, type, class, and ttl. -
Method Summary
Modifier and TypeMethodDescription(package private) abstract DNSOutgoing
addAnswer
(JmDNSImpl dns, DNSIncoming in, InetAddress addr, int port, DNSOutgoing out) Adds this as an answer to the provided outgoing datagram.boolean
long
(package private) long
getExpirationTime
(int percent) Get the expiration time of this record.(package private) int
getRemainingTTL
(long now) Get the remaining TTL for this record.abstract ServiceEvent
getServiceEvent
(JmDNSImpl dns) Creates and return a service event for this record.Return a service information associated with that record if appropriate.abstract ServiceInfo
getServiceInfo
(boolean persistent) Return a service information associated with that record if appropriate.int
getTTL()
(package private) abstract boolean
handleQuery
(JmDNSImpl dns, long expirationTime) Handles a query represented by this record.(package private) abstract boolean
handleResponse
(JmDNSImpl dns) Handles a response represented by this record.void
boolean
isExpired
(long now) Check if the record is expired.abstract boolean
Determine if a record can have multiple values in the cache.boolean
isStale
(long now) Check if the record is stale, i.e.boolean
isStaleAndShouldBeRefreshed
(long now) Check if the record is stale and whether the record should be refreshed over the network.(package private) void
Reset the TTL of a record.(package private) boolean
True if this record has the same type as some other record.(package private) abstract boolean
True if this record has the same value as some other record.void
setRecordSource
(InetAddress source) void
setTTL
(int ttl) (package private) void
setWillExpireSoon
(long now) When a record flushed we don't remove it immediately, but mark it for rapid decay.(package private) boolean
suppressedBy
(DNSIncoming msg) True if this record is suppressed by the answers in a message.(package private) boolean
suppressedBy
(DNSRecord other) True if this record would be suppressed by an answer.protected void
(package private) abstract void
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 Details
-
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
This source is mainly for debugging purposes, should be the address that sent this record.
-
-
Constructor Details
-
DNSRecord
DNSRecord(String name, DNSRecordType type, DNSRecordClass recordClass, boolean unique, int ttl) Create a DNSRecord with a name, type, class, and ttl.
-
-
Method Details
-
equals
-
sameValue
True if this record has the same value as some other record. -
sameType
True if this record has the same type as some other record. -
handleQuery
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
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, InetAddress addr, int port, DNSOutgoing out) throws IOException Adds this as an answer to the provided outgoing datagram.- Throws:
IOException
-
suppressedBy
True if this record is suppressed by the answers in a message. -
suppressedBy
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:DNSEntry
Check if the record is expired. -
isStale
public boolean isStale(long now) Description copied from class:DNSEntry
Check 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:
true
is the record is stale and should be refreshed,false
otherwise.
-
incrementRefreshPercentage
public void incrementRefreshPercentage() -
resetTTL
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
Write this record into an outgoing message. -
isSingleValued
public abstract boolean isSingleValued()Determine if a record can have multiple values in the cache.- Returns:
false
if this record can have multiple values in the cache,true
otherwise.
-
getServiceInfo
Return a service information associated with that record if appropriate.- Returns:
- service information
-
getServiceInfo
Return a service information associated with that record if appropriate.- Parameters:
persistent
- iftrue
ServiceListener.resolveService will be called whenever new new information is received.- Returns:
- service information
-
getServiceEvent
Creates and return a service event for this record.- Parameters:
dns
- DNS serviced by this event- Returns:
- service event
-
setRecordSource
-
getRecordSource
-
toString
-
setTTL
public void setTTL(int ttl) -
getTTL
public int getTTL() -
getCreated
public long getCreated()
-