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

java.lang.Object
  extended by org.eclipse.ocl.examples.domain.library.AbstractFeature
      extended by org.eclipse.ocl.examples.domain.library.AbstractIteration
          extended by org.eclipse.ocl.examples.library.iterator.IterateIteration
All Implemented Interfaces:
LibraryFeature, LibraryIteration

public class IterateIteration
extends AbstractIteration

IterateIteration realizes the Collection::iterate() library iteration.


Field Summary
static IterateIteration INSTANCE
           
 
Constructor Summary
IterateIteration()
           
 
Method Summary
 Value createAccumulatorValue(DomainEvaluator evaluator, DomainType accumulatorType, DomainType bodyType)
          Create the value that will accumulate the iteration results.
 Value evaluateIteration(DomainIterationManager iterationManager)
          The default iteration algorithm steps through the iteration domain by invoking DomainIterationManager.hasCurrent() and DomainIterationManager.advanceIterators().
protected  Value updateAccumulator(DomainIterationManager 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.domain.library.AbstractIteration
resolveTerminalValue
 
Methods inherited from class org.eclipse.ocl.examples.domain.library.AbstractFeature
getLibraryValidator, getValidator
 
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.domain.library.LibraryFeature
getValidator
 

Field Detail

INSTANCE

public static final IterateIteration INSTANCE
Constructor Detail

IterateIteration

public IterateIteration()
Method Detail

createAccumulatorValue

public Value createAccumulatorValue(DomainEvaluator evaluator,
                                    DomainType accumulatorType,
                                    DomainType bodyType)
Description copied from interface: LibraryIteration
Create the value that will accumulate the iteration results.

Parameters:
evaluator - that supervises evaluation
Returns:
the accumulator

evaluateIteration

public Value evaluateIteration(DomainIterationManager iterationManager)
                        throws InvalidValueException
Description copied from class: AbstractIteration
The default iteration algorithm steps through the iteration domain by invoking DomainIterationManager.hasCurrent() and DomainIterationManager.advanceIterators(). At each step AbstractIteration.updateAccumulator(DomainIterationManager) is invoked to update the accumulator for that step. A non-null return causes a premature exit and forms the return from the overall evaluation. If all steps complete AbstractIteration.resolveTerminalValue(DomainIterationManager) is invoked to provide the return value.

Derived classes may override this method to change the iteration algorithm or override the call-backs to customize the default iteration.

Specified by:
evaluateIteration in interface LibraryIteration
Overrides:
evaluateIteration in class AbstractIteration
Parameters:
iterationManager - the iteration space
Returns:
the result
Throws:
InvalidValueException - if a body evaluates to invalid

updateAccumulator

protected Value updateAccumulator(DomainIterationManager 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
Parameters:
iterationManager - the iteration context
Returns:
non-null premature result of iteration, or null if complete