|
JavaTM Platform Standard Ed. 6 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
java.lang.Objectjavax.script.SimpleScriptContext
public class SimpleScriptContext
ScriptContext 的简单实现。
| 字段摘要 | |
|---|---|
protected Bindings |
engineScope 此字段是引擎范围 bindings。 |
protected Writer |
errorWriter 此字段是用于脚本输出错误的 writer。 |
protected Bindings |
globalScope 此字段是全局范围 bindings。 |
protected Reader |
reader 此字段是用于脚本输入的 reader。 |
protected Writer |
writer 此字段是用于脚本输出的 writer。 |
| 从接口 javax.script.ScriptContext 继承的字段 |
|---|
ENGINE_SCOPE, GLOBAL_SCOPE |
| 构造方法摘要 | |
|---|---|
SimpleScriptContext() |
|
| 方法摘要 | |
|---|---|
Object |
getAttribute(String name) 获取范围中按搜索顺序最早出现的具有给定名称的属性的值。 |
Object |
getAttribute(String name, int scope) 获取给定范围中某一属性的值。 |
int |
getAttributesScope(String name) 获取用来定义属性的最小范围。 |
Bindings |
getBindings(int scope) 如果指定范围为 ENGINE_SCOPE,则返回 engineScope 字段的值。 |
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。 |
void |
setErrorWriter(Writer writer) 设置用来显示错误输出的 Writer。 |
void |
setReader(Reader reader) 设置脚本的 Reader,以读取输入。 |
void |
setWriter(Writer writer) 设置脚本的 Writer,以便在显示输出时使用。 |
| 从类 java.lang.Object 继承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 字段详细信息 |
|---|
protected Writer writer
System.out 的
PrintWriter。可使用存取方法 getWriter 和 setWriter 来管理此字段。
System.out,
PrintWriter
protected Writer errorWriter
System.err 的
PrintWriter。可使用存取方法 getErrorWriter 和 setErrorWriter 来管理此字段。
System.err,
PrintWriter
protected Reader reader
System.in 的
InputStreamReader 和默认字符集。可使用存取方法 getReader 和 setReader 来管理此字段。
System.in,
InputStreamReader
protected Bindings engineScope
SimpleBindings。可使用存取方法 setBindings 和 getBindings 来管理此字段。
SimpleBindings
protected Bindings globalScope
| 构造方法详细信息 |
|---|
public SimpleScriptContext()
| 方法详细信息 |
|---|
public void setBindings(Bindings bindings,
int scope)
Bindings。如果范围值为
ENGINE_SCOPE,则使用给定
Bindings 替代
engineScope 字段。如果范围值为
GLOBAL_SCOPE,则使用给定
Bindings 替换
globalScope 字段。
ScriptContext 中的
setBindings
bindings - 要设置的属性的
Bindings。
scope - 范围值,将在该范围中设置属性。
IllegalArgumentException - 如果 scope 无效。
NullPointerException - 如果 scope 的值为
ENGINE_SCOPE 并且指定的
Bindings 为 null。
public Object getAttribute(String name)
ScriptContext 中的
getAttribute
name - 要获取的属性的名称。
NullPointerException - 如果 name 为 null。
IllegalArgumentException - 如果 name 为空。
public Object getAttribute(String name,
int scope)
ScriptContext 中的
getAttribute
name - 要获取的属性名称。
scope - 将在其中获取属性的范围。
null 表示 name 不存在于给定范围中。
IllegalArgumentException - 如果 name 为空,或者 scope 的值无效。
NullPointerException - 如果 name 为 null。
public Object removeAttribute(String name,
int scope)
ScriptContext 中的
removeAttribute
name - 要移除的属性的名称
scope - 移除属性的范围
IllegalArgumentException - 如果 name 为空,或者 scope 无效。
NullPointerException - 如果 name 为 null。
public void setAttribute(String name,
Object value,
int scope)
ScriptContext 中的
setAttribute
name - 要设置的属性的名称
value - 属性值
scope - 属性的设置范围
IllegalArgumentException - 如果 name 为空,或者 scope 无效。
NullPointerException - 如果 name 为 null。
public Writer getWriter()
Writer,以便在显示输出时使用。
ScriptContext 中的
getWriter
Writer。
public Reader getReader()
Reader。
ScriptContext 中的
getReader
Reader。
public void setReader(Reader reader)
Reader,以读取输入。
ScriptContext 中的
setReader
reader - 新的
Reader。
public void setWriter(Writer writer)
Writer,以便在显示输出时使用。
ScriptContext 中的
setWriter
writer - 新的
Writer。
public Writer getErrorWriter()
Writer。
ScriptContext 中的
getErrorWriter
Writer
public void setErrorWriter(Writer writer)
Writer。
ScriptContext 中的
setErrorWriter
writer -
Writer。
public int getAttributesScope(String name)
ScriptContext 中的
getAttributesScope
name - 属性的名称。
NullPointerException - 如果 name 为 null。
IllegalArgumentException - 如果 name 为空。
public Bindings getBindings(int scope)
ENGINE_SCOPE,则返回
engineScope 字段的值。如果指定范围为
GLOBAL_SCOPE,则返回
globalScope 字段的值。
ScriptContext 中的
getBindings
scope - 指定范围
engineScope 或
globalScope 字段的值。
IllegalArgumentException - 如果 scope 的值无效。
public List<Integer> getScopes()
List。
ScriptContext 中的
getScopes
|
JavaTM Platform Standard Ed. 6 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策。