com.sdm.quasar.client.core.data.structure
Class ContextNodeComputation

java.lang.Object
  extended bycom.sdm.quasar.client.core.data.structure.ContextNodeComputation
All Implemented Interfaces:
Computation

public class ContextNodeComputation
extends java.lang.Object
implements Computation

Provides a Computation to be used in a ComputedNode that uses an index value taken from a Node to access an IndexedNode.

This implementation requires two source values:

  1. The index value to be used. This must be a value of correct type for use as an index in the IndexedNode. A value of null or an index that is not available will result in a null return value
  2. The value of the indexed node. This must come from an indexed node that is capable of using the index provided by the index value.

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

Constructor Summary
ContextNodeComputation(IndexedNode indexedNode)
          Constructor that takes the configuration from a given indexed node.
 
Method Summary
 java.util.Set computeIndexSet(ComputationValueAccess sourceValuesAccess, Context context)
          Performs the computation of a Set of the index values.
 java.lang.Object computeValue(ComputationValueAccess sourceValuesAccess, Context context)
          Performs the computation with an context. Takes the current index value from the first source while using the given context and adds the index value to the context for accessing the second source (the IndexedNode).
 java.lang.Class[] getSourceTypes()
          Returns an array with two values: the index type #indexType the type of the indexed node #type
 java.lang.Class getType()
           
 void reverseValueComputation(java.lang.Object targetValue, ComputationValueAccess sourceValuesAccess, Context context)
          Perform a reverse computation computes the correct source values with respect to the target value with a context. The resulting new source values must be set using the ComputationValueAccess. Takes the current index value from the first source and uses it to build a Context for accessing the second source (the IndexedNode).
 boolean supportsReverse()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContextNodeComputation

public ContextNodeComputation(IndexedNode indexedNode)
Constructor that takes the configuration from a given indexed node.

Parameters:
indexedNode - the indexed node that this ContextNodeComputation accesses.
Method Detail

getType

public java.lang.Class getType()
Specified by:
getType in interface Computation
Returns:
the type of the result that this computation produces

getSourceTypes

public java.lang.Class[] getSourceTypes()
Returns an array with two values:
  1. the index type #indexType
  2. the type of the indexed node #type

Specified by:
getSourceTypes in interface Computation
Returns:
the types of the source values that this compuatation expects
See Also:
Computation.getSourceTypes()

computeValue

public java.lang.Object computeValue(ComputationValueAccess sourceValuesAccess,
                                     Context context)
Performs the computation with an context. Takes the current index value from the first source while using the given context and adds the index value to the context for accessing the second source (the IndexedNode).

Specified by:
computeValue in interface Computation
Parameters:
sourceValuesAccess - the access source values
context - the context to be used
Returns:
the result
See Also:
Computation.computeValue(com.sdm.quasar.client.core.data.structure.ComputationValueAccess, com.sdm.quasar.client.core.data.Context)

supportsReverse

public boolean supportsReverse()
Specified by:
supportsReverse in interface Computation
Returns:
true
See Also:
Computation.supportsReverse()

reverseValueComputation

public void reverseValueComputation(java.lang.Object targetValue,
                                    ComputationValueAccess sourceValuesAccess,
                                    Context context)
Perform a reverse computation computes the correct source values with respect to the target value with a context. The resulting new source values must be set using the ComputationValueAccess. Takes the current index value from the first source and uses it to build a Context for accessing the second source (the IndexedNode).

Specified by:
reverseValueComputation in interface Computation
Parameters:
targetValue - the target value
sourceValuesAccess - the access current source values
context - the context to be used
See Also:
Computation.reverseValueComputation(java.lang.Object, com.sdm.quasar.client.core.data.structure.ComputationValueAccess, com.sdm.quasar.client.core.data.Context)

computeIndexSet

public java.util.Set computeIndexSet(ComputationValueAccess sourceValuesAccess,
                                     Context context)
Description copied from interface: Computation
Performs the computation of a Set of the index values. The method returns null for not indexed nodes.

Specified by:
computeIndexSet in interface Computation
Parameters:
sourceValuesAccess - the access source values
context - the context to be used
Returns:
a Set of the index values or null
See Also:
Computation.computeIndexSet(com.sdm.quasar.client.core.data.structure.ComputationValueAccess, com.sdm.quasar.client.core.data.Context)