|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.script.AbstractScriptEngine
bsh.BshScriptEngine
public class BshScriptEngine
Field Summary |
---|
Fields inherited from class javax.script.AbstractScriptEngine |
---|
context |
Fields inherited from interface javax.script.ScriptEngine |
---|
ARGV, ENGINE, ENGINE_VERSION, FILENAME, LANGUAGE, LANGUAGE_VERSION, NAME |
Constructor Summary | |
---|---|
BshScriptEngine()
|
|
BshScriptEngine(BshScriptEngineFactory factory)
|
Method Summary | ||
---|---|---|
javax.script.CompiledScript |
compile(java.io.Reader script)
Compiles the script (source read from Reader ) for later
execution. |
|
javax.script.CompiledScript |
compile(java.lang.String script)
Compiles the script (source represented as a String ) for later
execution. |
|
javax.script.Bindings |
createBindings()
|
|
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()
|
|
|
getInterface(java.lang.Class<T> clasz)
Returns an implementation of an interface using procedures compiled in the interpreter. |
|
|
getInterface(java.lang.Object thiz,
java.lang.Class<T> clasz)
Returns an implementation of an interface using member functions of a scripting object compiled in the interpreter. |
|
protected Interpreter |
getInterpreter()
|
|
java.lang.Object |
invokeFunction(java.lang.String name,
java.lang.Object... args)
Same as invoke(Object, String, Object...) with null as the
first argument. |
|
java.lang.Object |
invokeMethod(java.lang.Object thiz,
java.lang.String name,
java.lang.Object... args)
Calls a procedure compiled during a previous script execution, which is retained in the state of the {@code ScriptEngine{@code . |
Methods inherited from class javax.script.AbstractScriptEngine |
---|
eval, eval, eval, eval, get, getBindings, getContext, getScriptContext, put, setBindings, setContext |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BshScriptEngine()
public BshScriptEngine(BshScriptEngineFactory factory)
Method Detail |
---|
protected Interpreter getInterpreter()
public java.lang.Object eval(java.lang.String script, javax.script.ScriptContext scriptContext) 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 scriptContext) throws javax.script.ScriptException
eval
in interface javax.script.ScriptEngine
javax.script.ScriptException
public javax.script.Bindings createBindings()
createBindings
in interface javax.script.ScriptEngine
public javax.script.ScriptEngineFactory getFactory()
getFactory
in interface javax.script.ScriptEngine
public javax.script.CompiledScript compile(java.lang.String script) throws javax.script.ScriptException
String
) for later
execution.
compile
in interface javax.script.Compilable
script
- The source of the script, represented as a String
.
CompiledScript
to be executed later
using one of the eval
methods of CompiledScript
.
javax.script.ScriptException
- if compilation fails.
java.lang.NullPointerException
- if the argument is null.public javax.script.CompiledScript compile(java.io.Reader script) throws javax.script.ScriptException
Reader
) for later
execution. Functionality is identical to compile(String)
other
than the way in which the source is passed.
compile
in interface javax.script.Compilable
script
- The reader from which the script source is obtained.
CompiledScript
to be executed
later using one of its eval
methods of
CompiledScript
.
javax.script.ScriptException
- if compilation fails.
java.lang.NullPointerException
- if argument is null.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
name
- The name of the procedure to be called.thiz
- If the procedure is a member of a class defined in the script
and thiz is an instance of that class returned by a previous execution or
invocation, the named method is called through that instance. If classes are
not supported in the scripting language or if the procedure is not a member
function of any class, the argument must be null
.args
- Arguments to pass to the procedure. The rules for converting
the arguments to scripting variables are implementation-specific.
javax.script.ScriptException
- if an error occurrs during invocation
of the method.
java.lang.NoSuchMethodException
- if method with given name or matching argument
types cannot be found.
java.lang.NullPointerException
- if method name is null.public java.lang.Object invokeFunction(java.lang.String name, java.lang.Object... args) throws javax.script.ScriptException, java.lang.NoSuchMethodException
null
as the
first argument. Used to call top-level procedures defined in scripts.
invokeFunction
in interface javax.script.Invocable
args
- Arguments to pass to the procedure
javax.script.ScriptException
- if an error occurrs during invocation
of the method.
java.lang.NoSuchMethodException
- if method with given name or matching
argument types cannot be found.
java.lang.NullPointerException
- if method name is null.public <T> T getInterface(java.lang.Class<T> clasz)
invoke
method.
getInterface
in interface javax.script.Invocable
clasz
- The Class
object of the interface to return.
ScriptEngine
cannot be found matching the ones in the
requested interface.
java.lang.IllegalArgumentException
- if the specified Class
object
does not exist or is not an interface.public <T> T getInterface(java.lang.Object thiz, java.lang.Class<T> clasz)
getInterface
in interface javax.script.Invocable
thiz
- The scripting object whose member functions are used to
implement the methods of the interface.clasz
- The Class
object of the interface to return.
ScriptEngine
cannot be found matching the ones in the
requested interface.
java.lang.IllegalArgumentException
- if the specified Class
object
does not exist or is not an interface, or if the specified Object is null
or does not represent a scripting object.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |