Project JXTA

net.jxta.id
Class ID

java.lang.Object
  |
  +--net.jxta.id.ID
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable
Direct Known Subclasses:
CodatID, ModuleClassID, ModuleSpecID, PeerGroupID, PeerID, PipeID

public abstract class ID
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

IDs are used to uniquely identify peers, peer groups, pipes and other types of objects manipulated by the JXTA APIs.

Since:
JXTA 1.0
Version:
$Revision: 1.25 $
See Also:
IDFactory, CodatID, PeerID, PeerGroupID, PipeID, ModuleClassID, ModuleSpecID, Serialized Form

Field Summary
static ID nullID
          The null ID.
static java.lang.String URIEncodingName
          This defines the URI scheme that we will be using to present JXTA IDs.
static java.lang.String URNNamespace
          This defines the URN Namespace that we will be using to present JXTA IDs.
 
Constructor Summary
protected ID()
          Constructor for IDs.
 
Method Summary
 java.lang.Object clone()
          Returns a clone of this object.
abstract  java.lang.String getIDFormat()
          Returns a string identifier which indicates which ID format is used by this ID instance.
abstract  java.lang.Object getUniqueValue()
          Returns an object containing the unique value of the ID.
abstract  java.net.URL getURL()
          Returns a URI (URL in Java nomenclature) representation of the ID.
 java.lang.String toString()
          Returns a string representation of the ID.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

URIEncodingName

public static final java.lang.String URIEncodingName
This defines the URI scheme that we will be using to present JXTA IDs. JXTA IDs are encoded for presentation into URIs (see IETF RFC 2396 Uniform Resource Identifiers (URI) : Generic Syntax ) as URNs (see IETF RFC 2141 Uniform Resource Names (URN) Syntax ).

URNNamespace

public static final java.lang.String URNNamespace
This defines the URN Namespace that we will be using to present JXTA IDs. The namespace allows URN resolvers to determine which sub-resolver to use to resolve URN references. All JXTA IDs are presented in this namespace.

nullID

public static final ID nullID
The null ID. The NullID is often used as a placeholder in fields which are uninitialized. This is a singleton within the scope of a VM.
Constructor Detail

ID

protected ID()
Constructor for IDs.
Method Detail

clone

public java.lang.Object clone()
Returns a clone of this object. All sub-classes of ID should be immutable but we have no way to enforce it. So, let subclasses override clone with a trivial method. Here, do the standard thing (which is correct for an abstract class), so that subclasses may call super.clone() in case their clone method is NOT trivial.

NOTE: We DO NOT throw CloneNotSupportedException; all IDs MUST be clonable by API definition.

Overrides:
clone in class java.lang.Object
Returns:
the cloned object
Since:
JXTA 1.0

toString

public java.lang.String toString()
Returns a string representation of the ID. This representation should be used primarily for debugging purposes. For most other situations IDs should be externalized as Java URL Objects via getURL. The default implementation is the toString representation of the URL representation.
Overrides:
toString in class java.lang.Object
Returns:
String containing the URI
Since:
JXTA 1.0

getIDFormat

public abstract java.lang.String getIDFormat()
Returns a string identifier which indicates which ID format is used by this ID instance.
Returns:
a string identifier which indicates which ID format is used by this ID instance.
Since:
JXTA 1.0

getUniqueValue

public abstract java.lang.Object getUniqueValue()
Returns an object containing the unique value of the ID. This object must provide implementations of toString() and hashCode() that are canonical and consistent from run-to-run given the same input values. Beyond this nothing should be assumed about the nature of this object. For some implementations the object returned may be this.
Returns:
Object which can provide canonical representations of the ID.
Since:
JXTA 1.0

getURL

public abstract java.net.URL getURL()
Returns a URI (URL in Java nomenclature) representation of the ID. URLs are the prefered way of externalizing and presenting JXTA IDs. The JXTA ID Factory can be used to construct ID Objects from URLs containing JXTA IDs.
Returns:
URL Object containing the URI
Since:
JXTA 1.0
See Also:
URL, IDFactory.fromURL( java.net.URL )

Project JXTA