JXTA

net.jxta.impl.id.binaryID
Class PeerGroupBinaryID

java.lang.Object
  extended by net.jxta.id.ID
      extended by net.jxta.peergroup.PeerGroupID
          extended by net.jxta.impl.id.binaryID.PeerGroupBinaryID
All Implemented Interfaces:
Serializable

public final class PeerGroupBinaryID
extends PeerGroupID

This class implements a PeerGroup ID. Each peer group is assigned a unique peer id.BinaryID id are used to implement peer group id. Because this id is built with BinaryID, pulling the parent group requires a little work. The parent group is the first id, with the second following, separated by a dash '-' character.

Author:
Daniel Brookshier turbogeek@cluck.com
See Also:
ID, IDFactory, PeerGroupID, Serialized Form

Field Summary
protected  String id
          This is the id string used in the XML of the id.
 
Fields inherited from class net.jxta.peergroup.PeerGroupID
defaultNetPeerGroupID, worldPeerGroupID
 
Fields inherited from class net.jxta.id.ID
nullID, URIEncodingName, URNNamespace
 
Constructor Summary
  PeerGroupBinaryID()
          Constructor for creating a new PeerGroupID.
  PeerGroupBinaryID(BinaryID id)
          Constructor.
  PeerGroupBinaryID(byte[] data, boolean lengthIncluded)
          Constructor for creating a new PeerGroupID with a unique ID and a parent.
  PeerGroupBinaryID(PeerGroupID parent, byte[] data, boolean lengthIncluded)
          Constructor for creating a new PeerGroupID with a unique ID and a parent.
protected PeerGroupBinaryID(String id)
          Creates a ID from a string.
 
Method Summary
 boolean equals(Object target)
          
protected  String getID()
          returns the coded ID without the binaryid tag.
 String getIDFormat()
          Returns a string identifier which indicates which ID format is used by this ID instance.
 PeerGroupID getParentPeerGroupID()
          Returns the parent peer group id of this peer group id, if any.
 ID getPeerGroupID()
          
 Object getUniqueValue()
          Returns an object containing the unique value of the ID.
 int hashCode()
          
 
Methods inherited from class net.jxta.peergroup.PeerGroupID
create, intern
 
Methods inherited from class net.jxta.id.ID
getURL, toString, toURI
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

id

protected String id
This is the id string used in the XML of the id. The format is TX0..Xn where T is the type and X0 through Xn are the base64 encoded id.

Constructor Detail

PeerGroupBinaryID

public PeerGroupBinaryID(PeerGroupID parent,
                         byte[] data,
                         boolean lengthIncluded)
Constructor for creating a new PeerGroupID with a unique ID and a parent.

Note that only the ID for the parent is obtained and not the parent and the grandparent.

Parameters:
parent - Parent peer group.
data - data byte array to be used as the id.
lengthIncluded - If true, the first byte in the data array is the length of the remaining bytes.

PeerGroupBinaryID

protected PeerGroupBinaryID(String id)
Creates a ID from a string. Note that the ID is not currently validated.

Parameters:
id - Value of ID.

PeerGroupBinaryID

public PeerGroupBinaryID(byte[] data,
                         boolean lengthIncluded)
Constructor for creating a new PeerGroupID with a unique ID and a parent.

Parameters:
data - DOCUMENT ME!
lengthIncluded - DOCUMENT ME!

PeerGroupBinaryID

public PeerGroupBinaryID()
Constructor for creating a new PeerGroupID. Note that this creates an invalid ID but is required for serialization.


PeerGroupBinaryID

public PeerGroupBinaryID(BinaryID id)
Constructor. Intializes contents from provided ID. This PeerGroupID has no parent.

Parameters:
id - the ID data
Method Detail

equals

public boolean equals(Object target)

Overrides:
equals in class Object

hashCode

public int hashCode()

Overrides:
hashCode in class Object

getIDFormat

public String getIDFormat()
Returns a string identifier which indicates which ID format is used by this ID instance.

Specified by:
getIDFormat in class ID
Returns:
a string identifier which indicates which ID format is used by this ID instance.

getUniqueValue

public Object getUniqueValue()
Returns an object containing the unique value of the ID. This object must provide implementations of toString(), equals() 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.

Specified by:
getUniqueValue in class ID
Returns:
Object which can provide canonical representations of the ID.

getPeerGroupID

public ID getPeerGroupID()


getParentPeerGroupID

public PeerGroupID getParentPeerGroupID()
Returns the parent peer group id of this peer group id, if any.

Specified by:
getParentPeerGroupID in class PeerGroupID
Returns:
the id of the parent peergroup or null if this group has no parent group.

getID

protected String getID()
returns the coded ID without the binaryid tag.

Returns:
The coded ID without the binaryid tag.

JXSE