org.eclipse.ocl.examples.pivot.evaluation
Class AbstractEvaluationVisitor

java.lang.Object
  extended by org.eclipse.ocl.examples.pivot.util.AbstractVisitor<R,C>
      extended by org.eclipse.ocl.examples.pivot.util.AbstractExtendingVisitor<Value,java.lang.Object>
          extended by org.eclipse.ocl.examples.pivot.evaluation.AbstractEvaluationVisitor
All Implemented Interfaces:
EvaluationVisitor, Visitor<Value,java.lang.Object>
Direct Known Subclasses:
EvaluationVisitorImpl

public abstract class AbstractEvaluationVisitor
extends AbstractExtendingVisitor<Value,java.lang.Object>
implements EvaluationVisitor

An evaluation visitor implementation for OCL expressions.

Note that this class is not intended to be used or extended by clients. Use the AbstractEvaluationVisitor interface, instead.

See the Environment class for a description of the generic type parameters of this class.

Author:
Tim Klinger (tklinger), Christian W. Damus (cdamus)

Field Summary
protected  Environment environment
           
protected  EvaluationEnvironment evaluationEnvironment
           
protected  ModelManager modelManager
           
protected  TypeManager typeManager
           
protected  ValueFactory valueFactory
           
 
Fields inherited from class org.eclipse.ocl.examples.pivot.util.AbstractVisitor
context
 
Constructor Summary
protected AbstractEvaluationVisitor(Environment env, EvaluationEnvironment evalEnv, ModelManager modelManager)
          Initializes me.
 
Method Summary
 Environment getEnvironment()
          Obtains the environment that provides the metamodel semantics for the expression to be evaluated.
 EvaluationEnvironment getEvaluationEnvironment()
          Obtains the evaluation environment that keeps track of variable values and knows how to call operations, navigate properties, etc.
 ModelManager getModelManager()
          Obtains the mapping of model classes to their extents.
 TypeManager getTypeManager()
           
protected  EvaluationVisitor getUndecoratedVisitor()
          Obtains the visitor on which I perform nested Visitable#accept(org.eclipse.ocl.utilities.Visitor) calls.
 ValueFactory getValueFactory()
           
protected  EvaluationVisitor getVisitor()
          Deprecated. use getUndecoratedVisitor()
 void setUndecoratedVisitor(EvaluationVisitor evaluationVisitor)
          Sets the visitor on which I perform nested Visitable#accept(org.eclipse.ocl.utilities.Visitor) calls.
 NullValue throwInvalidEvaluation(InvalidValueException e)
           
 NullValue throwInvalidEvaluation(java.lang.String message)
           
 NullValue throwInvalidEvaluation(java.lang.Throwable e, OclExpression expression, java.lang.Object value, java.lang.String message, java.lang.Object... bindings)
           
 java.lang.String toString()
           
 Value visitConstraint(Constraint constraint)
          This default implementation asserts that the constraint is boolean-valued if it is an invariant, pre-condition, or post-condition constraint and returns the value of its body expression by delegation to #visitExpression(OCLExpression).
 
Methods inherited from class org.eclipse.ocl.examples.pivot.util.AbstractExtendingVisitor
visitAnnotation, visitAnyType, visitAssociationClass, visitAssociationClassCallExp, visitBagType, visitBooleanLiteralExp, visitCallExp, visitCallOperationAction, visitClass, visitClassifierType, visitCollectionItem, visitCollectionLiteralExp, visitCollectionLiteralPart, visitCollectionRange, visitCollectionType, visitComment, visitDataType, visitDetail, visitElement, visitEnumeration, visitEnumerationLiteral, visitEnumLiteralExp, visitExpressionInOcl, visitFeature, visitFeatureCallExp, visitIfExp, visitIntegerLiteralExp, visitInvalidLiteralExp, visitInvalidType, visitIterateExp, visitIteration, visitIteratorExp, visitLambdaType, visitLetExp, visitLibrary, visitLiteralExp, visitLoopExp, visitMessageExp, visitMessageType, visitMonikeredElement, visitMultiplicityElement, visitNamedElement, visitNamespace, visitNavigationCallExp, visitNullLiteralExp, visitNumericLiteralExp, visitOclExpression, visitOpaqueExpression, visitOperation, visitOperationCallExp, visitOperationTemplateParameter, visitOrderedSetType, visitPackage, visitPackageableElement, visitParameter, visitParameterableElement, visitPrecedence, visitPrimitiveLiteralExp, visitPrimitiveType, visitProperty, visitPropertyCallExp, visitRealLiteralExp, visitSendSignalAction, visitSequenceType, visitSetType, visitSignal, visitState, visitStateExp, visitStringLiteralExp, visitTemplateableElement, visitTemplateBinding, visitTemplateParameter, visitTemplateParameterSubstitution, visitTemplateParameterType, visitTemplateSignature, visitTupleLiteralExp, visitTupleLiteralPart, visitTupleType, visitType, visitTypedElement, visitTypedMultiplicityElement, visitTypeExp, visitTypeTemplateParameter, visitUnlimitedNaturalLiteralExp, visitUnspecifiedType, visitUnspecifiedValueExp, visitValueSpecification, visitVariable, visitVariableDeclaration, visitVariableExp, visitVoidType
 
Methods inherited from class org.eclipse.ocl.examples.pivot.util.AbstractVisitor
getAdapter, safeVisit, visit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.eclipse.ocl.examples.pivot.evaluation.EvaluationVisitor
createNestedVisitor
 
Methods inherited from interface org.eclipse.ocl.examples.pivot.util.Visitor
getAdapter, visitAnnotation, visitAnyType, visitAssociationClass, visitAssociationClassCallExp, visitBagType, visitBooleanLiteralExp, visitCallExp, visitCallOperationAction, visitClass, visitClassifierType, visitCollectionItem, visitCollectionLiteralExp, visitCollectionLiteralPart, visitCollectionRange, visitCollectionType, visitComment, visitDataType, visitDetail, visitElement, visitEnumeration, visitEnumerationLiteral, visitEnumLiteralExp, visitExpressionInOcl, visitFeature, visitFeatureCallExp, visitIfExp, visiting, visitIntegerLiteralExp, visitInvalidLiteralExp, visitInvalidType, visitIterateExp, visitIteration, visitIteratorExp, visitLambdaType, visitLetExp, visitLibrary, visitLiteralExp, visitLoopExp, visitMessageExp, visitMessageType, visitMonikeredElement, visitMultiplicityElement, visitNamedElement, visitNamespace, visitNavigationCallExp, visitNullLiteralExp, visitNumericLiteralExp, visitOclExpression, visitOpaqueExpression, visitOperation, visitOperationCallExp, visitOperationTemplateParameter, visitOrderedSetType, visitPackage, visitPackageableElement, visitParameter, visitParameterableElement, visitPrecedence, visitPrimitiveLiteralExp, visitPrimitiveType, visitProperty, visitPropertyCallExp, visitRealLiteralExp, visitSendSignalAction, visitSequenceType, visitSetType, visitSignal, visitState, visitStateExp, visitStringLiteralExp, visitTemplateableElement, visitTemplateBinding, visitTemplateParameter, visitTemplateParameterSubstitution, visitTemplateParameterType, visitTemplateSignature, visitTupleLiteralExp, visitTupleLiteralPart, visitTupleType, visitType, visitTypedElement, visitTypedMultiplicityElement, visitTypeExp, visitTypeTemplateParameter, visitUnlimitedNaturalLiteralExp, visitUnspecifiedType, visitUnspecifiedValueExp, visitValueSpecification, visitVariable, visitVariableDeclaration, visitVariableExp, visitVoidType
 

Field Detail

evaluationEnvironment

protected final EvaluationEnvironment evaluationEnvironment

environment

protected final Environment environment

typeManager

protected final TypeManager typeManager

modelManager

protected final ModelManager modelManager

valueFactory

protected final ValueFactory valueFactory
Constructor Detail

AbstractEvaluationVisitor

protected AbstractEvaluationVisitor(Environment env,
                                    EvaluationEnvironment evalEnv,
                                    ModelManager modelManager)
Initializes me.

Parameters:
env - the current environment
evalEnv - an evaluation environment (map of variable names to values)
modelManager - a map of classes to their instance sets
Method Detail

getEnvironment

public Environment getEnvironment()
Description copied from interface: EvaluationVisitor
Obtains the environment that provides the metamodel semantics for the expression to be evaluated.

Specified by:
getEnvironment in interface EvaluationVisitor
Returns:
the environment

getEvaluationEnvironment

public EvaluationEnvironment getEvaluationEnvironment()
Description copied from interface: EvaluationVisitor
Obtains the evaluation environment that keeps track of variable values and knows how to call operations, navigate properties, etc.

Specified by:
getEvaluationEnvironment in interface EvaluationVisitor
Returns:
the evaluation environment

getModelManager

public ModelManager getModelManager()
Description copied from interface: EvaluationVisitor
Obtains the mapping of model classes to their extents.

Specified by:
getModelManager in interface EvaluationVisitor
Returns:
the model manager

getTypeManager

public TypeManager getTypeManager()
Specified by:
getTypeManager in interface EvaluationVisitor

getUndecoratedVisitor

protected final EvaluationVisitor getUndecoratedVisitor()
Obtains the visitor on which I perform nested Visitable#accept(org.eclipse.ocl.utilities.Visitor) calls. This handles the case in which I am decorated by another visitor that must intercept every visitXxx() method. If I internally just recursively visit myself, then this decorator is cut out of the picture.

Returns:
my delegate visitor, which may be my own self or some other

getValueFactory

public ValueFactory getValueFactory()
Specified by:
getValueFactory in interface EvaluationVisitor

getVisitor

@Deprecated
protected final EvaluationVisitor getVisitor()
Deprecated. use getUndecoratedVisitor()

Obtains the visitor on which I perform nested Visitable#accept(org.eclipse.ocl.utilities.Visitor) calls. This handles the case in which I am decorated by another visitor that must intercept every visitXxx() method. If I internally just recursively visit myself, then this decorator is cut out of the picture.

Returns:
my delegate visitor, which may be my own self or some other

setUndecoratedVisitor

public void setUndecoratedVisitor(EvaluationVisitor evaluationVisitor)
Sets the visitor on which I perform nested Visitable#accept(org.eclipse.ocl.utilities.Visitor) calls.

Specified by:
setUndecoratedVisitor in interface EvaluationVisitor
Parameters:
visitor - my delegate visitor
See Also:
getUndecoratedVisitor()

throwInvalidEvaluation

public NullValue throwInvalidEvaluation(java.lang.String message)
                                 throws InvalidEvaluationException
Specified by:
throwInvalidEvaluation in interface EvaluationVisitor
Throws:
InvalidEvaluationException

throwInvalidEvaluation

public NullValue throwInvalidEvaluation(InvalidValueException e)
                                 throws InvalidEvaluationException
Specified by:
throwInvalidEvaluation in interface EvaluationVisitor
Throws:
InvalidEvaluationException

throwInvalidEvaluation

public NullValue throwInvalidEvaluation(java.lang.Throwable e,
                                        OclExpression expression,
                                        java.lang.Object value,
                                        java.lang.String message,
                                        java.lang.Object... bindings)
Specified by:
throwInvalidEvaluation in interface EvaluationVisitor

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

visitConstraint

public Value visitConstraint(Constraint constraint)
This default implementation asserts that the constraint is boolean-valued if it is an invariant, pre-condition, or post-condition constraint and returns the value of its body expression by delegation to #visitExpression(OCLExpression).

Specified by:
visitConstraint in interface Visitor<Value,java.lang.Object>
Overrides:
visitConstraint in class AbstractExtendingVisitor<Value,java.lang.Object>