org.eclipse.emf.ocl.expressions.util
Class EvalEnvironment

java.lang.Object
  extended byorg.eclipse.emf.ocl.expressions.util.EvalEnvironment
All Implemented Interfaces:
EvaluationEnvironment

public class EvalEnvironment
extends java.lang.Object
implements EvaluationEnvironment

A mapping of names to objects used in the evaluation of expressions.


Constructor Summary
EvalEnvironment()
           
EvalEnvironment(EvaluationEnvironment parent)
           
 
Method Summary
 void add(java.lang.String name, java.lang.Object value)
          Adds the supplied name and value binding to the environment
 boolean canEvaluate(org.eclipse.emf.ecore.EOperation operation, int opcode)
          Always returns false, because by default only the operations defined by the OCL itself and the particular EMF metamodel are supported.
 void clear()
          Clears the environment of variables.
 java.lang.Object evaluate(org.eclipse.emf.ecore.EOperation operation, int opcode, java.lang.Object target, java.lang.Object[] args)
          Implements the interface method by just throwing, as I do not by default provide any implementation of any additional operations.
 java.lang.Object getValueOf(java.lang.String name)
          Returns the value associated with the supplied name
 java.lang.Object remove(java.lang.String name)
          Removes the supplied name and binding from the environment (if it exists) and returns it.
 void replace(java.lang.String name, 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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EvalEnvironment

public EvalEnvironment()

EvalEnvironment

public EvalEnvironment(EvaluationEnvironment parent)
Method Detail

getValueOf

public java.lang.Object getValueOf(java.lang.String name)
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(java.lang.String name,
                    java.lang.Object value)
Replaces the current value of the supplied name with the supplied value.

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

add

public void add(java.lang.String name,
                java.lang.Object value)
Adds the supplied name and value binding to the environment

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

remove

public java.lang.Object remove(java.lang.String name)
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


canEvaluate

public boolean canEvaluate(org.eclipse.emf.ecore.EOperation operation,
                           int opcode)
Always returns false, because by default only the operations defined by the OCL itself and the particular EMF metamodel are supported. Subclasses can override to override existing operation implementations or to add operations not defined by either OCL or the metamodel.

Specified by:
canEvaluate 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:
EvaluationEnvironment.evaluate(EOperation, int, Object, Object[])

evaluate

public java.lang.Object evaluate(org.eclipse.emf.ecore.EOperation operation,
                                 int opcode,
                                 java.lang.Object target,
                                 java.lang.Object[] args)
                          throws java.lang.UnsupportedOperationException
Implements the interface method by just throwing, as I do not by default provide any implementation of any additional operations.

Specified by:
evaluate in interface EvaluationEnvironment
Parameters:
operation - the operation to evaluate
opcode - the operation code, if one of the operations pre-defined by OCL. Otherwise, -1
target - the object on which to apply the operation. the target may be an EObject or it may not, depending on the EClassifier type
args - the arguments passed to the operation. Will be an empty array if there are none (not null)
Returns:
the value of the operation, or null if the operation has no return result
Throws:
java.lang.UnsupportedOperationException - if the specified operation is not implemented by this environment
See Also:
EvaluationEnvironment.canEvaluate(EOperation, int)

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