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:
DomainEvaluationEnvironment, 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
metaModelManager
 
Constructor Summary
PivotEvaluationEnvironment(EvaluationEnvironment parent)
          Initializes me with my parent evaluation environment (nesting scope).
PivotEvaluationEnvironment(MetaModelManager metaModelManager)
          Initializes me.
 
Method Summary
 DomainModelManager createModelManager(java.lang.Object object)
          Retrieves the reference feature in the specified context object that references the specified association class.
 DomainTypedElement createVariable(java.lang.String name, DomainType type)
          Ecore implementation of the enumeration literal value.
 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)
          Obtains the instance of the specified association class that links the specified source element, optionally via the specified property.
 
Methods inherited from class org.eclipse.ocl.examples.pivot.evaluation.AbstractEvaluationEnvironment
add, basicGetOptions, clear, clearOptions, getAdapter, getMetaModelManager, getOptions, getParent, 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(MetaModelManager metaModelManager)
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 DomainModelManager 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; StringBuilder nameBuf = new StringBuilder(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; }

createVariable

public DomainTypedElement createVariable(java.lang.String name,
                                         DomainType type)
Ecore implementation of the enumeration literal value.

Since:
1.2 public Enumerator getValue(EnumerationLiteral enumerationLiteral) { return enumerationLiteral.getInstance(); }

navigateAssociationClass

public Value navigateAssociationClass(Type associationClass,
                                      Property navigationSource,
                                      java.lang.Object source)
                               throws java.lang.IllegalArgumentException
Description copied from interface: EvaluationEnvironment
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

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()