JXTA

net.jxta.peergroup
Class PeerGroupID

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

public abstract class PeerGroupID
extends ID

This class implements a PeerGroup ID. Each peer group is assigned a unique id.

Since:
JXTA 1.0
See Also:
ID, IDFactory, PeerID, Serialized Form

Field Summary
static PeerGroupID defaultNetPeerGroupID
          The well known Unique Identifier of the net peergroup.
static PeerGroupID worldPeerGroupID
          The well known Unique Identifier of the world peergroup.
 
Fields inherited from class net.jxta.id.ID
nullID, URIEncodingName, URNNamespace
 
Constructor Summary
PeerGroupID()
           
 
Method Summary
static PeerGroupID create(URI fromURI)
          Creates an ID by parsing the given URI.
abstract  PeerGroupID getParentPeerGroupID()
          Returns the parent peer group id of this peer group id, if any.
 PeerGroupID intern()
          Returns a canonical representation for the ID object.
 
Methods inherited from class net.jxta.id.ID
getIDFormat, getUniqueValue, getURL, toString, toURI
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

worldPeerGroupID

public static final PeerGroupID worldPeerGroupID
The well known Unique Identifier of the world peergroup. This is a singleton within the scope of a VM.


defaultNetPeerGroupID

public static final PeerGroupID defaultNetPeerGroupID
The well known Unique Identifier of the net peergroup. This is a singleton within the scope of this VM.

Constructor Detail

PeerGroupID

public PeerGroupID()
Method Detail

create

public static PeerGroupID create(URI fromURI)
Creates an ID by parsing the given URI.

This convenience factory method works as if by invoking the IDFactory.fromURI(URI) method; any URISyntaxException thrown is caught and wrapped in a new IllegalArgumentException object, which is then thrown.

This method is provided for use in situations where it is known that the given string is a legal ID, for example for ID constants declared within in a program, and so it would be considered a programming error for the URI not to parse as such. The IDFactory, which throws URISyntaxException directly, should be used situations where a ID is being constructed from user input or from some other source that may be prone to errors.

Parameters:
fromURI - The URI to be parsed into an ID
Returns:
The new ID
Throws:
NullPointerException - If fromURI is null.
IllegalArgumentException - If the given URI is not a valid ID.

intern

public PeerGroupID intern()
Returns a canonical representation for the ID object.

A pool of IDs, is maintained privately by the class.

When the intern() method is invoked, if the pool already contains a ID equal to this ID object as determined by the equals(Object) method, then the ID from the pool is returned. Otherwise, this ID object is added to the pool and a reference to this ID object is returned.

It follows that for any two ID s and t, s.intern() == t.intern() is true if and only if s.equals(t) is true.

Overrides:
intern in class ID
Returns:
a ID that has the same value as this type, but is guaranteed to be from a pool of unique types.

getParentPeerGroupID

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

Returns:
the id of the parent peergroup or null if this group has no parent group.

JXSE