JXTA

net.jxta.protocol
Class PeerAdvertisement

java.lang.Object
  extended by net.jxta.document.Advertisement
      extended by net.jxta.document.ExtendableAdvertisement
          extended by net.jxta.protocol.PeerAdvertisement
All Implemented Interfaces:
Cloneable

public abstract class PeerAdvertisement
extends ExtendableAdvertisement
implements Cloneable

Generated when instantiating a group on a peer and contains all the parameters that services need to publish. It is then published within the group.


Constructor Summary
PeerAdvertisement()
           
 
Method Summary
 PeerAdvertisement 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 that peer X group intersection.
 int getModCount()
          Returns the number of times this object has been modified since it was created.
 String getName()
          returns the name of the peer.
 PeerGroupID getPeerGroupID()
          Returns the id of the peergroup this peer advertisement is for.
 PeerID getPeerID()
          Returns the id of the peer.
 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.
protected  int incModCount()
          Increments the modification count for this peer advertisement.
 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 setName(String name)
          sets the name of the peer.
 void setPeerGroupID(PeerGroupID gid)
          Returns the id of the peergroup this peer advertisement is for.
 void setPeerID(PeerID pid)
          Sets the id of the peer.
 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

PeerAdvertisement

public PeerAdvertisement()
Method Detail

getModCount

public int getModCount()
Returns the number of times this object has been modified since it was created. This permits to detection of local changes that require refreshing of other data which depends upon the peer advertisement.

Returns:
int the current modification count.

incModCount

protected int incModCount()
Increments the modification count for this peer advertisement.


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

Overrides:
clone in class Advertisement

getName

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

Returns:
String name of the peer.

setName

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

Parameters:
name - name of the peer.

getPeerID

public PeerID getPeerID()
Returns the id of the peer.

Returns:
PeerID the peer id

setPeerID

public void setPeerID(PeerID pid)
Sets the id of the peer.

Parameters:
pid - the id of this peer.

getPeerGroupID

public PeerGroupID getPeerGroupID()
Returns the id of the peergroup this peer advertisement is for.

Returns:
PeerGroupID the peergroup id

setPeerGroupID

public void setPeerGroupID(PeerGroupID gid)
Returns the id of the peergroup this peer advertisement is for.

Parameters:
gid - The id of the peer.

getID

public ID getID()
Returns a unique ID for that peer X group intersection. This is for indexing purposes only.

Specified by:
getID in class Advertisement
Returns:
ID the unique ID

getDescription

public String getDescription()
returns the description

Returns:
String the description

setDescription

public void setDescription(String description)
sets the description

Parameters:
description - the description
Since:
JXTA 1.0

getDesc

public StructuredDocument getDesc()
returns the description

Returns:
the description

setDesc

public void setDesc(Element desc)
sets the description

Parameters:
desc - the description

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