com.judoscript
Class JudoEngine

java.lang.Object
  |
  +--com.judoscript.JudoEngine

public class JudoEngine
extends java.lang.Object

This is the JudoScript engine 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)
          Executes the script code.
 void runScript(java.lang.Object script)
          Executes the script.
 void runScript(java.lang.String path)
          Executes the script.
 
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

putBean

public void putBean(java.lang.String name,
                    java.lang.Object bean)
             throws java.lang.Exception
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.

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.
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.
See Also:
runScript(java.lang.Object)

runScript

public final void runScript(java.lang.Object script)
                     throws java.lang.Exception
Executes the script. The script object is saved for future call() uses.
Parameters:
script - the "script" object returned by parseScript().

runScript

public final void runScript(java.lang.String path)
                     throws java.lang.Exception
Executes the script. The script object is saved for future call() uses.
Parameters:
path - the path for a script file.

runCode

public final void runCode(java.lang.String code)
                   throws java.lang.Exception
Executes the script code. The script object is saved for future call() uses.
Parameters:
code - the script code.

call

public java.lang.Object call(java.lang.String fxn,
                             java.lang.Object[] args)
                      throws java.lang.Exception
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.
See Also:
runScript(java.lang.Object), runScript(java.lang.String), runCode(java.lang.String)