Project JXTA

net.jxta.protocol
Class ConfigParams

java.lang.Object
  extended bynet.jxta.document.Advertisement
      extended bynet.jxta.document.ExtendableAdvertisement
          extended bynet.jxta.protocol.ConfigParams

public abstract class ConfigParams
extends ExtendableAdvertisement

A container for configuration parameters.


Field Summary
protected  int modCount
          Counts the changes made to this object.
 
Constructor Summary
ConfigParams()
           
 
Method Summary
 boolean addDocumentElements(StructuredDocument adv)
          Return the advertisement as a document.
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.
 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 getServiceParamsEntrySet()
          Returns the set of params held by this object.
protected  boolean handleElement(Element raw)
          Process an individual element from the document during parse. Normally, implementations will allow the base advertisments a chance to handle the element before attempting ot 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;
      }
  
protected  int incModCount()
          Increases the modification count of the
 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.
 
Methods inherited from class net.jxta.document.ExtendableAdvertisement
getDocument
 
Methods inherited from class net.jxta.document.Advertisement
clone, getAdvType, getID, getIndexFields, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

modCount

protected transient volatile int 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

public ConfigParams()
Method Detail

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 the


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.

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 stand-alone 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.

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".

getServiceParamsEntrySet

public Set getServiceParamsEntrySet()
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.


handleElement

protected boolean handleElement(Element raw)
Process an individual element from the document during parse. Normally, implementations will allow the base advertisments a chance to handle the element before attempting ot 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

JXTA J2SE