## org.eclipse.ocl.ecore
Class EcoreEvaluationEnvironment

    java.lang.Object
      org.eclipse.ocl.AbstractEvaluationEnvironment<EClassifier,EOperation,EStructuralFeature,EClass,EObject>
          org.eclipse.ocl.ecore.EcoreEvaluationEnvironment

All Implemented Interfaces:
  EvaluationEnvironment<EClassifier,EOperation,EStructuralFeature,EClass,EObject>, EvaluationEnvironment.Enumerations<EEnumLiteral>, Customizable, Adaptable

Direct Known Subclasses:
  CompatibilityEvaluationEnvironment

    public class EcoreEvaluationEnvironment

extends AbstractEvaluationEnvironment<EClassifier,EOperation,EStructuralFeature,EClass,EObject>
implements EvaluationEnvironment.Enumerations<EEnumLiteral>

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

Nested Class Summary

Nested classes/interfaces inherited from interface org.eclipse.ocl.EvaluationEnvironment
`EvaluationEnvironment.Enumerations<EL>`

Constructor Summary
`EcoreEvaluationEnvironment()` Initializes me.
`EcoreEvaluationEnvironment(EvaluationEnvironment<EClassifier,EOperation,EStructuralFeature,EClass,EObject> parent)` Initializes me with my parent evaluation environment (nesting scope).

Method Summary
`Object` `callOperation(EOperation operation, int opcode, Object source, Object[] args)` Implements the inherited method by attempting to find an appropriate Java method in the actual type of the `source` object and invoking it.
`Map<EClass,Set<EObject>>` `createExtentMap(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.
`Tuple<EOperation,EStructuralFeature>` `createTuple(EClassifier type, Map<EStructuralFeature,Object> values)` Creates a new tuple instance.
`protected Object` `getInvalidResult()` Obtains the language-binding-specific representation of the predefined `OclInvalid` object.
`protected Method` `getJavaMethodFor(EOperation operation, Object receiver)` Returns the java method that corresponds to the supplied `EOperation`
`EClassifier` `getType(Object object)` Queries the type of the specified object.
`Enumerator` `getValue(EEnumLiteral enumerationLiteral)` Ecore implementation of the enumeration literal value.
`boolean` `isKindOf(Object object, EClassifier classifier)` Queries whether an object is an instance of the specified classifier or some specialization thereof.
`boolean` `isTypeOf(Object object, EClassifier classifier)` Queries whether an object's type is the specified classifier.
`Object` `navigateAssociationClass(EClassifier associationClass, EStructuralFeature navigationSource, Object target)` Obtains the instance of the specified association class that links the specified source element, optionally via the specified property.
`Object` `navigateProperty(EStructuralFeature property, List<?> qualifiers, Object target)` Obtains the value of the specified operation, for the given source element, according to the particular metamodel semantics.

Methods inherited from class org.eclipse.ocl.AbstractEvaluationEnvironment
`add, basicGetOptions, clear, clearOptions, getAdapter, getOptions, getParent, getValue, getValueOf, isEnabled, overrides, putOptions, remove, removeOption, removeOptions, replace, setOption, toString`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### EcoreEvaluationEnvironment

    public EcoreEvaluationEnvironment()

  Initializes me.

### EcoreEvaluationEnvironment

    public EcoreEvaluationEnvironment(EvaluationEnvironment<EClassifier,EOperation,EStructuralFeature,EClass,EObject> parent)

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

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

Method Detail

### callOperation

    public Object callOperation(EOperation operation,
                                int opcode,
                                Object source,
                                Object[] args)
                         throws IllegalArgumentException

  Description copied from class: `AbstractEvaluationEnvironment`
  Implements the inherited method by attempting to find an appropriate Java method in the actual type of the `source` object and invoking it. On failure to find or invoke the method (e.g., an exception), the `OclInvalid` result is returned.

  Specified by:
    `callOperation` in interface `EvaluationEnvironment<EClassifier,EOperation,EStructuralFeature,EClass,EObject>`
  Overrides:
    `callOperation` in class `AbstractEvaluationEnvironment<EClassifier,EOperation,EStructuralFeature,EClass,EObject>`
  Parameters:
    `operation` - the operation to invoke
    `opcode` - the operation code, if this is an OCL Standard Library operation (which this environment overrides)
    `source` - the source element on which the operation is invoked
    `args` - the arguments, or an empty array if none
  Returns:
    the result of the Java method invocation, or `OclInvalid` on failure of the method invocation
  Throws:
    `IllegalArgumentException` - if the operation is not supported by this environment

### getJavaMethodFor

    protected Method getJavaMethodFor(EOperation operation,
                                      Object receiver)

  Description copied from class: `AbstractEvaluationEnvironment`
  Returns the java method that corresponds to the supplied `EOperation`

  Specified by:
    `getJavaMethodFor` in class `AbstractEvaluationEnvironment<EClassifier,EOperation,EStructuralFeature,EClass,EObject>`
  Parameters:
    `operation` - the operation
  Returns:
    a java method

### getInvalidResult

    protected Object getInvalidResult()

  Description copied from class: `AbstractEvaluationEnvironment`
  Obtains the language-binding-specific representation of the predefined `OclInvalid` object.

  Specified by:
    `getInvalidResult` in class `AbstractEvaluationEnvironment<EClassifier,EOperation,EStructuralFeature,EClass,EObject>`
  Returns:
    `OclInvalid`

### navigateProperty

    public Object navigateProperty(EStructuralFeature property,
                                   List<?> qualifiers,
                                   Object target)
                            throws IllegalArgumentException

  Description copied from interface: `EvaluationEnvironment`
  Obtains the value of the specified operation, for the given source element, according to the particular metamodel semantics.

  Specified by:
    `navigateProperty` in interface `EvaluationEnvironment<EClassifier,EOperation,EStructuralFeature,EClass,EObject>`
  Parameters:
    `property` - the property to navigate
    `qualifiers` - the association-end qualifier values, or an empty list if none
    `target` - the source element owning the property value
  Returns:
    the property value
  Throws:
    `IllegalArgumentException` - if the property is not supported by the element or by this environment

### navigateAssociationClass

    public Object navigateAssociationClass(EClassifier associationClass,
                                           EStructuralFeature navigationSource,
                                           Object target)
                                    throws 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.

  Specified by:
    `navigateAssociationClass` in interface `EvaluationEnvironment<EClassifier,EOperation,EStructuralFeature,EClass,EObject>`
  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
    `target` - the source element from which to navigate
  Returns:
    the association class instance
  Throws:
    `IllegalArgumentException` - if the association class is not associated with the source element, or is not supported by this environment

### createTuple

    public Tuple<EOperation,EStructuralFeature> createTuple(EClassifier type,
                                                            Map<EStructuralFeature,Object> values)

  Description copied from interface: `EvaluationEnvironment`
  Creates a new tuple instance.

  Specified by:
    `createTuple` in interface `EvaluationEnvironment<EClassifier,EOperation,EStructuralFeature,EClass,EObject>`
  Parameters:
    `type` - the type (a `TupleType`) of the tuple to be created
    `values` - a mapping of the tuple parts
  Returns:
    the new tuple instance

### createExtentMap

    public Map<EClass,Set<EObject>> createExtentMap(Object object)

  Description copied from interface: `EvaluationEnvironment`
  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.

  Specified by:
    `createExtentMap` in interface `EvaluationEnvironment<EClassifier,EOperation,EStructuralFeature,EClass,EObject>`
  Parameters:
    `object` - a context object in the scope that covers the OCL classifier extents
  Returns:
    the extent map

### isKindOf

    public boolean isKindOf(Object object,
                            EClassifier classifier)

  Description copied from interface: `EvaluationEnvironment`
  Queries whether an object is an instance of the specified classifier or some specialization thereof.

  Specified by:
    `isKindOf` in interface `EvaluationEnvironment<EClassifier,EOperation,EStructuralFeature,EClass,EObject>`
  Parameters:
    `object` - an object
    `classifier` - a classifier
  Returns:
    `true` if the specified classifier is the object's type or some supertype thereof; `false`, otherwise

### isTypeOf

    public boolean isTypeOf(Object object,
                            EClassifier classifier)

  Description copied from interface: `EvaluationEnvironment`
  Queries whether an object's type is the specified classifier.

  Specified by:
    `isTypeOf` in interface `EvaluationEnvironment<EClassifier,EOperation,EStructuralFeature,EClass,EObject>`
  Parameters:
    `object` - an object
    `classifier` - a classifier
  Returns:
    `true` if ths specified classifier is the object's type; `false`, otherwise

### getType

    public EClassifier getType(Object object)

  Description copied from interface: `EvaluationEnvironment`
  Queries the type of the specified object.

  Specified by:
    `getType` in interface `EvaluationEnvironment<EClassifier,EOperation,EStructuralFeature,EClass,EObject>`
  Parameters:
    `object` - an object
  Returns:
    its type

### getValue

    public Enumerator getValue(EEnumLiteral enumerationLiteral)

  Ecore implementation of the enumeration literal value.

  Specified by:
    `getValue` in interface `EvaluationEnvironment.Enumerations<EEnumLiteral>`
  Parameters:
    `enumerationLiteral` - the enumeration literal model element
  Returns:
    the corresponding run-time instance
  Since:
    1.2

Copyright 2002, 2007 IBM Corporation and others. All Rights Reserved.