Project JXTA

net.jxta.id
Class ID

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

public abstract class ID
extends java.lang.Object
implements java.lang.Cloneable


Field Summary
protected  byte[] bytes
           
protected static byte flagCodatID
           
protected static byte flagNullID
           
protected static byte flagPeerGroupID
           
protected static byte flagPeerID
           
protected static byte flagPipeID
           
protected static int flagsEncodingOffset
           
protected static int flagsIdTypeOffset
           
protected static int flagsOffset
           
protected static int flagsSize
           
protected static int IdByteArraySize
          This class represents a JXTA ID.
static ID nullID
          The null ID.
static java.lang.String URIEncodingName
           
protected static byte UUIDEncoded
           
 
Constructor Summary
ID()
          Constructor for the null case.
 
Method Summary
protected  long bytesIntoLong(int offset)
          return the long value
 java.lang.Object clone()
          Returns a clone of this object.
 boolean equals(java.lang.Object target)
          Compares two CodatIds for equality.
abstract  PeerGroupID getPeerGroupID()
          Returns PeerGroupId of the Peer Group to which this CodatId belongs.
 java.net.URL getURL()
          Public member which returns a URI (URL in Java nomenclature) of the ID.
 int hashCode()
          Public member calculates a hash code for this ID.
 boolean isSamePeerGroup(ID target)
          Returns true if this CodatId is in the same Peer Group as the target.
protected  void longIntoBytes(int offset, long value)
          convert a long into the byte array
 java.lang.String toString()
          Public member which returns a string representation of the ID.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

IdByteArraySize

protected static final int IdByteArraySize
This class represents a JXTA ID. IDs are used to uniquely identify a peer, a peer group and a pipe or any other objects manipulated by the core. JXTA ID are represented as UUID.
See Also:
IDFactory, net.jxta.id.UUID, net.jxta.id.UUIDFactory
Since:
JXTA 1.0

flagsSize

protected static final int flagsSize

flagsIdTypeOffset

protected static final int flagsIdTypeOffset

flagNullID

protected static final byte flagNullID

flagCodatID

protected static final byte flagCodatID

flagPeerGroupID

protected static final byte flagPeerGroupID

flagPeerID

protected static final byte flagPeerID

flagPipeID

protected static final byte flagPipeID

flagsEncodingOffset

protected static final int flagsEncodingOffset

UUIDEncoded

protected static final byte UUIDEncoded

flagsOffset

protected static final int flagsOffset

bytes

protected byte[] bytes

nullID

public static final ID nullID
The null ID. Useful for comparisons and cases where the Id is ignored.

URIEncodingName

public static final java.lang.String URIEncodingName
Constructor Detail

ID

public ID()
Constructor for the null case. This constructor initializes only the flag fields of the ID. This is not usually a useful operation since there are already constants. Provided for subclasses to make their own null constants.
Since:
JXTA 1.0
Method Detail

isSamePeerGroup

public boolean isSamePeerGroup(ID target)
Returns true if this CodatId is in the same Peer Group as the target.
Parameters:
target - The CodatId which will checked for a Peer Group match.
Returns:
boolean true if the CodatIds are in the same Peer Group otherwise false.
Since:
JXTA 1.0

getPeerGroupID

public abstract PeerGroupID getPeerGroupID()
Returns PeerGroupId of the Peer Group to which this CodatId belongs.
Returns:
PeerGroupId of the Peer Group which this CodatId is part of.
Since:
JXTA 1.0

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Returns a clone of this object.
Overrides:
clone in class java.lang.Object
Returns:
the cloned object

equals

public boolean equals(java.lang.Object target)
Compares two CodatIds for equality.
Overrides:
equals in class java.lang.Object
Parameters:
target - the CodatID to be compared against.
Returns:
boolean true if CodatIds are equal, false otherwise.
Since:
JXTA 1.0

hashCode

public int hashCode()
Public member calculates a hash code for this ID. Used by Hashmaps.
Overrides:
hashCode in class java.lang.Object
Returns:
int Containing the hashcode of this ID.
Since:
JXTA 1.0

toString

public java.lang.String toString()
Public member which returns a string representation of the ID. This implementations encodes the Codat ID into a URI.
Overrides:
toString in class java.lang.Object
Returns:
String containting the URI
Since:
JXTA 1.0

getURL

public java.net.URL getURL()
Public member which returns a URI (URL in Java nomenclature) of the ID.
Returns:
URL Object containing the URI
Since:
JXTA 1.0

longIntoBytes

protected void longIntoBytes(int offset,
                             long value)
convert a long into the byte array
Parameters:
offset - offset
Since:
JXTA 1.0

bytesIntoLong

protected long bytesIntoLong(int offset)
return the long value
Parameters:
offset -  
Returns:
long
Since:
JXTA 1.0

Project JXTA