Project JXTA

net.jxta.protocol
Class PeerGroupAdvertisement

java.lang.Object
  extended bynet.jxta.document.Advertisement
      extended bynet.jxta.document.ExtendableAdvertisement
          extended bynet.jxta.protocol.PeerGroupAdvertisement
All Implemented Interfaces:
Cloneable

public abstract class PeerGroupAdvertisement
extends ExtendableAdvertisement
implements Cloneable

Describes a peer group and references additional information required for instantiating it. The PeerGroup method newGroup performs the task of instantiating a PeerGroup given its advertisement (provided the required subsequent documents can actually be found).

See Also:
ModuleSpecID, ModuleImplAdvertisement, PeerGroup

Constructor Summary
PeerGroupAdvertisement()
           
 
Method Summary
 Object clone()
          Clone this PeerGroupAdvertisement
static String getAdvertisementType()
          Returns the identifying type of this Advertisement.
 String getBaseAdvType()
          Returns the base type of this advertisement hierarchy. Typically, only the most basic advertisement of a type will implement this method and declare it as final.
 String getDescription()
          returns the description
 ID getID()
          Returns a unique ID for indexing purposes.
 ModuleSpecID getModuleSpecID()
          Returns the id of the group spec that this uses.
 String getName()
          returns the name of the group.
 PeerGroupID getPeerGroupID()
          Returns the id of the group.
 StructuredDocument getServiceParam(ID key)
          Returns the parameter element that matches the given key from the service parameters table.
 Hashtable getServiceParams()
          Returns the sets of parameters for all services.
 void putServiceParam(ID key, Element param)
          Puts a service parameter in the service parameters table under the given key.
 StructuredDocument removeServiceParam(ID key)
          Removes and returns the parameter element that matches the given key from the service parameters table.
 void setDescription(String description)
          sets the description
 void setModuleSpecID(ModuleSpecID sid)
          Sets the id of the group spec that this peer group uses.
 void setName(String name)
          sets the name of the group.
 void setPeerGroupID(PeerGroupID gid)
          Sets the id of the group.
 void setServiceParams(Hashtable params)
          sets the sets of parameters for all services.
 
Methods inherited from class net.jxta.document.ExtendableAdvertisement
getDocument, handleElement
 
Methods inherited from class net.jxta.document.Advertisement
getAdvType, getIndexFields, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PeerGroupAdvertisement

public PeerGroupAdvertisement()
Method Detail

getAdvertisementType

public static String getAdvertisementType()
Returns the identifying type of this Advertisement.

Returns:
String the type of advertisement

getBaseAdvType

public final String getBaseAdvType()
Returns the base type of this advertisement hierarchy. Typically, only the most basic advertisement of a type will implement this method and declare it as final.

Specified by:
getBaseAdvType in class ExtendableAdvertisement
Returns:
String the base type of advertisements in this hierarchy.

clone

public Object clone()
Clone this PeerGroupAdvertisement

Overrides:
clone in class Advertisement
Returns:
Object an object of class PeerGroupAdvertisement that is a deep-enough copy of this one.

getName

public String getName()
returns the name of the group.

Returns:
String name of the group.

setName

public void setName(String name)
sets the name of the group.

Parameters:
name - name of the group.

getModuleSpecID

public ModuleSpecID getModuleSpecID()
Returns the id of the group spec that this uses.

Returns:
ID the spec id

setModuleSpecID

public void setModuleSpecID(ModuleSpecID sid)
Sets the id of the group spec that this peer group uses.

Parameters:
sid - The id of the spec

getPeerGroupID

public PeerGroupID getPeerGroupID()
Returns the id of the group.

Returns:
ID the group id

setPeerGroupID

public void setPeerGroupID(PeerGroupID gid)
Sets the id of the group.

Parameters:
gid - The id of this group.

getID

public ID getID()
Returns a unique ID for indexing purposes. We use the id of the group as a plain ID.

Specified by:
getID in class Advertisement
Returns:
ID a unique id for that advertisement.

getDescription

public String getDescription()
returns the description

Returns:
String the description

setDescription

public void setDescription(String description)
sets the description

Parameters:
description - the description

setServiceParams

public void setServiceParams(Hashtable params)
sets the sets of parameters for all services. This method first makes a deep copy, in order to protect the active information from uncontrolled sharing. This quite an expensive operation. If only a few of the parameters need to be added, it is wise to use putServiceParam() instead.

Parameters:
params - The whole set of parameters.

getServiceParams

public Hashtable getServiceParams()
Returns the sets of parameters for all services.

This method returns a deep copy, in order to protect the real information from uncontrolled sharing while keeping it shared as long as it is safe. This quite an expensive operation. If only a few parameters need to be accessed, it is wise to use getServiceParam() instead.

Returns:
all of the parameters.

putServiceParam

public void putServiceParam(ID key,
                            Element param)
Puts a service parameter in the service parameters table under the given key. The key is of a subclass of ID; usually a ModuleClassID. This method makes a deep copy of the given element into an independent document.

Parameters:
key - The key.
param - The parameter, as an element. What is stored is a copy as a standalone StructuredDocument which type is the element's name.

getServiceParam

public StructuredDocument getServiceParam(ID key)
Returns the parameter element that matches the given key from the service parameters table. The key is of a subclass of ID; usually a ModuleClassID.

Parameters:
key - The key.
Returns:
StructuredDocument The matching parameter document or null if none matched. The document type id "Param".

removeServiceParam

public StructuredDocument removeServiceParam(ID key)
Removes and returns the parameter element that matches the given key from the service parameters table. The key is of a subclass of ID; usually a ModuleClassID.

Parameters:
key - The key.
Returns:
Element the removed parameter element or null if not found. This is actually a StructureDocument of type "Param".

JXTA J2SE