Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.strangeberry.rendezvous
Class ServiceInfo  view ServiceInfo download ServiceInfo.java

java.lang.Object
  extended bycom.strangeberry.rendezvous.DNSConstants
      extended bycom.strangeberry.rendezvous.Rendezvous.Listener
          extended bycom.strangeberry.rendezvous.ServiceInfo

public class ServiceInfo
extends Rendezvous.Listener

Rendezvous service information.

Version:
1.21, 11/29/2002

Field Summary
(package private)  java.net.InetAddress addr
           
(package private) static int CLASS_ANY
           
(package private) static int CLASS_CH
           
(package private) static int CLASS_CS
           
(package private) static int CLASS_HS
           
(package private) static int CLASS_IN
           
(package private) static int CLASS_MASK
           
(package private) static int CLASS_NONE
           
(package private) static int CLASS_UNIQUE
           
(package private) static int DNS_PORT
           
(package private) static int FLAGS_AA
           
(package private) static int FLAGS_AD
           
(package private) static int FLAGS_CD
           
(package private) static int FLAGS_QR_MASK
           
(package private) static int FLAGS_QR_QUERY
           
(package private) static int FLAGS_QR_RESPONSE
           
(package private) static int FLAGS_RA
           
(package private) static int FLAGS_RD
           
(package private) static int FLAGS_TC
           
(package private) static int FLAGS_Z
           
(package private) static int MAX_MSG_ABSOLUTE
           
(package private) static int MAX_MSG_TYPICAL
           
(package private) static java.lang.String MDNS_GROUP
           
(package private) static int MDNS_PORT
           
(package private)  java.lang.String name
           
static byte[] NO_VALUE
           
(package private)  int port
           
(package private)  int priority
           
(package private)  java.util.Hashtable props
           
(package private)  java.lang.String server
           
(package private)  byte[] text
           
(package private)  java.lang.String type
           
(package private) static int TYPE_A
           
(package private) static int TYPE_ANY
           
(package private) static int TYPE_CNAME
           
(package private) static int TYPE_HINFO
           
(package private) static int TYPE_MB
           
(package private) static int TYPE_MD
           
(package private) static int TYPE_MF
           
(package private) static int TYPE_MG
           
(package private) static int TYPE_MINFO
           
(package private) static int TYPE_MR
           
(package private) static int TYPE_MX
           
(package private) static int TYPE_NS
           
(package private) static int TYPE_NULL
           
(package private) static int TYPE_PTR
           
(package private) static int TYPE_SOA
           
(package private) static int TYPE_SRV
           
(package private) static int TYPE_TXT
           
(package private) static int TYPE_WKS
           
(package private)  int weight
           
 
Constructor Summary
(package private) ServiceInfo(java.lang.String type, java.lang.String name)
          Construct a serive record during service discovery.
  ServiceInfo(java.lang.String type, java.lang.String name, java.net.InetAddress addr, int port, int weight, int priority, byte[] text)
          Construct a service description for registrating with Rendezvous.
  ServiceInfo(java.lang.String type, java.lang.String name, java.net.InetAddress addr, int port, int weight, int priority, java.util.Hashtable props)
          Construct a service description for registrating with Rendezvous.
  ServiceInfo(java.lang.String type, java.lang.String name, java.net.InetAddress addr, int port, int weight, int priority, java.lang.String text)
          Construct a service description for registrating with Rendezvous.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Determine whether this Object is semantically equal to another Object.
 java.lang.String getAddress()
          Get the host address of the service (ie X.X.X.X).
(package private)  int getIPAddress()
          Get the ip address of the service.
 java.lang.String getName()
          Service name, such as foobar.
 int getPort()
          Get the port for the service.
 int getPriority()
          Get the priority of the service.
(package private)  java.util.Hashtable getProperties()
           
 byte[] getPropertyBytes(java.lang.String name)
          Get a property of the service.
 java.util.Enumeration getPropertyNames()
          Enumeration of the property names.
 java.lang.String getPropertyString(java.lang.String name)
          Get a property of the service.
 byte[] getTextBytes()
          Get the text for the serivce as raw bytes.
 java.lang.String getTextString()
          Get the text for the service.
 java.lang.String getType()
          Fully qualified service type name, such as _http._tcp.local..
 int getWeight()
          Get the weight of the service.
 int hashCode()
          Get a value that represents this Object, as uniquely as possible within the confines of an int.
(package private)  java.lang.String readUTF(byte[] data, int off, int len)
          Read data bytes as a UTF stream.
(package private)  boolean request(Rendezvous rendezvous, long timeout)
          Update the server information from the cache, send out repeated DNS queries for updated information.
 java.lang.String toString()
          Convert this Object to a human-readable String.
(package private)  void updateRecord(Rendezvous rendezvous, long now, DNSRecord rec)
          Rendezvous callback to update a DNS record.
(package private)  void writeUTF(java.io.OutputStream out, java.lang.String str)
          Write a UTF string with a length to a stream.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NO_VALUE

public static final byte[] NO_VALUE

type

java.lang.String type

name

java.lang.String name

server

java.lang.String server

port

int port

weight

int weight

priority

int priority

text

byte[] text

props

java.util.Hashtable props

addr

java.net.InetAddress addr

MDNS_GROUP

static final java.lang.String MDNS_GROUP
See Also:
Constant Field Values

MDNS_PORT

static final int MDNS_PORT
See Also:
Constant Field Values

DNS_PORT

static final int DNS_PORT
See Also:
Constant Field Values

MAX_MSG_TYPICAL

static final int MAX_MSG_TYPICAL
See Also:
Constant Field Values

MAX_MSG_ABSOLUTE

static final int MAX_MSG_ABSOLUTE
See Also:
Constant Field Values

FLAGS_QR_MASK

static final int FLAGS_QR_MASK
See Also:
Constant Field Values

FLAGS_QR_QUERY

static final int FLAGS_QR_QUERY
See Also:
Constant Field Values

FLAGS_QR_RESPONSE

static final int FLAGS_QR_RESPONSE
See Also:
Constant Field Values

FLAGS_AA

static final int FLAGS_AA
See Also:
Constant Field Values

FLAGS_TC

static final int FLAGS_TC
See Also:
Constant Field Values

FLAGS_RD

static final int FLAGS_RD
See Also:
Constant Field Values

FLAGS_RA

static final int FLAGS_RA
See Also:
Constant Field Values

FLAGS_Z

static final int FLAGS_Z
See Also:
Constant Field Values

FLAGS_AD

static final int FLAGS_AD
See Also:
Constant Field Values

FLAGS_CD

static final int FLAGS_CD
See Also:
Constant Field Values

CLASS_IN

static final int CLASS_IN
See Also:
Constant Field Values

CLASS_CS

static final int CLASS_CS
See Also:
Constant Field Values

CLASS_CH

static final int CLASS_CH
See Also:
Constant Field Values

CLASS_HS

static final int CLASS_HS
See Also:
Constant Field Values

CLASS_NONE

static final int CLASS_NONE
See Also:
Constant Field Values

CLASS_ANY

static final int CLASS_ANY
See Also:
Constant Field Values

CLASS_MASK

static final int CLASS_MASK
See Also:
Constant Field Values

CLASS_UNIQUE

static final int CLASS_UNIQUE
See Also:
Constant Field Values

TYPE_A

static final int TYPE_A
See Also:
Constant Field Values

TYPE_NS

static final int TYPE_NS
See Also:
Constant Field Values

TYPE_MD

static final int TYPE_MD
See Also:
Constant Field Values

TYPE_MF

static final int TYPE_MF
See Also:
Constant Field Values

TYPE_CNAME

static final int TYPE_CNAME
See Also:
Constant Field Values

TYPE_SOA

static final int TYPE_SOA
See Also:
Constant Field Values

TYPE_MB

static final int TYPE_MB
See Also:
Constant Field Values

TYPE_MG

static final int TYPE_MG
See Also:
Constant Field Values

TYPE_MR

static final int TYPE_MR
See Also:
Constant Field Values

TYPE_NULL

static final int TYPE_NULL
See Also:
Constant Field Values

TYPE_WKS

static final int TYPE_WKS
See Also:
Constant Field Values

TYPE_PTR

static final int TYPE_PTR
See Also:
Constant Field Values

TYPE_HINFO

static final int TYPE_HINFO
See Also:
Constant Field Values

TYPE_MINFO

static final int TYPE_MINFO
See Also:
Constant Field Values

TYPE_MX

static final int TYPE_MX
See Also:
Constant Field Values

TYPE_TXT

static final int TYPE_TXT
See Also:
Constant Field Values

TYPE_SRV

static final int TYPE_SRV
See Also:
Constant Field Values

TYPE_ANY

static final int TYPE_ANY
See Also:
Constant Field Values
Constructor Detail

ServiceInfo

public ServiceInfo(java.lang.String type,
                   java.lang.String name,
                   java.net.InetAddress addr,
                   int port,
                   int weight,
                   int priority,
                   java.lang.String text)
Construct a service description for registrating with Rendezvous.


ServiceInfo

public ServiceInfo(java.lang.String type,
                   java.lang.String name,
                   java.net.InetAddress addr,
                   int port,
                   int weight,
                   int priority,
                   java.util.Hashtable props)
Construct a service description for registrating with Rendezvous. The properties hashtable must map property names to either Strings or byte arrays describing the property values.


ServiceInfo

public ServiceInfo(java.lang.String type,
                   java.lang.String name,
                   java.net.InetAddress addr,
                   int port,
                   int weight,
                   int priority,
                   byte[] text)
Construct a service description for registrating with Rendezvous.


ServiceInfo

ServiceInfo(java.lang.String type,
            java.lang.String name)
Construct a serive record during service discovery.

Method Detail

getType

public java.lang.String getType()
Fully qualified service type name, such as _http._tcp.local..


getName

public java.lang.String getName()
Service name, such as foobar.


getAddress

public java.lang.String getAddress()
Get the host address of the service (ie X.X.X.X).


getPort

public int getPort()
Get the port for the service.


getPriority

public int getPriority()
Get the priority of the service.


getWeight

public int getWeight()
Get the weight of the service.


getTextBytes

public byte[] getTextBytes()
Get the text for the serivce as raw bytes.


getTextString

public java.lang.String getTextString()
Get the text for the service. This will interpret the text bytes as a UTF8 encoded string. Will return null if the bytes are not a valid UTF8 encoded string.


getPropertyBytes

public byte[] getPropertyBytes(java.lang.String name)
Get a property of the service. This involves decoding the text bytes into a property list. Returns null if the property is not found or the text data could not be decoded correctly.


getPropertyString

public java.lang.String getPropertyString(java.lang.String name)
Get a property of the service. This involves decoding the text bytes into a property list. Returns null if the property is not found, the text data could not be decoded correctly, or the resulting bytes are not a valid UTF8 string.


getPropertyNames

public java.util.Enumeration getPropertyNames()
Enumeration of the property names.


writeUTF

void writeUTF(java.io.OutputStream out,
              java.lang.String str)
        throws java.io.IOException
Write a UTF string with a length to a stream.


readUTF

java.lang.String readUTF(byte[] data,
                         int off,
                         int len)
Read data bytes as a UTF stream.


getProperties

java.util.Hashtable getProperties()

getIPAddress

int getIPAddress()
Get the ip address of the service.


updateRecord

void updateRecord(Rendezvous rendezvous,
                  long now,
                  DNSRecord rec)
Rendezvous callback to update a DNS record.

Specified by:
updateRecord in class Rendezvous.Listener

request

boolean request(Rendezvous rendezvous,
                long timeout)
Update the server information from the cache, send out repeated DNS queries for updated information.


hashCode

public int hashCode()
Description copied from class: java.lang.Object
Get a value that represents this Object, as uniquely as possible within the confines of an int.

There are some requirements on this method which subclasses must follow:

  • Semantic equality implies identical hashcodes. In other words, if a.equals(b) is true, then a.hashCode() == b.hashCode() must be as well. However, the reverse is not necessarily true, and two objects may have the same hashcode without being equal.
  • It must be consistent. Whichever value o.hashCode() returns on the first invocation must be the value returned on all later invocations as long as the object exists. Notice, however, that the result of hashCode may change between separate executions of a Virtual Machine, because it is not invoked on the same object.

Notice that since hashCode is used in java.util.Hashtable and other hashing classes, a poor implementation will degrade the performance of hashing (so don't blindly implement it as returning a constant!). Also, if calculating the hash is time-consuming, a class may consider caching the results.

The default implementation returns System.identityHashCode(this)


equals

public boolean equals(java.lang.Object obj)
Description copied from class: java.lang.Object
Determine whether this Object is semantically equal to another Object.

There are some fairly strict requirements on this method which subclasses must follow:

  • It must be transitive. If a.equals(b) and b.equals(c), then a.equals(c) must be true as well.
  • It must be symmetric. a.equals(b) and b.equals(a) must have the same value.
  • It must be reflexive. a.equals(a) must always be true.
  • It must be consistent. Whichever value a.equals(b) returns on the first invocation must be the value returned on all later invocations.
  • a.equals(null) must be false.
  • It must be consistent with hashCode(). That is, a.equals(b) must imply a.hashCode() == b.hashCode(). The reverse is not true; two objects that are not equal may have the same hashcode, but that has the potential to harm hashing performance.

This is typically overridden to throw a java.lang.ClassCastException if the argument is not comparable to the class performing the comparison, but that is not a requirement. It is legal for a.equals(b) to be true even though a.getClass() != b.getClass(). Also, it is typical to never cause a java.lang.NullPointerException.

In general, the Collections API (java.util) use the equals method rather than the == operator to compare objects. However, java.util.IdentityHashMap is an exception to this rule, for its own good reasons.

The default implementation returns this == o.


toString

public java.lang.String toString()
Description copied from class: java.lang.Object
Convert this Object to a human-readable String. There are no limits placed on how long this String should be or what it should contain. We suggest you make it as intuitive as possible to be able to place it into System.out.println() 55 and such.

It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.

This method will be called when performing string concatenation with this object. If the result is null, string concatenation will instead use "null".

The default implementation returns getClass().getName() + "@" + Integer.toHexString(hashCode()).