com.sdm.quasar.client.core.data.plugins.impl
Class AbstractIndexedValueHandler

java.lang.Object
  extended bycom.sdm.quasar.client.core.data.plugins.impl.AbstractIndexedValueHandler
All Implemented Interfaces:
ValueHandler
Direct Known Subclasses:
IndexedArrayValueHandler, IndexedListValueHandler, IndexedMapValueHandler

public abstract class AbstractIndexedValueHandler
extends java.lang.Object
implements ValueHandler

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

Constructor Summary
AbstractIndexedValueHandler()
           
 
Method Summary
 boolean canModifyValue(NodeController node, Context context, NestedValueHandler nestedValueHandler)
          Tests whether the value of the node can be modified. If the implementation takes responsability for the storing of the value it should determine the result on its own. Otherwise it should query the nested value handler using NestedValueHandler#canModifyValue(). Always returns false since the value can only be modified when using a context.
protected abstract  java.lang.Object getIndexedValue(java.lang.Object sourceValue, java.lang.Object indexValue)
          Template method to retrieve to value of the given index from the given source value.
 java.util.Set getIndexSet(NodeController node, Context context, NestedValueHandler nestedValueHandler)
          Retrieves a Set of the index values for the node.
protected abstract  java.util.Set getIndexSet(java.lang.Object sourceValue)
          Template method to retrieve the set of index values for the given source value.
 java.lang.Object getValue(NodeController node, Context context, NestedValueHandler nestedValueHandler)
          Retrieves the value of the node.
 boolean hasValue(NodeController node, Context context, NestedValueHandler nestedValueHandler)
          Tests whether the node has a indexed value.
 void notifyChildValueChanged(NodeController node, java.lang.String childKey)
          Called when the value of a node that depends on this node has changed. This implementation does nothing.
 void notifyNodeValueChanged(NodeController node)
          Called when the value of the node has changed because of a change originating at the given node. This implementation does nothing
 void notifySourceValueChanged(NodeController node, java.lang.String sourceKey)
          Called when the value of a node that the node depends on or an ancestor further removed has changed. This implenentation does nothing
protected abstract  void setIndexedValue(java.lang.Object sourceValue, java.lang.Object indexValue, NodeController node, java.lang.Object value)
          Template method to set a value for the given index at the given source value.
 void setValue(NodeController node, Context context, java.lang.Object value, NestedValueHandler nestedValueHandler)
          Sets the indexed value of the node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.sdm.quasar.client.core.data.plugin.ValueHandler
canHandle
 

Constructor Detail

AbstractIndexedValueHandler

public AbstractIndexedValueHandler()
Method Detail

getValue

public final java.lang.Object getValue(NodeController node,
                                       Context context,
                                       NestedValueHandler nestedValueHandler)
Description copied from interface: ValueHandler
Retrieves the value of the node. If this value handler does not take responsability for the storing of the value it must retrieve the value by using NestedValueHandler.getValue(Context).

Specified by:
getValue in interface ValueHandler
Parameters:
node - the concerned node
context - the context to resolve the indices
nestedValueHandler - the adapter to the next value handler in the chain of value handlers of that node
Returns:
the value of the node
See Also:
com.sdm.quasar.client.core.data.internal.impl.ValueHandler#getValue(com.sdm.quasar.client.core.data.internal.impl.NodeController, com.sdm.quasar.client.core.data.Context, com.sdm.quasar.client.core.data.internal.impl.NestedValueHandler)

getIndexedValue

protected abstract java.lang.Object getIndexedValue(java.lang.Object sourceValue,
                                                    java.lang.Object indexValue)
Template method to retrieve to value of the given index from the given source value. E.g. for a list the source value is the list and the index value is the Integer of index of the requested value. For am map the value is the map and the index value is the key of the requested value.

Parameters:
sourceValue - the source value of the node
indexValue - the index of the requested value
Returns:
value of the given index from the given source value

setValue

public final void setValue(NodeController node,
                           Context context,
                           java.lang.Object value,
                           NestedValueHandler nestedValueHandler)
Description copied from interface: ValueHandler
Sets the indexed value of the node. If it takes responsability for the storing of the value it must notify the node of the change if appropriate by using NodeController.startNodeValueChangedNotification(). If it does not take responsability it must notify the nested value handler using NestedValueHandler.setValue(Context, Object).

Specified by:
setValue in interface ValueHandler
Parameters:
node - the concerned node
context - the context to resolve the indices
value - the value to be set, may be null
nestedValueHandler - the adapter to the next value handler in the chain of value handlers of that node
See Also:
com.sdm.quasar.client.core.data.internal.impl.ValueHandler#setValue(com.sdm.quasar.client.core.data.internal.impl.NodeController, com.sdm.quasar.client.core.data.Context, java.lang.Object, com.sdm.quasar.client.core.data.internal.impl.NestedValueHandler)

setIndexedValue

protected abstract void setIndexedValue(java.lang.Object sourceValue,
                                        java.lang.Object indexValue,
                                        NodeController node,
                                        java.lang.Object value)
Template method to set a value for the given index at the given source value. E.g. for a list the source value is the list and the index value is the Integer of index of the requested value. For am map the value is the map and the index value is the key of the requested value.

Parameters:
sourceValue - the source value of the node
indexValue - the index of the requested value
node - the node controlle of the node
value - of the given index from the given source value

getIndexSet

public final java.util.Set getIndexSet(NodeController node,
                                       Context context,
                                       NestedValueHandler nestedValueHandler)
Description copied from interface: ValueHandler
Retrieves a Set of the index values for the node. If this value handler does not take responsability for the storing of the value it must retrieve the set by using NestedValueHandler.getIndexSet(com.sdm.quasar.client.core.data.Context).

Specified by:
getIndexSet in interface ValueHandler
Parameters:
node - the concerned node
context - the context to resolve the indices
nestedValueHandler - the adapter to the next value handler
Returns:
A Set of the index values for the node or null.
See Also:
com.sdm.quasar.client.core.data.internal.impl.ValueHandler#getIndexSet(com.sdm.quasar.client.core.data.internal.impl.NodeController, com.sdm.quasar.client.core.data.Context, com.sdm.quasar.client.core.data.internal.impl.NestedValueHandler)

getIndexSet

protected abstract java.util.Set getIndexSet(java.lang.Object sourceValue)
Template method to retrieve the set of index values for the given source value.

Parameters:
sourceValue - the source value of the node
Returns:
set of index values for the given source value or null

canModifyValue

public boolean canModifyValue(NodeController node,
                              Context context,
                              NestedValueHandler nestedValueHandler)
Tests whether the value of the node can be modified. If the implementation takes responsability for the storing of the value it should determine the result on its own. Otherwise it should query the nested value handler using NestedValueHandler#canModifyValue(). Always returns false since the value can only be modified when using a context.

Specified by:
canModifyValue in interface ValueHandler
Parameters:
node - the concerned node
context - the context to resolve the indices
nestedValueHandler - the adapter to the next value handler
Returns:
true iff the value of the node has a value
See Also:
com.sdm.quasar.client.core.data.internal.impl.ValueHandler#canModifyValue(com.sdm.quasar.client.core.data.internal.impl.NodeController, com.sdm.quasar.client.core.data.Context, com.sdm.quasar.client.core.data.internal.impl.NestedValueHandler)

hasValue

public boolean hasValue(NodeController node,
                        Context context,
                        NestedValueHandler nestedValueHandler)
Description copied from interface: ValueHandler
Tests whether the node has a indexed value. If the implementation takes responsability for the storing of the value it should determine the result on its own. Otherwise it should query the nested value handler using NestedValueHandler#hasValue().

Specified by:
hasValue in interface ValueHandler
Parameters:
node - the concerned node
context - the context to resolve the indices
nestedValueHandler - the adapter to the next value handler
Returns:
true iff the node has a value
See Also:
com.sdm.quasar.client.core.data.internal.impl.ValueHandler#hasValue(com.sdm.quasar.client.core.data.internal.impl.NodeController, com.sdm.quasar.client.core.data.Context, com.sdm.quasar.client.core.data.internal.impl.NestedValueHandler)

notifyNodeValueChanged

public void notifyNodeValueChanged(NodeController node)
Called when the value of the node has changed because of a change originating at the given node. This implementation does nothing

Specified by:
notifyNodeValueChanged in interface ValueHandler
Parameters:
node - the node whose value has changed
See Also:
com.sdm.quasar.client.core.data.internal.impl.ValueHandler#notifyNodeValueChanged(com.sdm.quasar.client.core.data.internal.impl.NodeController)

notifyChildValueChanged

public void notifyChildValueChanged(NodeController node,
                                    java.lang.String childKey)
Called when the value of a node that depends on this node has changed. This implementation does nothing.

Specified by:
notifyChildValueChanged in interface ValueHandler
Parameters:
node - the node that is notified
childKey - the key of the child node whose value has changed
See Also:
com.sdm.quasar.client.core.data.internal.impl.ValueHandler#notifyChildValueChanged(com.sdm.quasar.client.core.data.internal.impl.NodeController, java.lang.String)

notifySourceValueChanged

public void notifySourceValueChanged(NodeController node,
                                     java.lang.String sourceKey)
Called when the value of a node that the node depends on or an ancestor further removed has changed. This implenentation does nothing

Specified by:
notifySourceValueChanged in interface ValueHandler
Parameters:
node - the node that is notified
sourceKey - the key of the source node whose value has changed
See Also:
com.sdm.quasar.client.core.data.internal.impl.ValueHandler#notifySourceValueChanged(com.sdm.quasar.client.core.data.internal.impl.NodeController, String)