org.eclipse.higgins.util.jscript
Class JScriptExec

java.lang.Object
  extended byorg.eclipse.higgins.util.jscript.JScriptExec

public class JScriptExec
extends Object

Simplified representation of a PDP utilizing Mozilla's Rhino project as a JavaScript interpreter for policies. This object is used to evaluate the script and holds references to the compiled JavaScript fragment within a JScriptScope

Critical exceptions are logged as errors via commons logging

Author:
dbuss@novell.com

Constructor Summary
JScriptExec(JScriptScope sharedScope, String script, String scriptID)
           
 
Method Summary
 Object evaluate(String[] paramNames, Object[] params)
          Evaluate a previously complied script fragment.
 Object evaluate(String[] paramNames, Object[] params, String[] outputNames, Object[] outputObjects)
          Evaluate a previously complied script fragment.
 Object evaluate(String ParamName, Object Param)
          Evaluate a previously complied script fragment.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JScriptExec

public JScriptExec(JScriptScope sharedScope,
                   String script,
                   String scriptID)
            throws JScriptException
Method Detail

evaluate

public Object evaluate(String[] paramNames,
                       Object[] params)
                throws JScriptException
Evaluate a previously complied script fragment. Use this function to pass java objects to the script, all objects passed in are added to a local scope.

Parameters:
paramNames - ordered list of string versions of the parameter names. These are the names which will be stored in the local JavaScript scope for use by the JavaScript code fragment
params - order list containing the objects represented by the string names. This will be wrapped and made availible for use by the Script in the evaluation.
Returns:
A Java object representing the result of evaluation. By default it returns the contents of the JavaScript variable RESULT if defined, otherwise it returns the evaluation result of the script.
Throws:
JScriptException

evaluate

public Object evaluate(String[] paramNames,
                       Object[] params,
                       String[] outputNames,
                       Object[] outputObjects)
                throws JScriptException
Evaluate a previously complied script fragment. Use this function to pass java objects to the script, all objects passed in are added to a local scope.

Parameters:
paramNames - ordered list of string versions of the parameter names. These are the names which will be stored in the local JavaScript scope for use by the JavaScript code fragment
params - order list containing the objects represented by the string names. This will be wrapped and made availible for use by the Script in the evaluation.
Returns:
A Java object representing the result of evaluation. By default it returns the contents of the JavaScript variable RESULT if defined, otherwise it returns the evaluation result of the script.
Throws:
JScriptException

evaluate

public Object evaluate(String ParamName,
                       Object Param)
                throws JScriptException
Evaluate a previously complied script fragment. Use this version of evaluate if all that is needed is to set a single java string in the local scope for use by the script during evaluation.

Parameters:
ParamName - = string name of the parameter
Param - value of the parameter
Returns:
results of Java Script evaluation
Throws:
JScriptException