public class ScriptInvoker
extends java.lang.Object
SwingScript
class but is more intensive to use. It is strongly recommended to use SwingScript
if
possible. Note: unlike the SwingScript
class, this class doesn't necessarily run scripts in the Swing event
Thread. This class works by configuring and running scripts in a step by step manner. Always make sure to call one of
the createEngine methods before invoking any script code.Constructor and Description |
---|
ScriptInvoker() |
Modifier and Type | Method and Description |
---|---|
void |
createEngine()
Create the engine with a default
ScriptConfig . |
void |
createEngine(ScriptConfig config)
Create the engine with the supplied
ScriptConfig . |
<E> E |
eval(java.lang.String code)
Exaluate raw script code.
|
<E> E |
runFile(java.io.File file)
Run a
File as script. |
<E> E |
runResource(java.lang.String resource)
Run a script resource.
|
public void createEngine()
ScriptConfig
.public void createEngine(ScriptConfig config)
ScriptConfig
.config
- customize the script environment.public <E> E runResource(java.lang.String resource)
E
- automatically cast the return value to the assigned type.resource
- base name of the script.public <E> E runFile(java.io.File file) throws java.io.FileNotFoundException, javax.script.ScriptException
File
as script.E
- automatically cast the return value to the assigned type.file
- a File on the file system containing code.java.io.FileNotFoundException
- If the file is not on the File system.javax.script.ScriptException
- Low level Exception signaling problems in the script.public <E> E eval(java.lang.String code)
E
- automatically cast the return value to the assigned type.code
- raw script code to execute.