org.eclipse.ocl.examples.library.iterator
Class OneIteration

java.lang.Object
  extended by org.eclipse.ocl.examples.library.AbstractFeature
      extended by org.eclipse.ocl.examples.library.AbstractIteration<CollectionValue.Accumulator>
          extended by org.eclipse.ocl.examples.library.iterator.OneIteration
All Implemented Interfaces:
LibraryFeature, LibraryIteration, CallableImplementation

public class OneIteration
extends AbstractIteration<CollectionValue.Accumulator>

OneIteration realises the Collection::one() library iteration.

Since:
3.1

Field Summary
static OneIteration INSTANCE
           
 
Constructor Summary
OneIteration()
           
 
Method Summary
 Value evaluate(EvaluationVisitor evaluationVisitor, CollectionValue sourceVal, LoopExp iteratorExp)
          Return the result of evaluating iterationCall upon sourceVal within the environment provided by EvaluationVisitor.
protected  Value resolveTerminalValue(IterationManager<CollectionValue.Accumulator> iterationManager)
          Return the value appropriate to an iteration over all the source elements.
protected  Value updateAccumulator(IterationManager<CollectionValue.Accumulator> iterationManager)
          Update the accumulatorValue with the bodyValue resulting from the current iteration for which the iterators define the context in the environment.
 
Methods inherited from class org.eclipse.ocl.examples.library.AbstractIteration
createAccumulationValue, evaluate, evaluateIteration
 
Methods inherited from class org.eclipse.ocl.examples.library.AbstractFeature
validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.ocl.examples.pivot.evaluation.CallableImplementation
validate
 

Field Detail

INSTANCE

public static final OneIteration INSTANCE
Constructor Detail

OneIteration

public OneIteration()
Method Detail

evaluate

public Value evaluate(EvaluationVisitor evaluationVisitor,
                      CollectionValue sourceVal,
                      LoopExp iteratorExp)
Description copied from interface: LibraryIteration
Return the result of evaluating iterationCall upon sourceVal within the environment provided by EvaluationVisitor. An invalid return may be indicated by throwing an exception returning Java null or OCL invalid.

Parameters:
evaluationVisitor - the evaluation context
sourceVal - the source operand for the operation
iteratorExp - the iteration and additional arguments
Returns:
the evaluated value

resolveTerminalValue

protected Value resolveTerminalValue(IterationManager<CollectionValue.Accumulator> iterationManager)
Description copied from class: AbstractIteration
Return the value appropriate to an iteration over all the source elements. The default implementation just returns the accumulator. Derived iterations should override.

Overrides:
resolveTerminalValue in class AbstractIteration<CollectionValue.Accumulator>
Parameters:
iterationManager - the iteration context
Returns:

updateAccumulator

protected Value updateAccumulator(IterationManager<CollectionValue.Accumulator> iterationManager)
Description copied from class: AbstractIteration
Update the accumulatorValue with the bodyValue resulting from the current iteration for which the iterators define the context in the environment.

Specified by:
updateAccumulator in class AbstractIteration<CollectionValue.Accumulator>
Parameters:
iterationManager - the iteration context
Returns:
non-null premature result of iteration, or null if complete