org.eclipse.emf.ocl.parser
Interface EvaluationEnvironment

All Known Implementing Classes:
EvalEnvironment

public interface EvaluationEnvironment

The evaluation environment keeps track of the current values of variables in the evaluation of an OCL expression.


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)
          Queries whether this evaluation environment provides a custom implementation of the specified OCL operation.
 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)
          Evaluates the specified operation on a given target object with arguments.
 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.
 

Method Detail

getValueOf

public java.lang.Object getValueOf(java.lang.String name)
Returns the value associated with the supplied name

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.

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. The name must not already be bound.

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.

Parameters:
name - the name to remove
Returns:
the value associated with the removed name

clear

public void clear()
Clears the environment of variables.


canEvaluate

public boolean canEvaluate(org.eclipse.emf.ecore.EOperation operation,
                           int opcode)
Queries whether this evaluation environment provides a custom implementation of the specified OCL operation. In the case that the receiver does, then it must implement the EvaluationEnvironment.evaluate(EOperation, int, Object, Object[]) method to apply the operation.

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
Evaluates the specified operation on a given target object with arguments.

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.