| java.lang.Object javax.script.AbstractScriptEngine
All known Subclasses: bsh.engine.BshScriptEngine,
AbstractScriptEngine | abstract public class AbstractScriptEngine implements ScriptEngine(Code) | | Provides a standard implementation for several of the variants of the eval
method.
eval(Reader) eval(String)
eval(String, Bindings) eval(Reader, Bindings)
are implemented using the abstract methods
eval(Reader,ScriptContext) or
eval(String, ScriptContext)
with a SimpleScriptContext .
A SimpleScriptContext is used as the default ScriptContext
of the AbstractScriptEngine ..
author: Mike Grogan version: 1.0 since: 1.6
|
Field Summary | |
protected ScriptContext | context The default ScriptContext of this AbstractScriptEngine . |
Constructor Summary | |
public | AbstractScriptEngine() Creates a new instance of AbstractScriptEngine using a SimpleScriptContext
as its default ScriptContext . | public | AbstractScriptEngine(Bindings n) Creates a new instance using the specified Bindings as the
ENGINE_SCOPE Bindings in the protected ScriptContext field. |
Method Summary | |
public 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 ScriptContext field. | public Object | eval(String script, Bindings bindings) Same as eval(Reader, Bindings) except that the abstract
eval(String, ScriptContext) is used.
Parameters: script - A String containing the source of the script. Parameters: bindings - A Bindings to use as the ENGINE_SCOPE while the script executes. | public Object | eval(Reader reader) eval(Reader) calls the abstract
eval(Reader, ScriptContext) passing the value of the context
field.
Parameters: reader - A Reader containing the source of the script. | public Object | eval(String script) Same as eval(Reader) except that the abstract
eval(String, ScriptContext) is used.
Parameters: script - A String containing the source of the script. | public Object | get(String key) Gets the value for the specified key in the ENGINE_SCOPE of the
protected ScriptContext field. | public Bindings | getBindings(int scope) Returns the Bindings with the specified scope value in
the protected ScriptContext field.
Parameters: scope - The specified scope The corresponding Bindings . | public ScriptContext | getContext() Returns the value of the protected ScriptContext > field. | protected ScriptContext | getScriptContext(Bindings nn) Returns a SimpleScriptContext . | public void | put(String key, Object value) Sets the specified value with the specified key in the ENGINE_SCOPE
Bindings of the protected ScriptContext field. | public void | setBindings(Bindings bindings, int scope) Sets the Bindings with the corresponding scope value in the
context field.
Parameters: bindings - The specified Bindings . Parameters: scope - The specified scope. | public void | setContext(ScriptContext ctxt) Sets the value of the protected ScriptContext field to the specified
ScriptContext . |
context | protected ScriptContext context(Code) | | The default ScriptContext of this AbstractScriptEngine .
|
AbstractScriptEngine | public AbstractScriptEngine()(Code) | | Creates a new instance of AbstractScriptEngine using a SimpleScriptContext
as its default ScriptContext .
|
AbstractScriptEngine | public AbstractScriptEngine(Bindings n)(Code) | | Creates a new instance using the specified Bindings as the
ENGINE_SCOPE Bindings in the protected ScriptContext field.
Parameters: n - The specified Bindings . |
eval | public Object eval(Reader reader, Bindings bindings) throws ScriptException(Code) | | 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 ScriptContext field. The specified
Bindings is used instead of the ENGINE_SCOPE
Bindings of the context field.
Parameters: reader - A Reader containing the source of the script. Parameters: bindings - A Bindings to use for the ENGINE_SCOPE while the script executes. The return value from eval(Reader, ScriptContext) |
eval | public Object eval(String script, Bindings bindings) throws ScriptException(Code) | | Same as eval(Reader, Bindings) except that the abstract
eval(String, ScriptContext) is used.
Parameters: script - A String containing the source of the script. Parameters: bindings - A Bindings to use as the ENGINE_SCOPE while the script executes. The return value from eval(String, ScriptContext) |
eval | public Object eval(Reader reader) throws ScriptException(Code) | | eval(Reader) calls the abstract
eval(Reader, ScriptContext) passing the value of the context
field.
Parameters: reader - A Reader containing the source of the script. The return value from eval(Reader, ScriptContext) |
eval | public Object eval(String script) throws ScriptException(Code) | | Same as eval(Reader) except that the abstract
eval(String, ScriptContext) is used.
Parameters: script - A String containing the source of the script. The return value from eval(String, ScriptContext) |
get | public Object get(String key)(Code) | | Gets the value for the specified key in the ENGINE_SCOPE of the
protected ScriptContext field.
The value for the specified key. |
getBindings | public Bindings getBindings(int scope)(Code) | | Returns the Bindings with the specified scope value in
the protected ScriptContext field.
Parameters: scope - The specified scope The corresponding Bindings . IllegalArgumentException if the value of scope isinvalid for the type the protected ScriptContext field. |
getContext | public ScriptContext getContext()(Code) | | Returns the value of the protected ScriptContext > field.
The value of the protected ScriptContext field. |
getScriptContext | protected ScriptContext getScriptContext(Bindings nn)(Code) | | Returns a SimpleScriptContext . The SimpleScriptContext :
- Uses the specified
Bindings for its ENGINE_SCOPE
- Uses the
Bindings returned by the abstract getGlobalScope
method as its GLOBAL_SCOPE
- Uses the Reader and Writer in the default
ScriptContext of this
ScriptEngine
A SimpleScriptContext returned by this method is used to implement eval methods
using the abstract eval(Reader,Bindings) and eval(String,Bindings)
versions.
Parameters: nn - Bindings to use for the ENGINE_SCOPE The SimpleScriptContext |
put | public void put(String key, Object value)(Code) | | Sets the specified value with the specified key in the ENGINE_SCOPE
Bindings of the protected ScriptContext field.
Parameters: key - The specified key. Parameters: value - The specified value. |
setBindings | public void setBindings(Bindings bindings, int scope)(Code) | | Sets the Bindings with the corresponding scope value in the
context field.
Parameters: bindings - The specified Bindings . Parameters: scope - The specified scope. IllegalArgumentException if the value of scope isinvalid for the type the context field. |
setContext | public void setContext(ScriptContext ctxt)(Code) | | Sets the value of the protected ScriptContext field to the specified
ScriptContext .
Parameters: ctxt - The specified ScriptContext . |
|
|