|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.script.AbstractScriptEngine
public abstract class AbstractScriptEngine
Provides a standard implementation for various versions of the eval() methods.
Stores the ScriptContext, and provides access to the Bindings stored in the context.
The class is not synchronized.
The default context - SimpleScriptContext
- is not synchronized either.
Sub-classes must provide synchronization if necessary.
See Javadoc of Java Scripting API
Field Summary | |
---|---|
protected ScriptContext |
context
The default ScriptContext of this AbstractScriptEngine |
Fields inherited from interface javax.script.ScriptEngine |
---|
ARGV, ENGINE, ENGINE_VERSION, FILENAME, LANGUAGE, LANGUAGE_VERSION, NAME |
Constructor Summary | |
---|---|
AbstractScriptEngine()
Constructs a ScriptEngine using an uninitialized SimpleScriptContext. |
|
AbstractScriptEngine(Bindings bindings)
Constructs a ScriptEngine using the specified Bindings as its ENGINE_SCOPE. |
Method Summary | |
---|---|
java.lang.Object |
eval(java.io.Reader reader)
Evaluates a script obtained using the specified reader as the script source. |
java.lang.Object |
eval(java.io.Reader reader,
Bindings bindings)
Evaluates a script obtained using a reader as the script source and using the specified namespace as the ENGINE_SCOPE. |
java.lang.Object |
eval(java.lang.String script)
Evaluates a script contained in a String and returns the resultant object. |
java.lang.Object |
eval(java.lang.String script,
Bindings bindings)
Evaluates a piece of script using the specified namespace as the ENGINE_SCOPE. |
java.lang.Object |
get(java.lang.String key)
Retrieves the value which is associated with the specified key in the state of the ScriptEngine. |
Bindings |
getBindings(int scope)
Retrieves a reference to the associated bindings for the specified scope. |
ScriptContext |
getContext()
Returns the default ScriptContext of the ScriptEngine whose Bindings, Readers and Writers are used for script executions when no ScriptContext is specified. |
protected ScriptContext |
getScriptContext(Bindings bindings)
Returns a SimpleScriptContext which:
uses the specified Bindings as the ScriptEngine#ENGINE_SCOPE
has the same GLOBAL_SCOPE Bindings as the current context
uses the same Reader, Writer and Error Writer as the current context
|
void |
put(java.lang.String key,
java.lang.Object value)
Associates a key and a value in the ScriptEngine ENGINE_SCOPE bindings. |
void |
setBindings(Bindings bindings,
int scope)
Associates the specified bindings with the specified scope. |
void |
setContext(ScriptContext context)
Sets the default ScriptContext of the ScriptEngine whose Bindings, Readers and Writers are used for script executions when no ScriptContext is specified. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface javax.script.ScriptEngine |
---|
createBindings, eval, eval, getFactory |
Field Detail |
---|
protected ScriptContext context
Constructor Detail |
---|
public AbstractScriptEngine()
public AbstractScriptEngine(Bindings bindings)
bindings
- the Bindings to be used as the ENGINE_SCOPE
java.lang.NullPointerException
- if the parameter is nullMethod Detail |
---|
public java.lang.Object eval(java.io.Reader reader) throws ScriptException
eval
in interface ScriptEngine
reader
- the source of the script
ScriptException
- if an error occurspublic java.lang.Object eval(java.io.Reader reader, Bindings bindings) throws ScriptException
eval
in interface ScriptEngine
reader
- the script source used to obtained the scriptbindings
- the bindings to be used as ENGINE_SCOPE
ScriptException
- if an error occurspublic java.lang.Object eval(java.lang.String script) throws ScriptException
eval
in interface ScriptEngine
script
- the String representation of the script
ScriptException
- if an error occurspublic java.lang.Object eval(java.lang.String script, Bindings bindings) throws ScriptException
eval
in interface ScriptEngine
script
- the String representation of the scriptbindings
- the bindings to be used as the ENGINE_SCOPE
ScriptException
- if an error occurspublic java.lang.Object get(java.lang.String key)
get
in interface ScriptEngine
key
- the key associated with value.
public Bindings getBindings(int scope)
getBindings
in interface ScriptEngine
scope
- the specified scope
protected ScriptContext getScriptContext(Bindings bindings)
SimpleScriptContext
which:
Bindings
as the ScriptEngine#ENGINE_SCOPE
bindings
- the bindings to be associated with ENGINE_SCOPE
java.lang.NullPointerException
- if bindings is nullpublic void put(java.lang.String key, java.lang.Object value)
put
in interface ScriptEngine
key
- the specified key associated with the valuevalue
- value which is to be associated with the
specified keypublic void setBindings(Bindings bindings, int scope)
setBindings
in interface ScriptEngine
bindings
- bindings to be associated with the specified scopescope
- scope which the bindings should be associated withpublic ScriptContext getContext()
getContext
in interface ScriptEngine
public void setContext(ScriptContext context)
setContext
in interface ScriptEngine
context
- scriptContext that will replace the default ScriptContext in the ScriptEngine.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |