Class SEScriptEngine
- java.lang.Object
-
- javax.script.AbstractScriptEngine
-
- ca.cgjennings.apps.arkham.plugins.engine.SEScriptEngine
-
- All Implemented Interfaces:
javax.script.Compilable
,javax.script.Invocable
,javax.script.ScriptEngine
public final class SEScriptEngine extends javax.script.AbstractScriptEngine implements javax.script.Invocable, javax.script.Compilable
Implementation ofScriptEngine
for Strange Rhino, the modified Mozilla Rhino build used for Strange Eons scripts.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description javax.script.CompiledScript
compile(java.io.Reader script)
javax.script.CompiledScript
compile(java.lang.String script)
javax.script.Bindings
createBindings()
Create a new bindings instance, used to define script values in aScriptContext
to make them available to a running script.java.lang.Object
eval(java.io.Reader reader, javax.script.ScriptContext scriptContext)
java.lang.Object
eval(java.lang.String script, javax.script.ScriptContext scriptContext)
javax.script.ScriptEngineFactory
getFactory()
<T> T
getInterface(java.lang.Class<T> interfaceType)
<T> T
getInterface(java.lang.Object scriptObject, java.lang.Class<T> interfaceType)
java.lang.Object
invokeFunction(java.lang.String name, java.lang.Object... args)
java.lang.Object
invokeMethod(java.lang.Object thiz, java.lang.String name, java.lang.Object... args)
protected java.io.Reader
preprocessScript(java.lang.String fileName, java.io.Reader reader)
Subclasses may override this to construct a pipeline that can access and modify the script source before it is evaluated.
-
-
-
Method Detail
-
getFactory
public javax.script.ScriptEngineFactory getFactory()
- Specified by:
getFactory
in interfacejavax.script.ScriptEngine
-
eval
public java.lang.Object eval(java.io.Reader reader, javax.script.ScriptContext scriptContext) throws javax.script.ScriptException
- Specified by:
eval
in interfacejavax.script.ScriptEngine
- Throws:
javax.script.ScriptException
-
eval
public java.lang.Object eval(java.lang.String script, javax.script.ScriptContext scriptContext) throws javax.script.ScriptException
- Specified by:
eval
in interfacejavax.script.ScriptEngine
- Throws:
javax.script.ScriptException
-
createBindings
public javax.script.Bindings createBindings()
Create a new bindings instance, used to define script values in aScriptContext
to make them available to a running script. This will return bindings that can correctly handle keys that link to setting values and translated strings.- Specified by:
createBindings
in interfacejavax.script.ScriptEngine
- Returns:
- a map of values that can be placed in a script's scope
-
invokeFunction
public java.lang.Object invokeFunction(java.lang.String name, java.lang.Object... args) throws javax.script.ScriptException, java.lang.NoSuchMethodException
- Specified by:
invokeFunction
in interfacejavax.script.Invocable
- Throws:
javax.script.ScriptException
java.lang.NoSuchMethodException
-
invokeMethod
public java.lang.Object invokeMethod(java.lang.Object thiz, java.lang.String name, java.lang.Object... args) throws javax.script.ScriptException, java.lang.NoSuchMethodException
- Specified by:
invokeMethod
in interfacejavax.script.Invocable
- Throws:
javax.script.ScriptException
java.lang.NoSuchMethodException
-
getInterface
public <T> T getInterface(java.lang.Class<T> interfaceType)
- Specified by:
getInterface
in interfacejavax.script.Invocable
-
getInterface
public <T> T getInterface(java.lang.Object scriptObject, java.lang.Class<T> interfaceType)
- Specified by:
getInterface
in interfacejavax.script.Invocable
-
compile
public javax.script.CompiledScript compile(java.lang.String script) throws javax.script.ScriptException
- Specified by:
compile
in interfacejavax.script.Compilable
- Throws:
javax.script.ScriptException
-
compile
public javax.script.CompiledScript compile(java.io.Reader script) throws javax.script.ScriptException
- Specified by:
compile
in interfacejavax.script.Compilable
- Throws:
javax.script.ScriptException
-
preprocessScript
protected java.io.Reader preprocessScript(java.lang.String fileName, java.io.Reader reader) throws javax.script.ScriptException
Subclasses may override this to construct a pipeline that can access and modify the script source before it is evaluated.- Parameters:
fileName
- the script file name; will be a fallback name if unknownreader
- a non-null reader that will produce the source text- Returns:
- a reader that will produce the modified text, or the original reader
- Throws:
javax.script.ScriptException
- if an exception occurs while modifying the text
-
-