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

All Superinterfaces:
Adaptable, BasicEnvironment, Customizable, DomainEvaluationEnvironment
All Known Implementing Classes:
AbstractEvaluationEnvironment, PivotEvaluationEnvironment

public interface EvaluationEnvironment
extends DomainEvaluationEnvironment, BasicEnvironment

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(DomainTypedElement referredVariable, java.lang.Object value)
          Adds the supplied variable declaration and value binding to the environment.
 void clear()
          Clears the environment of variables.
 DomainModelManager 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.
 MetaModelManager getMetaModelManager()
          Obtains the Java-language value of the specified enumeration literal.
 Type getType(java.lang.Object object)
          Deprecated. 
 java.lang.Object getValueOf(VariableDeclaration referredVariable)
          Returns the value associated with the supplied variable declaration
 java.lang.Object 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.
 java.lang.Object remove(DomainTypedElement referredVariable)
          Deprecated. let expiry of a nested evaluation environment remove automatically
 void replace(DomainTypedElement referredVariable, java.lang.Object value)
          Replaces the current value of the supplied variable declaration with the supplied value.
 
Methods inherited from interface org.eclipse.ocl.examples.domain.evaluation.DomainEvaluationEnvironment
createVariable
 
Methods inherited from interface org.eclipse.ocl.examples.pivot.Adaptable
getAdapter
 
Methods inherited from interface org.eclipse.ocl.examples.pivot.Customizable
clearOptions, getOptions, getValue, isEnabled, putOptions, removeOption, removeOptions, setOption
 

Method Detail

getValueOf

java.lang.Object getValueOf(@NonNull
                            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(@NonNull
             DomainTypedElement referredVariable,
             java.lang.Object value)
Replaces the current value of the supplied variable declaration with the supplied value.

Specified by:
replace in interface DomainEvaluationEnvironment
Parameters:
referredVariable - the variable declaration
value - the new value

add

void add(@NonNull
         DomainTypedElement referredVariable,
         java.lang.Object value)
Adds the supplied variable declaration and value binding to the environment. The variable declaration must not already be bound.

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

remove

@Deprecated
java.lang.Object remove(@NonNull
                                   DomainTypedElement 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(@NonNull
                  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

java.lang.Object 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

@NonNull
DomainModelManager createModelManager(@Nullable
                                              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

getMetaModelManager

@NonNull
MetaModelManager getMetaModelManager()
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