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

java.lang.Object
  extended by org.eclipse.ocl.examples.pivot.AbstractBasicEnvironment<EvaluationEnvironment>
      extended by org.eclipse.ocl.examples.pivot.evaluation.AbstractEvaluationEnvironment
All Implemented Interfaces:
DomainEvaluationEnvironment, Adaptable, BasicEnvironment, Customizable, EvaluationEnvironment
Direct Known Subclasses:
PivotEvaluationEnvironment

public abstract class AbstractEvaluationEnvironment
extends AbstractBasicEnvironment<EvaluationEnvironment>
implements EvaluationEnvironment

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.

Author:
Christian W. Damus (cdamus)

Field Summary
protected  MetaModelManager metaModelManager
           
 
Fields inherited from class org.eclipse.ocl.examples.pivot.AbstractBasicEnvironment
parent
 
Constructor Summary
protected AbstractEvaluationEnvironment(EvaluationEnvironment parent)
           
protected AbstractEvaluationEnvironment(MetaModelManager metaModelManager)
           
 
Method Summary
 void add(DomainTypedElement referredVariable, java.lang.Object value)
          Adds the supplied name and value binding to the environment
 void clear()
          Clears the environment of variables.
 MetaModelManager getMetaModelManager()
          Obtains the Java-language value of the specified enumeration literal.
 java.lang.Object getValueOf(VariableDeclaration referredVariable)
          Returns the value associated with the supplied name
 boolean overrides(Operation operation, int opcode)
          By default, a subclass will not support overriding the operations defined by the OCL Standard Library.
 java.lang.Object remove(DomainTypedElement referredVariable)
          Deprecated. 
 void replace(DomainTypedElement referredVariable, java.lang.Object value)
          Replaces the current value of the supplied name with the supplied value.
 java.lang.String toString()
          Returns a string representation of the bindings
 
Methods inherited from class org.eclipse.ocl.examples.pivot.AbstractBasicEnvironment
basicGetOptions, clearOptions, getAdapter, getOptions, getParent, getValue, isEnabled, notOK, putOptions, removeOption, removeOptions, setOption, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.eclipse.ocl.examples.pivot.evaluation.EvaluationEnvironment
createModelManager, getType, navigateAssociationClass
 
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
 

Field Detail

metaModelManager

@NonNull
protected final MetaModelManager metaModelManager
Constructor Detail

AbstractEvaluationEnvironment

protected AbstractEvaluationEnvironment(@NonNull
                                        MetaModelManager metaModelManager)

AbstractEvaluationEnvironment

protected AbstractEvaluationEnvironment(@NonNull
                                        EvaluationEnvironment parent)
Method Detail

getMetaModelManager

@NonNull
public MetaModelManager getMetaModelManager()
Description copied from interface: EvaluationEnvironment
Obtains the Java-language value of the specified enumeration literal. Often, this is an instance of an EMF-generated enumeration type.

Specified by:
getMetaModelManager in interface EvaluationEnvironment
Returns:
the corresponding run-time instance

getValueOf

@Nullable
public java.lang.Object getValueOf(@NonNull
                                            VariableDeclaration referredVariable)
Returns the value associated with the supplied name

Specified by:
getValueOf in interface EvaluationEnvironment
Parameters:
name - the name whose value is to be returned
Returns:
the value associated with the name

replace

public void replace(@NonNull
                    DomainTypedElement referredVariable,
                    @Nullable
                    java.lang.Object value)
Replaces the current value of the supplied name with the supplied value.

Specified by:
replace in interface DomainEvaluationEnvironment
Specified by:
replace in interface EvaluationEnvironment
Parameters:
name - the name
value - the new value

add

public void add(@NonNull
                DomainTypedElement referredVariable,
                @Nullable
                java.lang.Object value)
Adds the supplied name and value binding to the environment

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

remove

@Deprecated
public java.lang.Object remove(@NonNull
                                          DomainTypedElement referredVariable)
Deprecated. 

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

Specified by:
remove in interface EvaluationEnvironment
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

toString

public java.lang.String toString()
Returns a string representation of the bindings

Overrides:
toString in class java.lang.Object

overrides

public boolean overrides(@NonNull
                         Operation 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
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