Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.protocol.zeroconf.jmdns
Class DNSRecord

java.lang.Object
  extended by net.java.sip.communicator.impl.protocol.zeroconf.jmdns.DNSEntry
      extended by net.java.sip.communicator.impl.protocol.zeroconf.jmdns.DNSRecord
Direct Known Subclasses:
DNSRecord.Address, DNSRecord.Pointer, DNSRecord.Service, DNSRecord.Text

public abstract class DNSRecord
extends DNSEntry

DNS record

Version:
%I%, %G%
Author:
Arthur van Hoff, Rick Blair, Werner Randelshofer, Pierre Frisch

Nested Class Summary
(package private) static class DNSRecord.Address
          Address record.
(package private) static class DNSRecord.Pointer
          Pointer record.
(package private) static class DNSRecord.Service
          Service record.
(package private) static class DNSRecord.Text
           
 
Field Summary
(package private)  int ttl
           
 
Fields inherited from class net.java.sip.communicator.impl.protocol.zeroconf.jmdns.DNSEntry
clazz, key, name, type, unique
 
Constructor Summary
DNSRecord(String name, int type, int clazz, int ttl)
          Create a DNSRecord with a name, type, clazz, and ttl.
 
Method Summary
(package private) abstract  DNSOutgoing addAnswer(JmDNS dns, DNSIncoming in, InetAddress addr, int port, DNSOutgoing out)
          Adds this as an answer to the provided outgoing datagram.
 boolean equals(Object other)
          True if this record is the same as some other record.
(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.
(package private) abstract  boolean handleQuery(JmDNS dns, long expirationTime)
          Handles a query represented by this record.
(package private) abstract  boolean handleResponse(JmDNS dns)
          Handles a responserepresented by this record.
(package private)  boolean isExpired(long now)
          Check if the record is expired.
(package private)  boolean isStale(long now)
          Check if the record is stale, ie it has outlived more than half of its TTL.
(package private)  void resetTTL(DNSRecord other)
          Reset the TTL of a record.
(package private)  boolean sameAs(DNSRecord other)
          True if this record is the same as some other record.
(package private)  boolean sameType(DNSRecord other)
          True if this record has the same type as some other record.
(package private) abstract  boolean sameValue(DNSRecord other)
          True if this record has the same value as some other record.
(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 supressed by an answer.
 String toString(String other)
           
(package private) abstract  void write(DNSOutgoing out)
          Write this record into an outgoing message.
 
Methods inherited from class net.java.sip.communicator.impl.protocol.zeroconf.jmdns.DNSEntry
getClazz, getClazz, getName, getType, getType, hashCode, isUnique, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ttl

int ttl
Constructor Detail

DNSRecord

DNSRecord(String name,
          int type,
          int clazz,
          int ttl)
Create a DNSRecord with a name, type, clazz, and ttl.

Method Detail

equals

public boolean equals(Object other)
True if this record is the same as some other record.

Overrides:
equals in class DNSEntry
Parameters:
other - obj to be compared to.

sameAs

boolean sameAs(DNSRecord other)
True if this record is the same as some other record.


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(JmDNS 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(JmDNS dns)
Handles a responserepresented 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(JmDNS dns,
                               DNSIncoming in,
                               InetAddress addr,
                               int port,
                               DNSOutgoing out)
                        throws IOException
Adds this as an answer to the provided outgoing datagram.

Throws:
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 supressed 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

boolean isExpired(long now)
Check if the record is expired.


isStale

boolean isStale(long now)
Check if the record is stale, ie it has outlived more than half of its TTL.


resetTTL

void resetTTL(DNSRecord other)
Reset the TTL of a record. This avoids having to update the entire record in the cache.


write

abstract void write(DNSOutgoing out)
             throws IOException
Write this record into an outgoing message.

Throws:
IOException

toString

public String toString(String other)

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.