org.eclipse.actf.core.config
Class AbstractConfiguration

java.lang.Object
  extended by org.eclipse.actf.core.config.AbstractConfiguration
All Implemented Interfaces:
Serializable, IConfiguration
Direct Known Subclasses:
EclipseConfiguration, HybridConfiguraton, XmlConfiguration

public class AbstractConfiguration
extends Object
implements IConfiguration

serves as a general-purpose implementation of the Configuration interface. In particular, this class manages the overall pool of ids and the key-value pairs (parameters) to which each id corresponds.

Note: Clients should extend this class rather than implementing Configuration to avoid API modifications.

Author:
Randy Horwitz
See Also:
Serialized Form

Field Summary
 Map _configMap
           
protected  String _curPool
           
 
Fields inherited from interface org.eclipse.actf.core.config.IConfiguration
ACTF_ID, ALIASES_ID, FILTER_CLASSNAME_ATTRIBUTE, FILTER_ID, FILTER_MODEL_ATTRIBUTE, FILTER_NODEIDS_ATTRIBUTE, FILTER_NODENAMES_ATTRIBUTE, MODEL_ADAPTOR_FACTORY, MODEL_BASE_TYPE, MODEL_ID, MODEL_IGNOREIDS, MODEL_IGNORENODENAMES, MODEL_LOCATOR, MODEL_LOCATORIDS_POOL, MODEL_POOL_ID_DELIMITER, SHOW_INVISIBLE_KEY, SHOW_ITEMS_KEY, TRACE_LEVEL_KEY, TRACE_STREAM_KEY, WORKING_DIR_KEY
 
Constructor Summary
AbstractConfiguration()
          create a Configuration.
 
Method Summary
 void addConfigurationData(Object data)
          default implementation for this method attempts to treat the data object as a map and simply adds it to the existing configuration map.
 void createSymbolPool(String id)
           
 boolean getBooleanParameter(String key)
          retrieve a boolean parameter from the current symbol pool
 Class getClassParameter(String key)
          retrieve a class parameter from the current symbol pool
 double getDoubleParameter(String key)
          retrieve a double parameter from the current symbol pool
 int getIntParameter(String key)
          retrieve an int parameter from the current symbol pool
 String[] getModelTypes()
          returns the model supported within this configuration object.
 Object getParameter(String key)
          get a parameter of an undetermined type in the current symbol pool
 String getParameterAsString(String key)
          get the parameter with the given key as a string
 String[] getParameterNames()
          retrieve list of parameters from the current symbol pool
 String getStringParameter(String key)
          retrieve a string parameter from the current symbol pool
 String getSymbolPool()
          get the current symbol pool.
 Map getSymbolPoolContents(String poolID)
          get the contents of the specified symbol pool
 String[] getSymbolPools()
          get all available symbol pools.
 void setParameter(String key, boolean value)
          set a boolean parameter in the current symbol pool
 void setParameter(String key, Class value)
          set a class parameter in the current symbol pool
 void setParameter(String key, double value)
          set a double parameter in the current symbol pool
 void setParameter(String key, int value)
          set an int parameter in the current symbol pool
 void setParameter(String key, Object value)
          set a parameter of an undetermined type in the current symbol pool
 void setParameter(String key, String value)
          set a string parameter in the current symbol pool
 void setParameter(String poolID, String name, Object val)
          convenience method to set any parameter in the configuration.
 void setSymbolPool(String id)
          set the symbol pool to be used in subsequent set/getParameter calls.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_configMap

public Map _configMap

_curPool

protected String _curPool
Constructor Detail

AbstractConfiguration

public AbstractConfiguration()
create a Configuration. Configuration objects are managed by the engine and should not be created by clients. Use a RuntimeContextFactory instance to create and access active configurations.

See Also:
RuntimeContextFactory
Method Detail

getSymbolPoolContents

public Map getSymbolPoolContents(String poolID)
get the contents of the specified symbol pool

Specified by:
getSymbolPoolContents in interface IConfiguration
Parameters:
poolID - - id of symbol pool
Returns:
map containing contents of pool or null if pool does not exist
See Also:
IConfiguration.setSymbolPool(String)

setSymbolPool

public void setSymbolPool(String id)
set the symbol pool to be used in subsequent set/getParameter calls. A symbol pool embodies a purpose or role in the ACTF engine. Instances of this interface might represent a particular symbol pool by a .properties file, data base table, or XML document.

Symbol pool ids can have two forms:


createSymbolPool

public void createSymbolPool(String id)

getSymbolPool

public String getSymbolPool()
get the current symbol pool. The returned value is the id of the pool that is currently be accessed by any get/setXXXParameter methods.

Specified by:
getSymbolPool in interface IConfiguration
Returns:
current symbol pool id
See Also:
IConfiguration.setSymbolPool(String)

getSymbolPools

public String[] getSymbolPools()
get all available symbol pools.

Specified by:
getSymbolPools in interface IConfiguration
Returns:
array of ids for all available symbol pools or empty array if no pools have been created other than the default pool
See Also:
IConfiguration.setSymbolPool(String)

getModelTypes

public String[] getModelTypes()
returns the model supported within this configuration object. ACTF is packaged with support for the following model:

Models are always introduced in the main symbol pool, ACTF_ID and should be retrieved via the MODEL_ID symbol pool. Indeed, this method will usually be short-hand for:

 setSymbolPool(MODEL_ID);
 return getParameterNames();
 

Specified by:
getModelTypes in interface IConfiguration
Returns:
names of supported model
See Also:
IConfiguration.getParameterNames(), IConfiguration.setSymbolPool(String)

setParameter

public void setParameter(String key,
                         Object value)
set a parameter of an undetermined type in the current symbol pool

Specified by:
setParameter in interface IConfiguration
Parameters:
key - - name of parameter
value - - object corresponding to this key
See Also:
IConfiguration.setSymbolPool(String)

setParameter

public void setParameter(String key,
                         String value)
set a string parameter in the current symbol pool

Specified by:
setParameter in interface IConfiguration
Parameters:
key - - name of parameter
value - - string value corresponding to this key
See Also:
IConfiguration.setSymbolPool(String)

setParameter

public void setParameter(String key,
                         int value)
set an int parameter in the current symbol pool

Specified by:
setParameter in interface IConfiguration
Parameters:
key - - name of parameter
value - - int value corresponding to this key
See Also:
IConfiguration.setSymbolPool(String)

setParameter

public void setParameter(String key,
                         double value)
set a double parameter in the current symbol pool

Specified by:
setParameter in interface IConfiguration
Parameters:
key - - name of parameter
value - - double value corresponding to this key
See Also:
IConfiguration.setSymbolPool(String)

setParameter

public void setParameter(String key,
                         boolean value)
set a boolean parameter in the current symbol pool

Specified by:
setParameter in interface IConfiguration
Parameters:
key - - name of parameter
value - - boolean value corresponding to this key
See Also:
IConfiguration.setSymbolPool(String)

setParameter

public void setParameter(String key,
                         Class value)
set a class parameter in the current symbol pool

Specified by:
setParameter in interface IConfiguration
Parameters:
key - - name of parameter
value - - Class object corresponding to this key
See Also:
IConfiguration.setSymbolPool(String)

setParameter

public void setParameter(String poolID,
                         String name,
                         Object val)
convenience method to set any parameter in the configuration. The current symbol pool id is saved and then restored after the set operation is complete.

Parameters:
poolID - - id of symbol pool in which set is to occur
name - - name or id of parameter to set
val - - value of parameter

getParameter

public Object getParameter(String key)
get a parameter of an undetermined type in the current symbol pool

Specified by:
getParameter in interface IConfiguration
Parameters:
key - - name of parameter to retrieve
Returns:
desired parameter
See Also:
IConfiguration.setSymbolPool(String)

getStringParameter

public String getStringParameter(String key)
retrieve a string parameter from the current symbol pool

Specified by:
getStringParameter in interface IConfiguration
Parameters:
key - - name or key of parameter
Returns:
string parameter with the given name or null if no such key exists
See Also:
IConfiguration.setSymbolPool(String)

getIntParameter

public int getIntParameter(String key)
retrieve an int parameter from the current symbol pool

Specified by:
getIntParameter in interface IConfiguration
Parameters:
key - - name or key of parameter
Returns:
int parameter with the given name or null if no such key exists
See Also:
IConfiguration.setSymbolPool(String)

getDoubleParameter

public double getDoubleParameter(String key)
retrieve a double parameter from the current symbol pool

Specified by:
getDoubleParameter in interface IConfiguration
Parameters:
key - - name or key of parameter
Returns:
double parameter with the given name or null if no such key exists
See Also:
IConfiguration.setSymbolPool(String)

getBooleanParameter

public boolean getBooleanParameter(String key)
retrieve a boolean parameter from the current symbol pool

Specified by:
getBooleanParameter in interface IConfiguration
Parameters:
key - - name or key of parameter
Returns:
boolean parameter with the given name or null if no such key exists
See Also:
IConfiguration.setSymbolPool(String)

getClassParameter

public Class getClassParameter(String key)
retrieve a class parameter from the current symbol pool

Specified by:
getClassParameter in interface IConfiguration
Parameters:
key - - name or key of parameter
Returns:
class parameter with the given name or null if no such key exists
See Also:
IConfiguration.setSymbolPool(String)

getParameterAsString

public String getParameterAsString(String key)
get the parameter with the given key as a string

Specified by:
getParameterAsString in interface IConfiguration
Parameters:
key - - key of desired parameter
Returns:
string representation of parameter or null if parameter is not found
See Also:
IConfiguration.setSymbolPool(String)

addConfigurationData

public void addConfigurationData(Object data)
                          throws ConfigurationException
default implementation for this method attempts to treat the data object as a map and simply adds it to the existing configuration map.

Specified by:
addConfigurationData in interface IConfiguration
Parameters:
data - configuration data
Throws:
ConfigurationException

getParameterNames

public String[] getParameterNames()
retrieve list of parameters from the current symbol pool

Specified by:
getParameterNames in interface IConfiguration
Returns:
list of parameters or empty array if no parameters exist
See Also:
IConfiguration.setSymbolPool(String)

toString

public String toString()
Overrides:
toString in class Object