|
JavaTM Platform Standard Ed. 6 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
public interface ScriptContext
该接口的实现类被用来连接 Script Engines 和宿主应用程序中的对象(如有范围的 Bindings)。每个范围都是一个指定属性集,这些属性的值可以使用 ScriptContext 方法设置和获取。ScriptContext 还公开可由 ScriptEngine 用于输入和输出的 Reader 和 Writer。
| 字段摘要 | |
|---|---|
static int |
ENGINE_SCOPE
EngineScope 属性在单个 ScriptEngine 的生存期是可见的,并为每个引擎维护一个属性集。 |
static int |
GLOBAL_SCOPE
GlobalScope 属性对于同一 ScriptEngineFactory 创建的所有引擎都是可见的。 |
| 方法摘要 | |
|---|---|
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 方法的调用必须映射到指定范围的 Bindings 的 get 和 put 方法。
bindings - 与给定范围关联的 Bindingsscope - 范围
IllegalArgumentException - 如果没有为此类型 ScriptContext 中的指定范围值定义 Bindings。
NullPointerException - 如果 scope 的值为 ENGINE_SCOPE 并且指定的 Bindings 为 null。Bindings getBindings(int scope)
ScriptContext 中的给定范围关联的 Bindings。
Bindings。如果尚未设置,则返回 null。
IllegalArgumentException - 如果没有为此类型的 ScriptContext 中的指定范围值定义 Bindings。
void setAttribute(String name,
Object value,
int scope)
name - 要设置的属性的名称value - 属性值scope - 属性的设置范围
IllegalArgumentException - 如果 name 为空,或者 scope 无效。
NullPointerException - 如果 name 为 null。
Object getAttribute(String name,
int scope)
name - 要获取的属性名称。scope - 将在其中获取属性的范围。
null 表示 name 不存在于给定范围中。
IllegalArgumentException - 如果 name 为空,或者 scope 的值无效。
NullPointerException - 如果 name 为 null。
Object removeAttribute(String name,
int scope)
name - 要移除的属性的名称scope - 移除属性的范围
IllegalArgumentException - 如果 name 为空,或者 scope 无效。
NullPointerException - 如果 name 为 null。Object getAttribute(String name)
name - 要获取的属性的名称。
NullPointerException - 如果 name 为 null。
IllegalArgumentException - 如果 name 为空。int getAttributesScope(String name)
name - 属性的名称。
NullPointerException - 如果 name 为 null。
IllegalArgumentException - 如果 name 为空。Writer getWriter()
Writer,以便在显示输出时使用。
Writer。Writer getErrorWriter()
Writer。
Writervoid setWriter(Writer writer)
Writer,以便在显示输出时使用。
writer - 新的 Writer。void setErrorWriter(Writer writer)
Writer。
writer - Writer。Reader getReader()
Reader。
Reader。void setReader(Reader reader)
Reader,以读取输入。
reader - 新的 Reader。List<Integer> getScopes()
List。
|
JavaTM Platform Standard Ed. 6 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策。