public class ExplangScriptEngine extends Object implements ScriptEngine, Invocable
Modifier and Type | Field and Description |
---|---|
protected Compiler |
comp |
protected ScriptContext |
defScriptContext |
protected ScriptEngineFactory |
factory |
ARGV, ENGINE, ENGINE_VERSION, FILENAME, LANGUAGE, LANGUAGE_VERSION, NAME
Modifier | Constructor and Description |
---|---|
protected |
ExplangScriptEngine() |
protected |
ExplangScriptEngine(Bindings bindings) |
protected |
ExplangScriptEngine(ScriptEngineFactory factory) |
Modifier and Type | Method and Description |
---|---|
Bindings |
createBindings() |
Object |
eval(Reader reader) |
Object |
eval(Reader reader,
Bindings bindings)
eval(Reader, Bindings) calls the abstract eval(Reader, ScriptContext)
method, passing it a ScriptContext whose Reader, Writers and Bindings for scopes
other that ENGINE_SCOPE are identical to those members of the protected
context field. |
Object |
eval(Reader reader,
ScriptContext context) |
Object |
eval(String script) |
Object |
eval(String script,
Bindings bindings) |
Object |
eval(String script,
ScriptContext context) |
Object |
get(String key)
Gets the value for the specified key in the
ENGINE_SCOPE of the protected
context field. |
Bindings |
getBindings(int scope)
Returns the
Bindings with the specified scope value in the protected context
field. |
ScriptContext |
getContext() |
ScriptEngineFactory |
getFactory() |
<T> T |
getInterface(Class<T> clasz) |
<T> T |
getInterface(Object thiz,
Class<T> clasz) |
protected ScriptContext |
getScriptContext(Bindings nn)
Returns a
SimpleScriptContext . |
Object |
invokeFunction(String name,
Object... args) |
Object |
invokeMethod(Object thiz,
String name,
Object... args) |
protected Compiler.ICtx |
makeCtx(ScriptContext sc) |
void |
put(String key,
Object value) |
void |
setBindings(Bindings bindings,
int scope) |
void |
setContext(ScriptContext ctxt)
Sets the value of the protected
context field to the specified ScriptContext
. |
protected final ScriptEngineFactory factory
protected ScriptContext defScriptContext
protected Compiler comp
protected ExplangScriptEngine(Bindings bindings)
protected ExplangScriptEngine()
protected ExplangScriptEngine(ScriptEngineFactory factory)
protected Compiler.ICtx makeCtx(ScriptContext sc)
public Object eval(String script, ScriptContext context) throws ScriptException
eval
in interface ScriptEngine
ScriptException
public Object eval(Reader reader, ScriptContext context) throws ScriptException
eval
in interface ScriptEngine
ScriptException
public Object eval(String script) throws ScriptException
eval
in interface ScriptEngine
ScriptException
public Object eval(Reader reader) throws ScriptException
eval
in interface ScriptEngine
ScriptException
public Object eval(String script, Bindings bindings) throws ScriptException
eval
in interface ScriptEngine
ScriptException
public Object eval(Reader reader, Bindings bindings) throws ScriptException
eval(Reader, Bindings)
calls the abstract eval(Reader, ScriptContext)
method, passing it a ScriptContext
whose Reader, Writers and Bindings for scopes
other that ENGINE_SCOPE
are identical to those members of the protected
context
field. The specified Bindings
is used instead of the
ENGINE_SCOPE
Bindings
of the context
field.eval
in interface ScriptEngine
reader
- A Reader
containing the source of the script.bindings
- A Bindings
to use for the ENGINE_SCOPE
while the
script executes.eval(Reader, ScriptContext)
ScriptException
- if an error occurs in script.NullPointerException
- if any of the parameters is null.public void put(String key, Object value)
put
in interface ScriptEngine
public Object get(String key)
ENGINE_SCOPE
of the protected
context
field.get
in interface ScriptEngine
NullPointerException
- if key is null.IllegalArgumentException
- if key is empty.public Bindings getBindings(int scope)
Bindings
with the specified scope value in the protected context
field.getBindings
in interface ScriptEngine
scope
- The specified scopeBindings
.IllegalArgumentException
- if the value of scope is invalid for the type the protected
context
field.public void setBindings(Bindings bindings, int scope)
setBindings
in interface ScriptEngine
public Bindings createBindings()
createBindings
in interface ScriptEngine
public ScriptContext getContext()
getContext
in interface ScriptEngine
public void setContext(ScriptContext ctxt)
context
field to the specified ScriptContext
.setContext
in interface ScriptEngine
ctxt
- The specified ScriptContext
.NullPointerException
- if ctxt is null.public ScriptEngineFactory getFactory()
getFactory
in interface ScriptEngine
protected ScriptContext getScriptContext(Bindings nn)
SimpleScriptContext
. The SimpleScriptContext
: Bindings
for its ENGINE_SCOPE
Bindings
returned by the abstract getGlobalScope
method as its GLOBAL_SCOPE
ScriptContext
of this
ScriptEngine
SimpleScriptContext
returned by this method is used to implement eval methods
using the abstract eval(Reader,Bindings)
and eval(String,Bindings)
versions.nn
- Bindings to use for the ENGINE_SCOPE
SimpleScriptContext
public Object invokeMethod(Object thiz, String name, Object... args) throws ScriptException, NoSuchMethodException
invokeMethod
in interface Invocable
ScriptException
NoSuchMethodException
public Object invokeFunction(String name, Object... args) throws ScriptException, NoSuchMethodException
invokeFunction
in interface Invocable
ScriptException
NoSuchMethodException
public <T> T getInterface(Class<T> clasz)
getInterface
in interface Invocable
public <T> T getInterface(Object thiz, Class<T> clasz)
getInterface
in interface Invocable
Copyright © 2022. All rights reserved.