## org.eclipse.ocl
Class AbstractEvaluationEnvironment<C,O,P,CLS,E>

    java.lang.Object
      org.eclipse.ocl.AbstractEvaluationEnvironment<C,O,P,CLS,E>

All Implemented Interfaces:
  EvaluationEnvironment<C,O,P,CLS,E>, Customizable, Adaptable

Direct Known Subclasses:
  EcoreEvaluationEnvironment

    public abstract class AbstractEvaluationEnvironment<C,O,P,CLS,E>

extends Object
implements EvaluationEnvironment<C,O,P,CLS,E>, Adaptable, Customizable

A partial implementation of the `EvaluationEnvironment` interface, providing some useful common behaviors. Implementors of metamodel-specific environments are encourage to extend this class rather than implement an evaluation environment "from scratch."

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

Since the 1.2 release, this interface is `Adaptable` to support the optional adapter protocols such as `EvaluationEnvironment.Enumerations` and `Customizable`.

Nested Class Summary

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

Constructor Summary
`protected` `AbstractEvaluationEnvironment()`
`protected` `AbstractEvaluationEnvironment(EvaluationEnvironment<C,O,P,CLS,E> parent)`

Method Summary
`void` `add(String name, Object value)` Adds the supplied name and value binding to the environment
`protected Map<Option<?>,Object>` `basicGetOptions()`
`Object` `callOperation(O 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.
`void` `clear()` Clears the environment of variables.
`Map<Option<?>,Object>` `clearOptions()` Clears all options.

`

`<T> T`

`

`getAdapter(Class<T> adapterType)`
Implements the interface method by testing whether I am an instance of the requested adapter type.

`protected abstract Object` `getInvalidResult()` Obtains the language-binding-specific representation of the predefined `OclInvalid` object.
`protected abstract Method` `getJavaMethodFor(O operation, Object receiver)` Returns the java method that corresponds to the supplied `EOperation`
`Map<Option<?>,Object>` `getOptions()` Obtains a copy of my map of options.
`protected EvaluationEnvironment<C,O,P,CLS,E>` `getParent()` Obtains my parent (nesting) environment.

`

`<T> T`

`

`getValue(Option<T> option)`
Obtains the value of the specified option's setting in the my options map.

`Object` `getValueOf(String name)` Returns the value associated with the supplied name
`boolean` `isEnabled(Option<Boolean> option)` Queries whether the specified boolean-valued option is enabled.
`boolean` `overrides(O operation, int opcode)` By default, a subclass will not support overriding the operations defined by the OCL Standard Library.

`

`<T> void`

`

`putOptions(Map<? extends Option<T>,? extends T> options)`
Adds options to apply to my behaviour.

`Object` `remove(String name)` Removes the supplied name and binding from the environment (if it exists) and returns it.

`

`<T> T`

`

`removeOption(Option<T> option)`
Removes the specified option.

`

`<T> Map<Option<T>,T>`

`

`removeOptions(Collection<Option<T>> options)`
Removes the specified options.

`void` `replace(String name, Object value)` Replaces the current value of the supplied name with the supplied value.

`

`<T> void`

`

`setOption(Option<T> option, T value)`
Add an option to apply to my behaviour.

`String` `toString()` Returns a string representation of the bindings

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

Methods inherited from interface org.eclipse.ocl.EvaluationEnvironment
`createExtentMap, createTuple, getType, isKindOf, isTypeOf, navigateAssociationClass, navigateProperty`

Constructor Detail

### AbstractEvaluationEnvironment

    protected AbstractEvaluationEnvironment()

### AbstractEvaluationEnvironment

    protected AbstractEvaluationEnvironment(EvaluationEnvironment<C,O,P,CLS,E> parent)

Method Detail

### getParent

    protected EvaluationEnvironment<C,O,P,CLS,E> getParent()

  Obtains my parent (nesting) environment.

  Returns:
    my parent environment, or `null` if none

### getValueOf

    public Object getValueOf(String name)

  Returns the value associated with the supplied name

  Specified by:
    `getValueOf` in interface `EvaluationEnvironment<C,O,P,CLS,E>`
  Parameters:
    `name` - the name whose value is to be returned
  Returns:
    the value associated with the name

### replace

    public void replace(String name,
                        Object value)

  Replaces the current value of the supplied name with the supplied value.

  Specified by:
    `replace` in interface `EvaluationEnvironment<C,O,P,CLS,E>`
  Parameters:
    `name` - the name
    `value` - the new value

### add

    public void add(String name,
                    Object value)

  Adds the supplied name and value binding to the environment

  Specified by:
    `add` in interface `EvaluationEnvironment<C,O,P,CLS,E>`
  Parameters:
    `name` - the name to add
    `value` - the associated binding
  See Also:
    `EvaluationEnvironment.replace(String, Object)`

### remove

    public Object remove(String name)

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

  Specified by:
    `remove` in interface `EvaluationEnvironment<C,O,P,CLS,E>`
  Parameters:
    `name` - the name to remove
  Returns:
    the value associated with the removed name

### clear

    public void clear()

  Clears the environment of variables.

  Specified by:
    `clear` in interface `EvaluationEnvironment<C,O,P,CLS,E>`

### toString

    public String toString()

  Returns a string representation of the bindings

  Overrides:
    `toString` in class `Object`

### overrides

    public boolean overrides(O operation,
                             int opcode)

  By default, a subclass will not support overriding the operations defined by the OCL Standard Library. This implementation delegates to the parent environment (if any), otherwise returns `false`.

  Specified by:
    `overrides` in interface `EvaluationEnvironment<C,O,P,CLS,E>`
  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:
    `EvaluationEnvironment.callOperation(O, int, java.lang.Object, java.lang.Object[])`

### callOperation

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

  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<C,O,P,CLS,E>`
  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 abstract Method getJavaMethodFor(O operation,
                                               Object receiver)

  Returns the java method that corresponds to the supplied `EOperation`

  Parameters:
    `operation` - the operation
  Returns:
    a java method

### getInvalidResult

    protected abstract Object getInvalidResult()

  Obtains the language-binding-specific representation of the predefined `OclInvalid` object.

  Returns:
    `OclInvalid`

### getAdapter

    public <T> T getAdapter(Class<T> adapterType)

  Implements the interface method by testing whether I am an instance of the requested adapter type.

  Specified by:
    `getAdapter` in interface `Adaptable`
  Type Parameters:
    `T` - the requested adapter interface
  Parameters:
    `adapterType` - the requested adapter interface
  Returns:
    an instance of the requested interface, or `null` if this environment does not adapt to it

### basicGetOptions

    protected Map<Option<?>,Object> basicGetOptions()

### getOptions

    public Map<Option<?>,Object> getOptions()

  Description copied from interface: `Customizable`
  Obtains a copy of my map of options. Options not explicitly set in an environment are inherited from the parent environment, if any, otherwise they are at their default values.

  Specified by:
    `getOptions` in interface `Customizable`
  Returns:
    the map of options

### setOption

    public <T> void setOption(Option<T> option,
                              T value)

  Description copied from interface: `Customizable`
  Add an option to apply to my behaviour.

  Specified by:
    `setOption` in interface `Customizable`
  Parameters:
    `option` - the option
    `value` - the option's value

### putOptions

    public <T> void putOptions(Map<? extends Option<T>,? extends T> options)

  Description copied from interface: `Customizable`
  Adds options to apply to my behaviour.

  Specified by:
    `putOptions` in interface `Customizable`
  Parameters:
    `options` - the options

### removeOption

    public <T> T removeOption(Option<T> option)

  Description copied from interface: `Customizable`
  Removes the specified option.

  Specified by:
    `removeOption` in interface `Customizable`
  Parameters:
    `option` - the option to remove
  Returns:
    the former value of the option

### removeOptions

    public <T> Map<Option<T>,T> removeOptions(Collection<Option<T>> options)

  Description copied from interface: `Customizable`
  Removes the specified options.

  Specified by:
    `removeOptions` in interface `Customizable`
  Parameters:
    `options` - the options to remove
  Returns:
    the former values of the options

### clearOptions

    public Map<Option<?>,Object> clearOptions()

  Description copied from interface: `Customizable`
  Clears all options.

  Specified by:
    `clearOptions` in interface `Customizable`
  Returns:
    the former values of the options

### isEnabled

    public boolean isEnabled(Option<Boolean> option)

  Description copied from interface: `Customizable`
  Queries whether the specified boolean-valued option is enabled. This method essentially just puts a nice "is" name on boolean options. Options not explicitly set in an environment are inherited from the parent environment, if any, otherwise they are at their default values.

  Specified by:
    `isEnabled` in interface `Customizable`
  Parameters:
    `option` - an option
  Returns:
    whether the option is enabled

### getValue

    public <T> T getValue(Option<T> option)

  Description copied from interface: `Customizable`
  Obtains the value of the specified option's setting in the my options map. Options not explicitly set in an environment are inherited from the parent environment, if any, otherwise they are at their default values.

  Specified by:
    `getValue` in interface `Customizable`
  Parameters:
    `option` - the option to query
  Returns:
    value of the option

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