程序包 com.script
类 AbstractScriptEngine
java.lang.Object
com.script.AbstractScriptEngine
- 所有已实现的接口:
ScriptEngine
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..
- 从以下版本开始:
- 1.6
-
字段概要
字段从接口继承的字段 com.script.ScriptEngine
FILENAME -
构造器概要
构造器构造器说明Creates a new instance of AbstractScriptEngine using aSimpleScriptContextas its defaultScriptContext.Creates a new instance using the specifiedBindingsas theENGINE_SCOPEBindingsin the protectedcontextfield. -
方法概要
修饰符和类型方法说明eval(Reader)calls the abstracteval(Reader, ScriptContext)passing the value of thecontextfield.eval(Reader, Bindings)calls the abstracteval(Reader, ScriptContext)method, passing it aScriptContextwhose Reader, Writers and Bindings for scopes other thatENGINE_SCOPEare identical to those members of the protectedcontextfield.Same aseval(Reader)except that the abstracteval(String, ScriptContext)is used.Same aseval(Reader, Bindings)except that the abstracteval(String, ScriptContext)is used.Gets the value for the specified key in theENGINE_SCOPEof the protectedcontextfield.getBindings(int scope) Returns theBindingswith the specified scope value in the protectedcontextfield.Returns the value of the protectedcontextfield.protected ScriptContextReturns aSimpleScriptContext.voidSets the specified value with the specified key in theENGINE_SCOPEBindingsof the protectedcontextfield.voidsetBindings(Bindings bindings, int scope) Sets theBindingswith the corresponding scope value in thecontextfield.voidsetContext(ScriptContext ctxt) Sets the value of the protectedcontextfield to the specifiedScriptContext.从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait从接口继承的方法 com.script.ScriptEngine
createBindings, eval, eval
-
字段详细资料
-
context
The defaultScriptContextof thisAbstractScriptEngine.
-
-
构造器详细资料
-
AbstractScriptEngine
public AbstractScriptEngine()Creates a new instance of AbstractScriptEngine using aSimpleScriptContextas its defaultScriptContext. -
AbstractScriptEngine
Creates a new instance using the specifiedBindingsas theENGINE_SCOPEBindingsin the protectedcontextfield.- 参数:
n- The specifiedBindings.- 抛出:
NullPointerException- if n is null.
-
-
方法详细资料
-
setContext
Sets the value of the protectedcontextfield to the specifiedScriptContext.- 指定者:
setContext在接口中ScriptEngine- 参数:
ctxt- The specifiedScriptContext.- 抛出:
NullPointerException- if ctxt is null.
-
getContext
Returns the value of the protectedcontextfield.- 指定者:
getContext在接口中ScriptEngine- 返回:
- The value of the protected
contextfield.
-
getBindings
Returns theBindingswith the specified scope value in the protectedcontextfield.- 指定者:
getBindings在接口中ScriptEngine- 参数:
scope- The specified scope- 返回:
- The corresponding
Bindings. - 抛出:
IllegalArgumentException- if the value of scope is invalid for the type the protectedcontextfield.
-
setBindings
Sets theBindingswith the corresponding scope value in thecontextfield.- 指定者:
setBindings在接口中ScriptEngine- 参数:
bindings- The specifiedBindings.scope- The specified scope.- 抛出:
IllegalArgumentException- if the value of scope is invalid for the type thecontextfield.NullPointerException- if the bindings is null and the scope isScriptContext.ENGINE_SCOPE
-
put
Sets the specified value with the specified key in theENGINE_SCOPEBindingsof the protectedcontextfield.- 指定者:
put在接口中ScriptEngine- 参数:
key- The specified key.value- The specified value.- 抛出:
NullPointerException- if key is null.IllegalArgumentException- if key is empty.
-
get
Gets the value for the specified key in theENGINE_SCOPEof the protectedcontextfield.- 指定者:
get在接口中ScriptEngine- 参数:
key- The key whose value is to be returned- 返回:
- The value for the specified key.
- 抛出:
NullPointerException- if key is null.IllegalArgumentException- if key is empty.
-
eval
eval(Reader, Bindings)calls the abstracteval(Reader, ScriptContext)method, passing it aScriptContextwhose Reader, Writers and Bindings for scopes other thatENGINE_SCOPEare identical to those members of the protectedcontextfield. The specifiedBindingsis used instead of theENGINE_SCOPEBindingsof thecontextfield.- 指定者:
eval在接口中ScriptEngine- 参数:
reader- AReadercontaining the source of the script.bindings- ABindingsto use for theENGINE_SCOPEwhile the script executes.- 返回:
- The return value from
eval(Reader, ScriptContext) - 抛出:
ScriptException- if an error occurs in script.NullPointerException- if any of the parameters is null.
-
eval
Same aseval(Reader, Bindings)except that the abstracteval(String, ScriptContext)is used.- 指定者:
eval在接口中ScriptEngine- 参数:
script- AStringcontaining the source of the script.bindings- ABindingsto use as theENGINE_SCOPEwhile the script executes.- 返回:
- The return value from
eval(String, ScriptContext) - 抛出:
ScriptException- if an error occurs in script.NullPointerException- if any of the parameters is null.
-
eval
eval(Reader)calls the abstracteval(Reader, ScriptContext)passing the value of thecontextfield.- 指定者:
eval在接口中ScriptEngine- 参数:
reader- AReadercontaining the source of the script.- 返回:
- The return value from
eval(Reader, ScriptContext) - 抛出:
ScriptException- if an error occurs in script.NullPointerException- if any of the parameters is null.
-
eval
Same aseval(Reader)except that the abstracteval(String, ScriptContext)is used.- 指定者:
eval在接口中ScriptEngine- 参数:
script- AStringcontaining the source of the script.- 返回:
- The return value from
eval(String, ScriptContext) - 抛出:
ScriptException- if an error occurs in script.NullPointerException- if any of the parameters is null.
-
getScriptContext
Returns aSimpleScriptContext. TheSimpleScriptContext:
- Uses the specified
Bindingsfor itsENGINE_SCOPE - Uses the
Bindingsreturned by the abstractgetGlobalScopemethod as itsGLOBAL_SCOPE - Uses the Reader and Writer in the default
ScriptContextof thisScriptEngine
ASimpleScriptContextreturned by this method is used to implement eval methods using the abstracteval(Reader,Bindings)andeval(String,Bindings)versions.- 参数:
nn- Bindings to use for theENGINE_SCOPE- 返回:
- The
SimpleScriptContext
- Uses the specified
-