JXTA

net.jxta.protocol
Class ConfigParams

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

public abstract class ConfigParams
extends ExtendableAdvertisement
implements Cloneable

A container for collections of configuration parameters. Configuration parameters are stored in a Map which is keyed by JXTA IDs and whose values are Advertisements.


Field Summary
protected  AtomicInteger modCount
          Counts the changes made to this object.
 
Constructor Summary
protected ConfigParams()
          Default Constructor.
 
Method Summary
 boolean addDocumentElements(StructuredDocument adv)
          Return the advertisement as a document.
 ConfigParams clone()
          
 boolean equals(Object other)
          
static String getAdvertisementType()
          Returns the identifying type of this Advertisement.
 String getBaseAdvType()
          Returns the base type of this advertisement hierarchy.
 int getModCount()
          Returns the number of times this object has been modified since it was created.
 StructuredDocument getServiceParam(ID key)
          Returns the parameter element that matches the given key from the service parameters table.
 Set<Map.Entry<ID,StructuredDocument>> getServiceParamsEntrySet()
          Deprecated. This method exposes the internal data structures of the advertisement and will be removed in order to prevent unexpected behaviour.
 Advertisement getSvcConfigAdvertisement(ID key)
          Gets an advertisement from the service parameters table under the given key.
protected  boolean handleElement(Element raw)
          Process an individual element from the document during parse.
protected  int incModCount()
          Increases the modification count of this instance.
 boolean isSvcEnabled(ID key)
          Gets an advertisement from the service parameters table under the given key.
 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 removeSvcConfigAdvertisement(ID key)
          Removes any parameters for the given key from the service parameters table.
 void setSvcConfigAdvertisement(ID key, Advertisement adv)
          Puts an advertisement into the service parameters table under the given key.
 void setSvcConfigAdvertisement(ID key, Advertisement adv, boolean enabled)
          Puts an advertisement into the service parameters table under the given key.
 
Methods inherited from class net.jxta.document.ExtendableAdvertisement
getDocument, handleAttribute
 
Methods inherited from class net.jxta.document.Advertisement
getAdvType, getID, getIndexFields, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

modCount

protected final transient AtomicInteger modCount
Counts the changes made to this object. The API increments it every time some change is not proven to be idempotent. We rely on implementations to increment modCount every time something is changed without going through the API.

Constructor Detail

ConfigParams

protected ConfigParams()
Default Constructor. We want all ConfigParams derived advertisements to pretty print.

Method Detail

getAdvertisementType

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

Returns:
String the type of advertisement

clone

public ConfigParams clone()

Overrides:
clone in class Advertisement

equals

public boolean equals(Object other)

Overrides:
equals in class Object

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.

handleElement

protected boolean handleElement(Element raw)
Process an individual element from the document during parse. Normally, implementations will allow the base advertisements a chance to handle the element before attempting to handle the element themselves. ie.


  protected boolean handleElement(Element elem) {

      if (super.handleElement()) {
           // it's been handled.
           return true;
           }
      ... handle elements here ...

      // we don't know how to handle the element
      return false;
      }
  

Overrides:
handleElement in class ExtendableAdvertisement
Parameters:
raw - The element to be processed.
Returns:
true if the element was recognized, otherwise false.

addDocumentElements

public boolean addDocumentElements(StructuredDocument adv)
Return the advertisement as a document.

Parameters:
adv - the document to add elements to.
Returns:
true if elements were added otherwise false.

getModCount

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

Returns:
int the current modification count.

incModCount

protected int incModCount()
Increases the modification count of this instance.

Returns:
modification count

putServiceParam

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

Parameters:
key - The key.
param - The parameter document.

setSvcConfigAdvertisement

public void setSvcConfigAdvertisement(ID key,
                                      Advertisement adv)
Puts an advertisement into the service parameters table under the given key. The key is usually a ModuleClassID. This method makes a clone of the advertisement.

Parameters:
key - The key.
adv - The advertisement, a clone of which is stored or null to forget this key.

setSvcConfigAdvertisement

public void setSvcConfigAdvertisement(ID key,
                                      Advertisement adv,
                                      boolean enabled)
Puts an advertisement into the service parameters table under the given key. The key is usually a ModuleClassID. This method makes a clone of the advertisement.

Parameters:
key - The key.
adv - The advertisement, a clone of which is stored or null to forget this key.
enabled - If true then the service is enabled or disabled if false.

isSvcEnabled

public boolean isSvcEnabled(ID key)
Gets an advertisement from the service parameters table under the given key. The key is usually a ModuleClassID. This method makes a clone of the advertisement.

Parameters:
key - The key.
Returns:
If true then the service is enabled otherwise if the service is disabled.

getSvcConfigAdvertisement

public Advertisement getSvcConfigAdvertisement(ID key)
Gets an advertisement from the service parameters table under the given key. The key is usually a ModuleClassID. This method makes a clone of the advertisement.

Parameters:
key - The key.
Returns:
The advertisement for the specified key otherwise null.

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.

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:
The removed parameter element or null if not found.

removeSvcConfigAdvertisement

public void removeSvcConfigAdvertisement(ID key)
Removes any parameters for the given key from the service parameters table.

Parameters:
key - The key.

getServiceParamsEntrySet

@Deprecated
public Set<Map.Entry<ID,StructuredDocument>> getServiceParamsEntrySet()
Deprecated. This method exposes the internal data structures of the advertisement and will be removed in order to prevent unexpected behaviour.

Returns the set of params held by this object. The parameters are not copied and any changes to the Set are reflected in this object's version. incModCount should be called as appropriate.


JXSE