Class Overview
Implementation of ScriptEngine
using the Mozilla Rhino
interpreter.
Summary
[Expand]
Inherited Constants |
From interface
javax.script.ScriptEngine
String |
ARGV |
Reserved key for a named value that passes
an array of positional arguments to a script. |
String |
ENGINE |
Reserved key for a named value that is
the name of the ScriptEngine implementation. |
String |
ENGINE_VERSION |
Reserved key for a named value that identifies
the version of the ScriptEngine implementation. |
String |
FILENAME |
Reserved key for a named value that is
the name of the file being executed. |
String |
LANGUAGE |
Reserved key for a named value that is
the full name of Scripting Language supported by the implementation. |
String |
LANGUAGE_VERSION |
Reserved key for the named value that identifies
the version of the scripting language supported by the implementation. |
String |
NAME |
Reserved key for a named value that identifies
the short name of the scripting language. |
|
[Expand]
Inherited Methods |
From class
javax.script.AbstractScriptEngine
Object
|
eval(Reader reader)
eval(Reader) calls the abstract
eval(Reader, ScriptContext) passing the value of the context
field.
|
Object
|
eval(String script)
Same as eval(Reader) except that the abstract
eval(String, ScriptContext) is used.
|
Object
|
eval(String script, Bindings bindings)
Same as eval(Reader, Bindings) except that the abstract
eval(String, ScriptContext) is used.
|
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
|
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()
Returns the value of the protected context field.
|
ScriptContext
|
getScriptContext(Bindings nn)
Returns a SimpleScriptContext .
|
void
|
put(String key, Object value)
Sets the specified value with the specified key in the ENGINE_SCOPE
Bindings of the protected context field.
|
void
|
setBindings(Bindings bindings, int scope)
Sets the Bindings with the corresponding scope value in the
context field.
|
void
|
setContext(ScriptContext ctxt)
Sets the value of the protected context field to the specified
ScriptContext .
|
|
From class
java.lang.Object
Object
|
clone()
Creates and returns a copy of this object.
|
boolean
|
equals(Object obj)
Indicates whether some other object is "equal to" this one.
|
void
|
finalize()
Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
|
final
Class<?>
|
getClass()
Returns the runtime class of this Object .
|
int
|
hashCode()
Returns a hash code value for the object.
|
final
void
|
notify()
Wakes up a single thread that is waiting on this object's
monitor.
|
final
void
|
notifyAll()
Wakes up all threads that are waiting on this object's monitor.
|
String
|
toString()
Returns a string representation of the object.
|
final
void
|
wait()
Causes the current thread to wait until another thread invokes the
notify() method or the
notifyAll() method for this object.
|
final
void
|
wait(long timeout, int nanos)
Causes the current thread to wait until another thread invokes the
notify() method or the
notifyAll() method for this object, or
some other thread interrupts the current thread, or a certain
amount of real time has elapsed.
|
final
void
|
wait(long timeout)
Causes the current thread to wait until either another thread invokes the
notify() method or the
notifyAll() method for this object, or a
specified amount of time has elapsed.
|
|
From interface
javax.script.Compilable
|
From interface
javax.script.Invocable
abstract
<T>
T
|
getInterface(Class<T> clasz)
Returns an implementation of an interface using functions compiled in
the interpreter.
|
abstract
<T>
T
|
getInterface(Object thiz, Class<T> clasz)
Returns an implementation of an interface using member functions of
a scripting object compiled in the interpreter.
|
abstract
Object
|
invokeFunction(String name, Object... args)
Used to call top-level procedures and functions defined in scripts.
|
abstract
Object
|
invokeMethod(Object thiz, String name, Object... args)
Calls a method on a script object compiled during a previous script execution,
which is retained in the state of the ScriptEngine .
|
|
From interface
javax.script.ScriptEngine
abstract
Bindings
|
createBindings()
Returns an uninitialized Bindings .
|
abstract
Object
|
eval(String script, Bindings n)
Executes the script using the Bindings argument as the ENGINE_SCOPE
Bindings of the ScriptEngine during the script execution.
|
abstract
Object
|
eval(Reader reader, Bindings n)
Same as eval(String, Bindings) except that the source of the script
is provided as a Reader .
|
abstract
Object
|
eval(Reader reader)
Same as eval(String) except that the source of the script is
provided as a Reader
|
abstract
Object
|
eval(Reader reader, ScriptContext context)
Same as eval(String, ScriptContext) where the source of the script
is read from a Reader .
|
abstract
Object
|
eval(String script, ScriptContext context)
Causes the immediate execution of the script whose source is the String
passed as the first argument.
|
abstract
Object
|
eval(String script)
Executes the specified script.
|
abstract
Object
|
get(String key)
Retrieves a value set in the state of this engine.
|
abstract
Bindings
|
getBindings(int scope)
Returns a scope of named values.
|
abstract
ScriptContext
|
getContext()
Returns the default ScriptContext of the ScriptEngine whose Bindings, Reader
and Writers are used for script executions when no ScriptContext is specified.
|
abstract
ScriptEngineFactory
|
getFactory()
Returns a ScriptEngineFactory for the class to which this ScriptEngine belongs.
|
abstract
void
|
put(String key, Object value)
Sets a key/value pair in the state of the ScriptEngine that may either create
a Java Language Binding to be used in the execution of scripts or be used in some
other way, depending on whether the key is reserved.
|
abstract
void
|
setBindings(Bindings bindings, int scope)
Sets a scope of named values to be used by scripts.
|
abstract
void
|
setContext(ScriptContext context)
Sets the default ScriptContext of the ScriptEngine whose Bindings, Reader
and Writers are used for script executions when no ScriptContext is specified.
|
|
Public Constructors
public
RhinoScriptEngine
()
Creates a new instance of RhinoScriptEngine
Public Methods
Compiles the script (source read from Reader
) for
later execution. Functionality is identical to
compile(String)
other than the way in which the source is
passed.
Parameters
script
| The reader from which the script source is obtained. |
Returns
- An implementation of
CompiledScript
to be executed
later using one of its eval
methods of CompiledScript
.
Compiles the script (source represented as a String
) for
later execution.
Parameters
script
| The source of the script, represented as a String . |
Returns
- An subclass of
CompiledScript
to be executed later using one
of the eval
methods of CompiledScript
.
public
T
getInterface
(Class<T> clasz)
Returns an implementation of an interface using functions compiled in
the interpreter. The methods of the interface
may be implemented using the invokeFunction
method.
Parameters
clasz
| The Class object of the interface to return. |
Returns
- An instance of requested interface - null if the requested interface is unavailable,
i. e. if compiled functions in the
ScriptEngine
cannot be found matching
the ones in the requested interface.
public
T
getInterface
(Object thiz, Class<T> clasz)
Returns an implementation of an interface using member functions of
a scripting object compiled in the interpreter. The methods of the
interface may be implemented using the invokeMethod
method.
Parameters
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. |
Returns
- An instance of requested interface - null if the requested interface is unavailable,
i. e. if compiled methods in the
ScriptEngine
cannot be found matching
the ones in the requested interface.
Used to call top-level procedures and functions defined in scripts.
Parameters
args
| Arguments to pass to the procedure or function |
Returns
- The value returned by the procedure or function
Calls a method on a script object compiled during a previous script execution,
which is retained in the state of the ScriptEngine
.
Parameters
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. |
name
| The name of the procedure to be called. |
args
| Arguments to pass to the procedure. The rules for converting
the arguments to scripting variables are implementation-specific. |
Returns
- The value returned by the procedure. The rules for converting the scripting
variable returned by the script method to a Java Object are implementation-specific.