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

java.lang.Object
  extended by org.eclipse.ocl.examples.pivot.evaluation.AbstractEvaluationEnvironment
      extended by org.eclipse.ocl.examples.pivot.evaluation.PivotEvaluationEnvironment
All Implemented Interfaces:
Adaptable, Customizable, EvaluationEnvironment

public class PivotEvaluationEnvironment
extends AbstractEvaluationEnvironment

Implementation of the EvaluationEnvironment for evaluation of OCL expressions on instances of Ecore models (i.e., on M0 models).

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

Field Summary
 
Fields inherited from class org.eclipse.ocl.examples.pivot.evaluation.AbstractEvaluationEnvironment
typeManager
 
Constructor Summary
PivotEvaluationEnvironment(EvaluationEnvironment parent)
          Initializes me with my parent evaluation environment (nesting scope).
PivotEvaluationEnvironment(TypeManager typeManager)
          Initializes me.
 
Method Summary
 ModelManager createModelManager(java.lang.Object object)
          Retrieves the reference feature in the specified context object that references the specified association class.
 Type getType(java.lang.Object object)
          Queries the type of the specified object.
 ValueFactory getValueFactory()
           
 Value navigateAssociationClass(Type associationClass, Property navigationSource, java.lang.Object source)
          Ecore implementation of the enumeration literal value.
 
Methods inherited from class org.eclipse.ocl.examples.pivot.evaluation.AbstractEvaluationEnvironment
add, basicGetOptions, clear, clearOptions, getAdapter, getOptions, getParent, getTypeManager, getValue, getValueOf, isEnabled, overrides, putOptions, remove, removeOption, removeOptions, replace, setOption, throwInvalidEvaluation, throwInvalidEvaluation, throwInvalidEvaluation, throwInvalidEvaluation, throwInvalidEvaluation, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PivotEvaluationEnvironment

public PivotEvaluationEnvironment(TypeManager typeManager)
Initializes me.


PivotEvaluationEnvironment

public PivotEvaluationEnvironment(EvaluationEnvironment parent)
Initializes me with my parent evaluation environment (nesting scope).

Parameters:
parent - my parent (nesting scope); must not be null
Method Detail

createModelManager

public ModelManager createModelManager(java.lang.Object object)
Retrieves the reference feature in the specified context object that references the specified association class.

Parameters:
context - the context object
associationClass - the association class that it references
Returns:
the reference in question private EReference getAssociationClassReference(EObject context, org.eclipse.ocl.examples.pivot.Class associationClass) { EReference result = null; StringBuffer nameBuf = new StringBuffer(associationClass.getName()); UnicodeSupport.setCodePointAt(nameBuf, 0, UnicodeSupport .toLowerCase(UnicodeSupport.codePointAt(nameBuf, 0))); String name = nameBuf.toString(); for (EReference next : context.eClass().getEAllReferences()) { if (name.equals(next.getName()) && (associationClass == next.getEReferenceType())) { result = next; break; } } return result; }

navigateAssociationClass

public Value navigateAssociationClass(Type associationClass,
                                      Property navigationSource,
                                      java.lang.Object source)
                               throws java.lang.IllegalArgumentException
Ecore implementation of the enumeration literal value.

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
Since:
1.2 public Enumerator getValue(EnumerationLiteral enumerationLiteral) { return enumerationLiteral.getInstance(); }

getType

public Type getType(java.lang.Object object)
Description copied from interface: EvaluationEnvironment
Queries the type of the specified object.

Parameters:
object - an object
Returns:
its type

getValueFactory

public ValueFactory getValueFactory()