JXTA

net.jxta.peer
Class PeerID

java.lang.Object
  extended by net.jxta.id.ID
      extended by net.jxta.peer.PeerID
All Implemented Interfaces:
Serializable

public abstract class PeerID
extends ID

This class implements a PeerID. Each peer is assigned a unique peer id.

See Also:
ID, IDFactory, PeerGroupID, Serialized Form

Field Summary
 
Fields inherited from class net.jxta.id.ID
nullID, URIEncodingName, URNNamespace
 
Constructor Summary
PeerID()
           
 
Method Summary
static PeerID create(URI fromURI)
          Creates an ID by parsing the given URI.
abstract  ID getPeerGroupID()
          Returns PeerGroupID of the Peer Group to which this Peer ID belongs.
 PeerID 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
 

Constructor Detail

PeerID

public PeerID()
Method Detail

create

public static PeerID 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 PeerID 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.

getPeerGroupID

public abstract ID getPeerGroupID()
Returns PeerGroupID of the Peer Group to which this Peer ID belongs.

Returns:
PeerGroupID of the Peer Group to which this Peer ID belongs.

JXSE