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

java.lang.Object
  extended bycom.sdm.quasar.client.core.data.plugin.AbstractDataManagerPlugIn
      extended bycom.sdm.quasar.client.core.data.plugins.impl.DefaultValueChangedPlugIn
All Implemented Interfaces:
DataManagerPlugIn, Disposable, ValueChangedPlugIn

public class DefaultValueChangedPlugIn
extends AbstractDataManagerPlugIn
implements ValueChangedPlugIn

Note: this is a first draft! - it probably compares the values way too often - does not work if an indexed nodes is asked or it is in the recursion - is comparator the right thing? We need only an equals, not an order (int)


Constructor Summary
DefaultValueChangedPlugIn()
           
 
Method Summary
protected  java.util.Comparator getComparator(NodeController node)
          Returns the Comparator set in the node or null if none has been set.
protected  java.lang.Object getReferenceValue(NodeController node)
          Returns the reference value
 BooleanState getValueChangedState(java.lang.String key)
          Returns the state that is true if the value of the given node has changed (according to the comparator) from the time saveReferenceValues(String) was called last for the node.
protected  MutableBooleanState getValueChangedStateInternal(NodeController node)
          Returns the MutableBooleanState stored in the metadata of the node that is true if this node's value has changed according to the comparator.
 BooleanState getValuesChangedState(java.lang.String startKey)
          Returns the state that is true if any value in the subtree starting at the given node has changed (according to the comparator) from the time saveReferenceValues(String) was called last for the nodes.
protected  ORBooleanState getValuesChangedStateInternal(NodeController node)
          Returns the ORBooleanState stored in the metadata of the node that is true if this node's value has changed according to the comparator or any of its children in the tree.
 void notifyExternalChange(java.lang.String key)
          Notify the node that its value has been changed by means outside the control of the data store.
protected  void notifyNodeAdded(NodeController node)
          Called by the DataCore when a node has been added.
protected  void notifyNodeWillBeRemoved(NodeController node)
          Called by the DataCore before a node will be removed.
 void saveReferenceValues(java.lang.String startKey)
          Saves the reference values for the subtree starting at the given node.
 void setComparator(java.lang.String key, java.util.Comparator comparator)
          Sets the comparator to be used
 void setDefaultComparator(java.util.Comparator defaultComparator)
          Sets the default comparator to be used, if no comparator has been specified for the node.
 
Methods inherited from class com.sdm.quasar.client.core.data.plugin.AbstractDataManagerPlugIn
dispose, getDataCore, install
 
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.DataManagerPlugIn
install
 
Methods inherited from interface com.sdm.quasar.client.core.common.Disposable
dispose
 

Constructor Detail

DefaultValueChangedPlugIn

public DefaultValueChangedPlugIn()
Method Detail

notifyNodeAdded

protected void notifyNodeAdded(NodeController node)
Description copied from class: AbstractDataManagerPlugIn
Called by the DataCore when a node has been added. The implementation may register value handlers for the new node.

Specified by:
notifyNodeAdded in class AbstractDataManagerPlugIn
Parameters:
node - the node that has been added

notifyNodeWillBeRemoved

protected void notifyNodeWillBeRemoved(NodeController node)
Description copied from class: AbstractDataManagerPlugIn
Called by the DataCore before a node will be removed.

Specified by:
notifyNodeWillBeRemoved in class AbstractDataManagerPlugIn
Parameters:
node - the key of the node that will be removed.

getValueChangedState

public BooleanState getValueChangedState(java.lang.String key)
Description copied from interface: ValueChangedPlugIn
Returns the state that is true if the value of the given node has changed (according to the comparator) from the time ValueChangedPlugIn.saveReferenceValues(String) was called last for the node.

Specified by:
getValueChangedState in interface ValueChangedPlugIn
Parameters:
key -
Returns:

getValuesChangedState

public BooleanState getValuesChangedState(java.lang.String startKey)
Description copied from interface: ValueChangedPlugIn
Returns the state that is true if any value in the subtree starting at the given node has changed (according to the comparator) from the time ValueChangedPlugIn.saveReferenceValues(String) was called last for the nodes.

Specified by:
getValuesChangedState in interface ValueChangedPlugIn
Parameters:
startKey -
Returns:

saveReferenceValues

public void saveReferenceValues(java.lang.String startKey)
Description copied from interface: ValueChangedPlugIn
Saves the reference values for the subtree starting at the given node.

Specified by:
saveReferenceValues in interface ValueChangedPlugIn
Parameters:
startKey -

setComparator

public void setComparator(java.lang.String key,
                          java.util.Comparator comparator)
Description copied from interface: ValueChangedPlugIn
Sets the comparator to be used

Specified by:
setComparator in interface ValueChangedPlugIn
Parameters:
key -

setDefaultComparator

public void setDefaultComparator(java.util.Comparator defaultComparator)
Description copied from interface: ValueChangedPlugIn
Sets the default comparator to be used, if no comparator has been specified for the node. If not set, the default is an equals from the reference value to the current value

Specified by:
setDefaultComparator in interface ValueChangedPlugIn
Parameters:
defaultComparator -

getValueChangedStateInternal

protected MutableBooleanState getValueChangedStateInternal(NodeController node)
Returns the MutableBooleanState stored in the metadata of the node that is true if this node's value has changed according to the comparator.

Parameters:
node - the node
Returns:
the state

getValuesChangedStateInternal

protected ORBooleanState getValuesChangedStateInternal(NodeController node)
Returns the ORBooleanState stored in the metadata of the node that is true if this node's value has changed according to the comparator or any of its children in the tree.

Parameters:
node - the node
Returns:
the state

getComparator

protected java.util.Comparator getComparator(NodeController node)
Returns the Comparator set in the node or null if none has been set.

Parameters:
node - the node
Returns:
the comparator

getReferenceValue

protected java.lang.Object getReferenceValue(NodeController node)
Returns the reference value

Parameters:
node - the node
Returns:
the reference value

notifyExternalChange

public void notifyExternalChange(java.lang.String key)
Description copied from interface: ValueChangedPlugIn
Notify the node that its value has been changed by means outside the control of the data store.

Specified by:
notifyExternalChange in interface ValueChangedPlugIn