org.enhydra.shark.scripting
Class PythonEvaluator

java.lang.Object
  extended by org.enhydra.shark.scripting.PythonEvaluator
All Implemented Interfaces:
Evaluator

public class PythonEvaluator
extends java.lang.Object
implements Evaluator

Implementation of the Evaluator interface which evaluates the conditions body as a Python expression.


Field Summary
protected  CallbackUtilities cus
           
protected static java.lang.String LOG_CHANNEL
           
 
Constructor Summary
PythonEvaluator()
           
 
Method Summary
protected  java.lang.String adjustExpression(WMSessionHandle shandle, java.lang.String expression, java.util.Map context, java.lang.String procId, java.lang.String actId)
           
 void configure(CallbackUtilities cus)
           
 boolean evaluateCondition(WMSessionHandle shandle, java.lang.String procId, java.lang.String actId, java.lang.String condition, java.util.Map context)
          Evaluate the condition using python as the expression language.
 java.lang.Object evaluateExpression(WMSessionHandle shandle, java.lang.String procId, java.lang.String actId, java.lang.String expr, java.util.Map context, java.lang.Class resultClass)
          Evaluates the given expression.
protected  java.lang.String prepareContext(WMSessionHandle shandle, org.python.util.PythonInterpreter interpreter, java.lang.String expr, java.util.Map context, java.lang.String procId, java.lang.String actId)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG_CHANNEL

protected static final java.lang.String LOG_CHANNEL
See Also:
Constant Field Values

cus

protected CallbackUtilities cus
Constructor Detail

PythonEvaluator

public PythonEvaluator()
Method Detail

configure

public void configure(CallbackUtilities cus)
               throws java.lang.Exception
Specified by:
configure in interface Evaluator
Throws:
java.lang.Exception

evaluateCondition

public boolean evaluateCondition(WMSessionHandle shandle,
                                 java.lang.String procId,
                                 java.lang.String actId,
                                 java.lang.String condition,
                                 java.util.Map context)
                          throws java.lang.Exception
Evaluate the condition using python as the expression language. This method returns true if the condition is satisfied.

Specified by:
evaluateCondition in interface Evaluator
Parameters:
condition - The condition
context - The context
Returns:
True if the condition is true
Throws:
java.lang.Exception

evaluateExpression

public java.lang.Object evaluateExpression(WMSessionHandle shandle,
                                           java.lang.String procId,
                                           java.lang.String actId,
                                           java.lang.String expr,
                                           java.util.Map context,
                                           java.lang.Class resultClass)
                                    throws java.lang.Exception
Evaluates the given expression.

Specified by:
evaluateExpression in interface Evaluator
Parameters:
expr - The expression String
context - The workflow context
resultClass - Returned object should be the instance of this Java class
Returns:
True if the expression evaluates to true
Throws:
java.lang.Exception

prepareContext

protected java.lang.String prepareContext(WMSessionHandle shandle,
                                          org.python.util.PythonInterpreter interpreter,
                                          java.lang.String expr,
                                          java.util.Map context,
                                          java.lang.String procId,
                                          java.lang.String actId)
                                   throws java.lang.Exception
Throws:
java.lang.Exception

adjustExpression

protected java.lang.String adjustExpression(WMSessionHandle shandle,
                                            java.lang.String expression,
                                            java.util.Map context,
                                            java.lang.String procId,
                                            java.lang.String actId)
                                     throws java.lang.Exception
Throws:
java.lang.Exception