public class RhinoScriptEngine
extends javax.script.AbstractScriptEngine
implements javax.script.Compilable, javax.script.Invocable
This is the implementation of the standard ScriptEngine interface for Rhino.
An instance of the Rhino ScriptEngine is fully self-contained. Bindings at the GLOBAL_SCOPE may be set, but there is nothing special about them -- if both global and ENGINE_SCOPE bindings are set then the "engine" bindings override the global ones.
The Rhino engine is not thread safe. Rhino does no synchronization of ScriptEngine instances and no synchronization of Bindings instances. It is up to the caller to ensure that the ScriptEngine and all its Bindings are used by a single thread at a time.
The Rhino script engine includes some top-level built-in functions. See the Builtins class for more documentation.
The engine supports a few configuration parameters that may be set at the "engine scope". Both are numbers that may be set to a String or Number object.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
OPTIMIZATION_LEVEL
Reserved key for the Rhino optimization level.
|
Modifier and Type | Method and Description |
---|---|
javax.script.CompiledScript |
compile(java.io.Reader script) |
javax.script.CompiledScript |
compile(java.lang.String script) |
javax.script.Bindings |
createBindings() |
java.lang.Object |
eval(java.io.Reader reader,
javax.script.ScriptContext context) |
java.lang.Object |
eval(java.lang.String script,
javax.script.ScriptContext context) |
javax.script.ScriptEngineFactory |
getFactory() |
<T> T |
getInterface(java.lang.Class<T> clasz) |
<T> T |
getInterface(java.lang.Object thiz,
java.lang.Class<T> clasz) |
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) |
public static final java.lang.String OPTIMIZATION_LEVEL
public java.lang.Object eval(java.lang.String script, javax.script.ScriptContext context) throws javax.script.ScriptException
eval
in interface javax.script.ScriptEngine
javax.script.ScriptException
public java.lang.Object eval(java.io.Reader reader, javax.script.ScriptContext context) throws javax.script.ScriptException
eval
in interface javax.script.ScriptEngine
javax.script.ScriptException
public javax.script.CompiledScript compile(java.lang.String script) throws javax.script.ScriptException
compile
in interface javax.script.Compilable
javax.script.ScriptException
public javax.script.CompiledScript compile(java.io.Reader script) throws javax.script.ScriptException
compile
in interface javax.script.Compilable
javax.script.ScriptException
public java.lang.Object invokeFunction(java.lang.String name, java.lang.Object... args) throws javax.script.ScriptException, java.lang.NoSuchMethodException
invokeFunction
in interface javax.script.Invocable
javax.script.ScriptException
java.lang.NoSuchMethodException
public java.lang.Object invokeMethod(java.lang.Object thiz, java.lang.String name, java.lang.Object... args) throws javax.script.ScriptException, java.lang.NoSuchMethodException
invokeMethod
in interface javax.script.Invocable
javax.script.ScriptException
java.lang.NoSuchMethodException
public <T> T getInterface(java.lang.Class<T> clasz)
getInterface
in interface javax.script.Invocable
public <T> T getInterface(java.lang.Object thiz, java.lang.Class<T> clasz)
getInterface
in interface javax.script.Invocable
public javax.script.Bindings createBindings()
createBindings
in interface javax.script.ScriptEngine
public javax.script.ScriptEngineFactory getFactory()
getFactory
in interface javax.script.ScriptEngine
Copyright © 2010 - 2023 Adobe. All Rights Reserved