org.eclipse.ocl.examples.pivot.evaluation
Interface EvaluationEnvironment

All Known Implementing Classes:
AbstractEvaluationEnvironment, PivotEvaluationEnvironment

public interface EvaluationEnvironment

The evaluation environment keeps track of the current values of variables in the evaluation of an OCL expression. It also knows how to navigate properties and association classes, etc. in M0 instances described by models conformant to the metamodel supported by the environment implementation.

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

As of the 1.2 release, evaluation environments are encouraged to implement the Adaptable interface to provide optional interfaces such as Customizable for specifying evaluation options. Moreover, the (AbstractEvaluationEnvironment) class implements the Adaptable protocol. Use the OCLUtil#getAdapter(EvaluationEnvironment, Class) method to obtain adapters for any evaluation environment instance.

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

Method Summary
 void add(VariableDeclaration referredVariable, Value value)
          Adds the supplied variable declaration and value binding to the environment.
 void clear()
          Clears the environment of variables.
 ModelManager createModelManager(java.lang.Object object)
          Creates an extent map for invocation of OclType.allInstances() using the specified object as a context from which to find the scope in which OCL classifier extents are defined.
 Type getType(java.lang.Object object)
          Deprecated. 
 TypeManager getTypeManager()
          Obtains the Java-language value of the specified enumeration literal.
 ValueFactory getValueFactory()
           
 Value getValueOf(VariableDeclaration referredVariable)
          Returns the value associated with the supplied variable declaration
 Value navigateAssociationClass(Type associationClass, Property navigationSource, java.lang.Object source)
          Obtains the instance of the specified association class that links the specified source element, optionally via the specified property.
 boolean overrides(Operation operation, int opcode)
          Queries whether this evaluation environment provides a custom implementation of the specified pre-defined OCL operation.
 Value remove(VariableDeclaration referredVariable)
          Deprecated. let expiry of a nested evaluation environment remove automatically
 void replace(VariableDeclaration referredVariable, Value value)
          Replaces the current value of the supplied variable declaration with the supplied value.
 NullValue throwInvalidEvaluation(InvalidValueException e)
           
 NullValue throwInvalidEvaluation(java.lang.String message)
           
 NullValue throwInvalidEvaluation(java.lang.String message, OclExpression expression)
           
 NullValue throwInvalidEvaluation(java.lang.String message, OclExpression expression, java.lang.Object context)
           
 NullValue throwInvalidEvaluation(java.lang.Throwable e, OclExpression expression, java.lang.Object context, java.lang.String message, java.lang.Object... bindings)
           
 

Method Detail

getValueOf

Value getValueOf(VariableDeclaration referredVariable)
Returns the value associated with the supplied variable declaration

Parameters:
referredVariable - the name whose value is to be returned
Returns:
the value associated with the name

replace

void replace(VariableDeclaration referredVariable,
             Value value)
Replaces the current value of the supplied variable declaration with the supplied value.

Parameters:
referredVariable - the variable declaration
value - the new value

add

void add(VariableDeclaration referredVariable,
         Value value)
Adds the supplied variable declaration and value binding to the environment. The variable declaration must not already be bound.

Parameters:
referredVariable - the variable declaration to add
value - the associated binding
See Also:
#replace(String, Object)

remove

@Deprecated
Value remove(VariableDeclaration referredVariable)
Deprecated. let expiry of a nested evaluation environment remove automatically

Removes the supplied variable declaration and binding from the environment (if it exists) and returns it.

Parameters:
referredVariable - the variable declaration to remove
Returns:
the value associated with the removed variable declaration

clear

void clear()
Clears the environment of variables.


overrides

boolean overrides(Operation operation,
                  int opcode)
Queries whether this evaluation environment provides a custom implementation of the specified pre-defined OCL operation. In the case that the receiver does, then it must implement the #callOperation method to apply the operation.

Parameters:
operation - an OCL operation
opcode - the operation code, if one of the operations pre-defined by OCL. Otherwise, -1
Returns:
true if this evaluation environment provides an implementation of this operation; false, otherwise
See Also:
#callOperation

navigateAssociationClass

Value navigateAssociationClass(Type associationClass,
                               Property navigationSource,
                               java.lang.Object source)
                               throws java.lang.IllegalArgumentException
Obtains the instance of the specified association class that links the specified source element, optionally via the specified property.

Parameters:
associationClass - the association class to navigate to
navigationSource - in case of ambiguity, the property of the source element's classifier through which to navigate to the association class
source - the source element from which to navigate
Returns:
the association class instance
Throws:
java.lang.IllegalArgumentException - if the association class is not associated with the source element, or is not supported by this environment

createModelManager

ModelManager createModelManager(java.lang.Object object)
Creates an extent map for invocation of OclType.allInstances() using the specified object as a context from which to find the scope in which OCL classifier extents are defined. This scope may be a resource, resource set, or some metamodel-specific scope. Note that in the case that the object is not an EObject but is, instead, some primitive type, then this may be difficult to determine.

Clients are encouraged to do what they can to optimize this mapping, by lazy initialization of key-value pairs, workspace indices, or whatever means is available. Note that the map will only ever be accessed by key (Map.get(java.lang.Object)); it will never be queried for all entries, all keys, all values, etc. This knowledge could help optimization.

Parameters:
object - a context object in the scope that covers the OCL classifier extents
Returns:
the extent map

getType

@Deprecated
Type getType(java.lang.Object object)
Deprecated. 

Queries the type of the specified object.

Parameters:
object - an object
Returns:
its type

getTypeManager

TypeManager getTypeManager()
Obtains the Java-language value of the specified enumeration literal. Often, this is an instance of an EMF-generated enumeration type.

Parameters:
enumerationLiteral - the enumeration literal model element
Returns:
the corresponding run-time instance

getValueFactory

ValueFactory getValueFactory()

throwInvalidEvaluation

NullValue throwInvalidEvaluation(InvalidValueException e)
                                 throws InvalidEvaluationException
Throws:
InvalidEvaluationException

throwInvalidEvaluation

NullValue throwInvalidEvaluation(java.lang.String message)
                                 throws InvalidEvaluationException
Throws:
InvalidEvaluationException

throwInvalidEvaluation

NullValue throwInvalidEvaluation(java.lang.String message,
                                 OclExpression expression)
                                 throws InvalidEvaluationException
Throws:
InvalidEvaluationException

throwInvalidEvaluation

NullValue throwInvalidEvaluation(java.lang.String message,
                                 OclExpression expression,
                                 java.lang.Object context)
                                 throws InvalidEvaluationException
Throws:
InvalidEvaluationException

throwInvalidEvaluation

NullValue throwInvalidEvaluation(java.lang.Throwable e,
                                 OclExpression expression,
                                 java.lang.Object context,
                                 java.lang.String message,
                                 java.lang.Object... bindings)
                                 throws InvalidEvaluationException
Throws:
InvalidEvaluationException