|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
Represents the basic interface of a datastore.
A DataManager stores hierarchically organized values
and allows access to them. The hierarchy usually reflects the object
structure of the stored objects including their attributes.
There are many extensions to this interface that provide additional functionality.
The DataManager interface is one of three facets
of the DataManagerComponent.
The following basic concepts are used by the
DataManagerComponent.
DataManager)
String. Values may be any java object,
e.g. a Integer or a complex data structure starting with an object that references other data objects.
DataManager).
DataConfiguration
and DataStructureConfiguration)
Node
that defines the structural aspects of the data that can be stored under that key.
BaseNode)
DataStructureConfiguration.addBaseNode(String, Class).
AspectNode)
getValue(String) with the key "person.name" will return the value
of the attribute "name" of the "Person" object stored in the node "person".
And setValue(String, Object) with the key "person.name" will set
the value in the stored object.
DataStructureConfiguration.addAspectNode(String, String, Class, String, Class).
IndexedNode)
Integer index.
List, an array, or a Map.
Please note that the capabilities of the indexed node depend on the corresponding plugin, thus restricting the
possible types an indexed node can be based on.
getValue(String, Context) to access an indexed value. The Context
parameter has the information which index should be used in form of key value pairs where the key is the key of the
indexed node and the value is the index to be used.
List of class "Employee".
You can have the instanceof of "Company" in a base node "company" and an aspect node "company.employees" which is connected to the "employees" attribute.
Then you can define an indexed node "company.employees.indexed" which depends on the node "company.employees".
To access the 5th employee instance in the list you need to create a context with the key "company.employees.indexed" and
the value (Integer)4. Using this context a call to getValue(String, Context) with a key of "company.employees.indexed"
will return the 5th employee.
ContextNodeComputation to do that for you.
The index mechanism with a context is incredibly powerful since it allows you to reference a value even when it is stored in a list
of a list of objects.
DataStructureConfiguration.addIndexedNode(String, String, Class, Class, Class).
ComputedNode)
Date into a String, but
you can define other computations, e.g. the concatenation of several string values that are stored in other nodes.
This is also a way to define 'virtual' attributes or values in the DataManager.
Computation
it is configured with. The Computation contains the code to convert
the source values into the node's own value (and vice versa if desired).
DataStructureConfiguration.addComputedNode(String, String[], Computation).
In most cases it will be sufficient to create a subclass of AbstractSimpleComputation
and supply it as the Computation parameter.
DataManagerSetup)
DataManagerComponent
supplies only the basic infrastructure for organizing data and change notifications.
You have to set up your data manager by registering the plugins that you want to use.
DataManagerPlugIn
and its corresponding implementation. The implementation is accessable by the user of the
DataManager by calling getPlugIn(Class) with the interface class as a parameter.
DataManager which
offer additional functionality, e.g. an observer mechanism, metadata or transaction support.
DataManager, e.g. for actually storing values or accessing indexed values. These plug ins are
absolutely necessary to create a data manager but are pluggable to allow for easy extensions,
e.g. when handling collections you can add support for other types by supplying a corresponding plug in that handles
the indexed nodes of those types.
DataManager interface by adding a
ValueHandler to the nodes they feel responsible for.
The value handlers of different plug ins are stacked in each node, thus the order in which
plug ins are registered is vital.
To use the DataManager, you must first register the DataManagerPlugIns
using DataManagerSetup,
then configure the data structure using DataConfiguration
or the more convenient interface DataStructureConfiguration.
Then you can add, read, and modify the data.
Note: Depending on the system or dialog environment, implementations of this interface may have to be threadsafe.
| Method Summary | |
boolean |
canModifyValue(java.lang.String key)
Tests whether the value with the given name can be modified. |
java.util.Set |
getIndexSet(java.lang.String key)
Returns a Set of the index values for the given key.
|
java.util.Set |
getIndexSet(java.lang.String key,
Context context)
Returns a Set of the index values for the given key. |
DataManagerPlugIn |
getPlugIn(java.lang.Class dataManagerPlugInClass)
Returns the requested plugin implementation |
java.lang.Object |
getValue(java.lang.String key)
Returns the value corresponding to the given name. |
java.lang.Object |
getValue(java.lang.String key,
Context context)
Returns a value that needs indices to be accessed. |
java.lang.Class |
getValueType(java.lang.String key)
Returnes the Class of the value that may be stored at
or recieved by the data node. |
boolean |
hasKey(java.lang.String key)
Tests whether the DataManager has a node defined for the given key.
|
boolean |
hasPlugIn(java.lang.Class dataManagerPlugInClass)
Tests whether the DataManager does have a specific plug in installed. |
boolean |
hasValue(java.lang.String key)
Tests whether the node defined by the given key does have a value. |
void |
setValue(java.lang.String key,
Context context,
java.lang.Object value)
Modifies a value that needs indices to be accessed. |
void |
setValue(java.lang.String key,
java.lang.Object value)
Sets the value corresponding to the given name. |
| Method Detail |
public java.lang.Object getValue(java.lang.String key)
key - the key of the data node
public java.lang.Class getValueType(java.lang.String key)
Class of the value that may be stored at
or recieved by the data node.
key - the key of the data node
public void setValue(java.lang.String key,
java.lang.Object value)
key - the of the data nodevalue - the new value, may be null if null is a valid value for the corresponding node
java.lang.IllegalArgumentException - if the value cannot be set.public boolean hasKey(java.lang.String key)
DataManager has a node defined for the given key.
This does not test whether the value is null or not, it tests solely if the
DataManager is configured in a way that allows such a value to exist.
If hasKey(String) returns false, getValue(String) will return null.
If hasKey(String) returns true, getValue(String)
depends on the value of this node and the nodes it depends on.
key - the key of the node
DataManager does have a node defined for the given keypublic boolean hasValue(java.lang.String key)
This does not test whether the value is null or not, it tests solely if the node could have a value other than null.
If hasValue(String) returns false, getValue(String) will return null.
If hasValue(String) returns true, getValue(String)
depends on the actually stored value but may return null.
key - the key of the node
java.lang.IllegalArgumentException - iff the DataManager does not have a node with the given key.public boolean hasPlugIn(java.lang.Class dataManagerPlugInClass)
DataManager does have a specific plug in installed.
dataManagerPlugInClass - the interface class (extending DataManagerPlugIn) that defines the plugin
DataManager does have the feature installedpublic DataManagerPlugIn getPlugIn(java.lang.Class dataManagerPlugInClass)
dataManagerPlugInClass - the interface class (extending DataManagerPlugIn) that defines the plugin
java.lang.IllegalArgumentException - if the DataManager does not have the given plugin installedpublic boolean canModifyValue(java.lang.String key)
If canModifyValue(String) returns false, then setValue(String, Object) will
throw an exception. Otherwise the call to setValue(String, Object) should succeed,
although it may fail for unexpected reasons.
key - the key of the node to be modified
DataManager can modify the value for the given name
public java.lang.Object getValue(java.lang.String key,
Context context)
key - the key of the data nodecontext - the context containing the indices needed to access the value
public void setValue(java.lang.String key,
Context context,
java.lang.Object value)
key - the key of the data nodecontext - the context containing the indices needed to access the valuevalue - the new value, may be null if null is a valid value for the corresponding node
java.lang.IllegalArgumentException - if the value cannot be set.public java.util.Set getIndexSet(java.lang.String key)
Set of the index values for the given key.
The objects of the set may be used as index values within a Context
together with the given key.
The method returns null for not indexed nodes.
key - the key of the data node
Set of the index values for the given key or null.
public java.util.Set getIndexSet(java.lang.String key,
Context context)
Set of the index values for the given key. The objects of
the set may be used as additional index values within the given
Context for access with the given key. The method returns null for
not indexed nodes.
key - the key of the data nodecontext - the context containing the indices needed to access the value
Set of the index values for the given key and context or null.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||