JXTA

net.jxta.protocol
Class PeerGroupAdvertisement

java.lang.Object
  extended by net.jxta.document.Advertisement
      extended by net.jxta.document.ExtendableAdvertisement
          extended by net.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). This advertisement is indexed on "Name", "GID", and "Desc"

See Also:
ModuleSpecID, ModuleImplAdvertisement, PeerGroup

Constructor Summary
PeerGroupAdvertisement()
          Construct a new Peer Group Advertisement.
 
Method Summary
 PeerGroupAdvertisement clone()
          
static String getAdvertisementType()
          Returns the identifying type of this Advertisement.
 String getBaseAdvType()
          Returns the base type of this advertisement hierarchy.
 StructuredDocument getDesc()
          returns the description
 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 or null if no name has been assigned.
 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<ID,StructuredDocument> 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 setDesc(Element desc)
          sets the description
 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<ID,? extends Element> params)
          sets the sets of parameters for all services.
 
Methods inherited from class net.jxta.document.ExtendableAdvertisement
getDocument, handleAttribute, 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()
Construct a new Peer Group Advertisement.

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 PeerGroupAdvertisement clone()

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

getName

public String getName()
Returns the name of the group or null if no name has been assigned.

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

getDesc

public StructuredDocument getDesc()
returns the description

Returns:
the description

setDesc

public void setDesc(Element desc)
sets the description

Parameters:
desc - the description
Since:
JXTA 1.0

setServiceParams

public void setServiceParams(Hashtable<ID,? extends Element> 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<ID,StructuredDocument> 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".

JXSE