com.judoscript
Class JudoEngine

java.lang.Object
  extended by com.judoscript.JudoEngine

public class JudoEngine
extends java.lang.Object

This is the JudoEngine for Java to invoke and interact with JudoScript. It allows Java code to invoke JudoScript functions, or evaluate expression, as well as passing objects between Java and JudoScript.

It is easier and lighter-weight than BSF and needs no extra packages.


Constructor Summary
JudoEngine()
           
 
Method Summary
 java.lang.Object call(java.lang.String fxn, java.lang.Object[] args)
          Call the named function in the saved script object.
 void clearBean(java.lang.String name)
          Removes the named global variable in JudoScript.
 java.lang.Object getBean(java.lang.String name)
           
static java.lang.Object parseCode(java.lang.String code)
           
static java.lang.Object parseScript(java.lang.String path)
           
 void putBean(java.lang.String name, java.lang.Object bean)
          Puts an object into the JudoScript root context as a global variable.
 void runCode(java.lang.String code, java.lang.String[] args, java.util.Map sysprops)
          Executes the script code.
 void runScript(java.lang.Object script, java.lang.String[] args, java.util.Map sysprops)
          Executes the script.
 void runScript(java.lang.String path, java.lang.String[] args, java.util.Map sysprops)
          Executes the script.
 void setErr(LinePrintWriter pw)
           
 void setIn(java.io.BufferedReader br)
           
 void setLog(LinePrintWriter pw)
           
 void setOut(LinePrintWriter pw)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JudoEngine

public JudoEngine()
Method Detail

setOut

public void setOut(LinePrintWriter pw)

setErr

public void setErr(LinePrintWriter pw)

setLog

public void setLog(LinePrintWriter pw)

setIn

public void setIn(java.io.BufferedReader br)

putBean

public void putBean(java.lang.String name,
                    java.lang.Object bean)
             throws java.lang.Throwable
Puts an object into the JudoScript root context as a global variable.

Parameters:
name - the name of the global variable in JudoScript.
value - the variable value.
Throws:
java.lang.Throwable

clearBean

public void clearBean(java.lang.String name)
Removes the named global variable in JudoScript.

Parameters:
name - the name of the global variable.

getBean

public java.lang.Object getBean(java.lang.String name)
Parameters:
name - the name of the global variable.
Returns:
the named global variable in JudoScript.

parseScript

public static final java.lang.Object parseScript(java.lang.String path)
                                          throws java.lang.Exception
Parameters:
path - the path of a script file.
Returns:
a "script" object. This can be passed to runScript() method.
Throws:
java.lang.Exception
See Also:
#runScript(java.lang.Object)

parseCode

public static final java.lang.Object parseCode(java.lang.String code)
                                        throws java.lang.Exception
Parameters:
code - the script code.
Returns:
a "script" object. This can be passed to runScript() method.
Throws:
java.lang.Exception
See Also:
#runScript(java.lang.Object)

runScript

public final void runScript(java.lang.Object script,
                            java.lang.String[] args,
                            java.util.Map sysprops)
                     throws java.lang.Exception
Executes the script. The script object is saved for future call() uses.

Parameters:
script - the "script" object returned by parseScript().
Throws:
java.lang.Exception

runScript

public final void runScript(java.lang.String path,
                            java.lang.String[] args,
                            java.util.Map sysprops)
                     throws java.lang.Exception
Executes the script. The script object is saved for future call() uses.

Parameters:
path - the path for a script file.
Throws:
java.lang.Exception

runCode

public final void runCode(java.lang.String code,
                          java.lang.String[] args,
                          java.util.Map sysprops)
                   throws java.lang.Exception
Executes the script code. The script object is saved for future call() uses.

Parameters:
code - the script code.
Throws:
java.lang.Exception

call

public java.lang.Object call(java.lang.String fxn,
                             java.lang.Object[] args)
                      throws java.lang.Throwable
Call the named function in the saved script object.

Parameters:
fxn - the function name.
args - the parameters to the function.
Returns:
the return value of the function.
Throws:
java.lang.Throwable
See Also:
#runScript(java.lang.Object), #runScript(java.lang.String), #runCode(java.lang.String)