com.sdm.quasar.client.core.data.impl
Class DefaultNodeController

java.lang.Object
  extended bycom.sdm.quasar.client.core.data.impl.DefaultNodeController
All Implemented Interfaces:
NodeController, SystemInfoProvider

public final class DefaultNodeController
extends java.lang.Object
implements NodeController, SystemInfoProvider

Represents the internal node that a com.sdm.quasar.client.core.data.internal.impl.DataCore uses to manage the data structure defined by Nodes. A com.sdm.quasar.client.core.data.internal.impl.NodeController in the com.sdm.quasar.client.core.data.internal.impl.DataCore corresponds to a Node in the DataConfiguration. TODO Für JSF Rel.: Implementation should be made threadsafe

Version:
1.0
Author:
Thomas Wolf, sd&m AG, Bernd Olleck, sd&m AG

Method Summary
 void addValueHandler(ValueHandler valueHandler)
          Adds a ValueHandler to the list of value handlers in this node.
 void allowNotification()
          Allows notification of changes.
 boolean canModifyValue(Context context)
          Calls the chain of value handlers to test whether the value of this node can be modified
 void collectSystemInfo(SystemInfoNode root, SystemInfoOptions options)
          Builds the system information tree upon local information of the implementor.
 void continueNodeValueChangedNotification()
          Continues the notification across the node graph that this node's value has been changed.
protected  void dispose()
           
 DataCore getDataCore()
           
 java.util.List getDependentNodes()
           
 java.util.Set getIndexSet(Context context)
          Calls the chain of value handlers to return a Set of the index values for the node.
 java.lang.String getKey()
          Shortcut für getNode().
 java.lang.Object getMetadata(java.lang.Class storingClass, java.lang.String key)
          Returns a stored data object for a plug in or a value handler
 Node getNode()
           
 java.lang.Object getValue(Context context)
          Calls the chain of value handlers to return the indexed value of the node
 boolean hasValue(Context context)
          Calls the chain of value handlers to test whether this node has a value
 void notifyChildrenOfSourceValueChange()
          This method notifies all of this node's children that their source value has changed.
protected  void notifyChildValueChanged(java.lang.String childKey)
          Called by a node that depends on this node that its value has changed.
 void notifySourcesOfChildValueChange()
          This method notifies all of this node's sources that this node's value has changed.
protected  void notifySourceValueChanged(java.lang.String sourceKey)
          Called by a source node when it's value has changed.
 java.lang.Object removeMetadata(java.lang.Class storingClass, java.lang.String key)
          Removes a data object for a plug in or a value handler.
 void setMetadata(java.lang.Class storingClass, java.lang.String key, java.lang.Object value)
          Stores a data object for a plug in or a value handler.
 void setValue(Context context, java.lang.Object value)
          Calls the chain of value handlers to set the (indexed) value of the node
 void startNodeValueChangedNotification()
          Starts the notification across the node graph that this node's value has been changed.
 void stopNotification()
          Temporary stops the notification of changes.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getKey

public java.lang.String getKey()
Description copied from interface: NodeController
Shortcut für NodeController.getNode().Node.getKey().

Specified by:
getKey in interface NodeController
Returns:
the key for this node
See Also:
NodeController.getKey()

getNode

public Node getNode()
Specified by:
getNode in interface NodeController
Returns:
the node that defines the value of this NodeController.
See Also:
NodeController.getNode()

getDataCore

public DataCore getDataCore()
Specified by:
getDataCore in interface NodeController
Returns:
the data core that this node is installed in
See Also:
NodeController.getDataCore()

getMetadata

public java.lang.Object getMetadata(java.lang.Class storingClass,
                                    java.lang.String key)
Description copied from interface: NodeController
Returns a stored data object for a plug in or a value handler

Specified by:
getMetadata in interface NodeController
Parameters:
storingClass - the class that the data object has been stored for
key - the key under which the data object has been stored
Returns:
the data object, may be null if no such key exists
See Also:
NodeController.getMetadata(java.lang.Class, java.lang.String)

setMetadata

public void setMetadata(java.lang.Class storingClass,
                        java.lang.String key,
                        java.lang.Object value)
Description copied from interface: NodeController
Stores a data object for a plug in or a value handler.

Specified by:
setMetadata in interface NodeController
Parameters:
storingClass - the class that the data object has been stored for
key - the key under which the data object should be stored
value - the data object
See Also:
NodeController.setMetadata(java.lang.Class, java.lang.String, java.lang.Object)

removeMetadata

public java.lang.Object removeMetadata(java.lang.Class storingClass,
                                       java.lang.String key)
Description copied from interface: NodeController
Removes a data object for a plug in or a value handler.

Specified by:
removeMetadata in interface NodeController
Parameters:
storingClass - the class that the data object has been stored for
key - the key under which the data object has been stored
Returns:
the data object, may be null if no such key exists
See Also:
NodeController.removeMetadata(java.lang.Class, java.lang.String)

addValueHandler

public void addValueHandler(ValueHandler valueHandler)
Description copied from interface: NodeController
Adds a ValueHandler to the list of value handlers in this node.

These value handlers will be called in the reverse order they have been registered.

Node that a value handler may only be added while the node is being registered.

Important

: The first value handler to be added, which is the last value handler to be called, must take responsibility for storing and retrieving the value in accordance to the structure description defined by Node.

Specified by:
addValueHandler in interface NodeController
See Also:
NodeController.addValueHandler(com.sdm.quasar.client.core.data.plugin.ValueHandler)

getValue

public java.lang.Object getValue(Context context)
Description copied from interface: NodeController
Calls the chain of value handlers to return the indexed value of the node

Specified by:
getValue in interface NodeController
Parameters:
context - the context to resolve the indices
Returns:
the indexed value of the node
See Also:
NodeController.getValue(com.sdm.quasar.client.core.data.Context)

setValue

public void setValue(Context context,
                     java.lang.Object value)
Description copied from interface: NodeController
Calls the chain of value handlers to set the (indexed) value of the node

Specified by:
setValue in interface NodeController
Parameters:
context - the context to resolve the indices
value - the value of the node
See Also:
NodeController.setValue(com.sdm.quasar.client.core.data.Context, java.lang.Object)

getIndexSet

public java.util.Set getIndexSet(Context context)
Description copied from interface: NodeController
Calls the chain of value handlers to return a Set of the index values for the node. The method returns null for not indexed nodes.

Specified by:
getIndexSet in interface NodeController
Parameters:
context - the context to resolve the indices
Returns:
A Set of the index values for the node or null.
See Also:
NodeController.getIndexSet(com.sdm.quasar.client.core.data.Context)

hasValue

public boolean hasValue(Context context)
Description copied from interface: NodeController
Calls the chain of value handlers to test whether this node has a value

Specified by:
hasValue in interface NodeController
Parameters:
context - the context to resolve the indices
Returns:
true if the node does have a value
See Also:
NodeController.hasValue(com.sdm.quasar.client.core.data.Context)

canModifyValue

public boolean canModifyValue(Context context)
Description copied from interface: NodeController
Calls the chain of value handlers to test whether the value of this node can be modified

Specified by:
canModifyValue in interface NodeController
Returns:
true if the value can be modified
See Also:
NodeController.canModifyValue(com.sdm.quasar.client.core.data.Context)

notifySourceValueChanged

protected void notifySourceValueChanged(java.lang.String sourceKey)
Called by a source node when it's value has changed. First all value handlers on this node are notified by using ValueHandler.notifySourceValueChanged(NodeController,String), then all nodes that depend on this node are notified that their source has changed.

Parameters:
sourceKey - the key of the source node whose value has changed

notifyChildValueChanged

protected void notifyChildValueChanged(java.lang.String childKey)
Called by a node that depends on this node that its value has changed. All value handlers on this node are notified by using ValueHandler.notifyChildValueChanged(NodeController,String). This notification is propagated further "up" the dependency graph to the nodes that this node depends on.

Parameters:
childKey - the key of the child node whose value has changed

continueNodeValueChangedNotification

public void continueNodeValueChangedNotification()
Description copied from interface: NodeController
Continues the notification across the node graph that this node's value has been changed. The nodes that this node depends on are notified that their child has changed. Then it notifies the dependent nodes that their source value has changed.

Specified by:
continueNodeValueChangedNotification in interface NodeController
See Also:
NodeController.continueNodeValueChangedNotification()

notifySourcesOfChildValueChange

public void notifySourcesOfChildValueChange()
Description copied from interface: NodeController
This method notifies all of this node's sources that this node's value has changed.

Specified by:
notifySourcesOfChildValueChange in interface NodeController
See Also:
NodeController.notifySourcesOfChildValueChange()

notifyChildrenOfSourceValueChange

public void notifyChildrenOfSourceValueChange()
Description copied from interface: NodeController
This method notifies all of this node's children that their source value has changed.

Specified by:
notifyChildrenOfSourceValueChange in interface NodeController
See Also:
NodeController.notifyChildrenOfSourceValueChange()

stopNotification

public void stopNotification()
Description copied from interface: NodeController
Temporary stops the notification of changes. Changes are no longer propagated through the hierarchy.

Important: When calling this method you must ensure that the corresponding NodeController.allowNotification() will be called even in case of an error by using try ... finally.

Specified by:
stopNotification in interface NodeController
See Also:
NodeController.stopNotification()

allowNotification

public void allowNotification()
Description copied from interface: NodeController
Allows notification of changes.

Important: After calling this method the caller must start an appropriate notification.

Specified by:
allowNotification in interface NodeController
See Also:
NodeController.allowNotification()

startNodeValueChangedNotification

public void startNodeValueChangedNotification()
Description copied from interface: NodeController
Starts the notification across the node graph that this node's value has been changed. First all value handlers of this node are notified that this node's value has changed. Then nodes that this node depends on are notified that their child has changed. Then it notifies the dependent nodes that their source value has changed.

This notification may also be used to notify the node that the value has been changed by means outside the control of the data store.

Specified by:
startNodeValueChangedNotification in interface NodeController
See Also:
NodeController.startNodeValueChangedNotification()

getDependentNodes

public java.util.List getDependentNodes()
Specified by:
getDependentNodes in interface NodeController
Returns:
the keys of the nodes that depend on this node in the order they are notified
See Also:
NodeController.getDependentNodes()

dispose

protected void dispose()

toString

public java.lang.String toString()

collectSystemInfo

public void collectSystemInfo(SystemInfoNode root,
                              SystemInfoOptions options)
Description copied from interface: SystemInfoProvider
Builds the system information tree upon local information of the implementor. The system information tree can be used within development by inspecting the system; so implementors should append their internal state (depending on the details settings within SystemInfoOptions). The information can be appended to the tree by adding new child SystemInformationNodes to the root node given using the SystemInfoNode.createChild(String) method and by setting information attributes the these nodes or the given root node.

Specified by:
collectSystemInfo in interface SystemInfoProvider
Parameters:
root - the SystemInfoNode to add information to (guaranteed to be not null)
options - contains additional options, that might influence the amount of information added to the tree (guaranteed to be not null)
See Also:
SystemInfoProvider.collectSystemInfo(com.sdm.quasar.client.core.common.sysinfo.SystemInfoNode, com.sdm.quasar.client.core.common.sysinfo.SystemInfoOptions)