public interface ScriptContext
ScriptContext
方法检索属性。scriptcontexts也让读者和作者可以通过输入和输出的scriptengines使用。
Modifier and Type | Field and Description |
---|---|
static int |
ENGINE_SCOPE
EngineScope把一个
ScriptEngine 和一组属性是保持每个引擎的寿命期间是可见的。
|
static int |
GLOBAL_SCOPE
全球范围的属性是通过同ScriptEngineFactory创建的所有引擎可见。
|
Modifier and Type | Method and Description |
---|---|
Object |
getAttribute(String name)
在搜索顺序中最早出现的范围中检索给定名称的属性的值。
|
Object |
getAttribute(String name, int scope)
获取给定范围内的属性的值。
|
int |
getAttributesScope(String name)
获取定义属性的最低范围。
|
Bindings |
getBindings(int scope)
获取与给定的范围,在这
ScriptContext 相关的
Bindings 。
|
Writer |
getErrorWriter()
返回用于显示错误输出的
Writer 。
|
Reader |
getReader()
返回一个
Reader 被脚本用来读取输入。
|
List<Integer> |
getScopes()
在scriptcontext范围内的所有有效值不变的
List 返回。
|
Writer |
getWriter()
返回
Writer 脚本时使用的显示输出。
|
Object |
removeAttribute(String name, int scope)
在给定范围中删除属性。
|
void |
setAttribute(String name, Object value, int scope)
在给定范围内设置属性的值。
|
void |
setBindings(Bindings bindings, int scope)
把
Bindings 实例在这
ScriptContext 特定范围。
|
void |
setErrorWriter(Writer writer)
设置用于显示错误输出的
Writer 。
|
void |
setReader(Reader reader)
设置脚本读取输入的
Reader 。
|
void |
setWriter(Writer writer)
集
Writer 脚本时使用的显示输出。
|
static final int ENGINE_SCOPE
ScriptEngine
和一组属性是保持每个引擎的寿命期间是可见的。
static final int GLOBAL_SCOPE
void setBindings(Bindings bindings, int scope)
Bindings
实例在这
ScriptContext
特定范围。打电话给
getAttribute
和
setAttribute
方法必须为指定范围的Map的
Bindings
的
get
和
put
方法。
bindings
-
Bindings
与给定范围内的副
scope
-范围
IllegalArgumentException
-如果没有
Bindings
是规定范围的值,这种类型的scriptcontexts定义。
NullPointerException
如果值的范围是
ENGINE_SCOPE
和指定的
Bindings
是空的。
Bindings getBindings(int scope)
ScriptContext
相关的
Bindings
。
scope
-范围
Bindings
。返回
null
如果没有设置。
IllegalArgumentException
-如果没有
Bindings
是规定范围的值,这种类型的
ScriptContext
定义。
void setAttribute(String name, Object value, int scope)
name
-属性的名称设置
value
-该属性的值
scope
——范围设置属性
IllegalArgumentException
-如果范围无效的名称为空或。
NullPointerException
-如果名称是空的。
Object getAttribute(String name, int scope)
name
-属性名称检索。
scope
——范围检索属性。
null
是名不在规定的范围内存在。
IllegalArgumentException
-如果范围值无效的名称为空或。
NullPointerException
-如果名称是空的。
Object removeAttribute(String name, int scope)
name
-属性的名称删除
scope
——范围删除属性
IllegalArgumentException
-如果范围无效的名称为空或。
NullPointerException
-如果名称是空的。
Object getAttribute(String name)
name
的属性名称检索。
NullPointerException
-如果名称是空的。
IllegalArgumentException
-如果名称是空的。
int getAttributesScope(String name)
name
-属性名称。
NullPointerException
如果名称是空的。
IllegalArgumentException
如果名称是空的。
Writer getWriter()
Writer
脚本时使用的显示输出。
Writer
。
Writer getErrorWriter()
Writer
。
Writer
void setWriter(Writer writer)
Writer
脚本时使用的显示输出。
writer
-新的
Writer
。
void setErrorWriter(Writer writer)
Writer
用来显示错误输出。
writer
-
Writer
。
Reader getReader()
Reader
被脚本用来读取输入。
Reader
。
void setReader(Reader reader)
Reader
。
reader
-新的
Reader
。
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.