|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.script.SimpleScriptContext
public class SimpleScriptContext
A simple implementation of ScriptContext
.
This class is not synchronized.
See Javadoc of Java Scripting API
Field Summary | |
---|---|
protected Bindings |
engineScope
This is the scope bindings for ENGINE_SCOPE . |
protected Writer |
errorWriter
The writer to be used for displaying error output from scripts |
protected Bindings |
globalScope
This is the scope bindings for GLOBAL_SCOPE. |
protected Reader |
reader
The reader to be used for input from scripts. |
protected Writer |
writer
The writer to be used for displaying output from scripts |
Fields inherited from interface javax.script.ScriptContext |
---|
ENGINE_SCOPE, GLOBAL_SCOPE |
Constructor Summary | |
---|---|
SimpleScriptContext()
Create a new instance, setting the Reader and Writers from the corresponding System streams. |
Method Summary | |
---|---|
Object |
getAttribute(String name)
Retrieves the value of the getAttribute(String, int) for the lowest scope in which it returns a non-null value. |
Object |
getAttribute(String name,
int scope)
Retrieves the value of an attribute in the specified scope. |
int |
getAttributesScope(String name)
Retrieves the lowest value of the scope for which the attribute is defined. |
Bindings |
getBindings(int scope)
Retrieves the Bindings instance associated with the given scope. |
Writer |
getErrorWriter()
Returns the Writer to be used to display error output. |
Reader |
getReader()
Returns a Reader to be used by the script to read input. |
List |
getScopes()
Returns an immutable List of all the valid values for scope in the ScriptContext. |
Writer |
getWriter()
Retrieves an instance of java.io.Writer which can be used by scripts to display their output. |
Object |
removeAttribute(String name,
int scope)
Removes the given attribute from the specified scope. |
void |
setAttribute(String name,
Object value,
int scope)
Associates a specified value with the specifed name in the specified scope. |
void |
setBindings(Bindings bindings,
int scope)
Associates the specified Bindings with the specified scope. |
void |
setErrorWriter(Writer writer)
Sets the Writer for scripts to use when displaying error output. |
void |
setReader(Reader reader)
Sets the Reader to be used by the script to read input. |
void |
setWriter(Writer writer)
Sets the Writer for scripts to use when displaying output. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Bindings globalScope
protected Bindings engineScope
protected Reader reader
protected Writer writer
protected Writer errorWriter
Constructor Detail |
---|
public SimpleScriptContext()
Method Detail |
---|
public Object getAttribute(String name)
getAttribute
in interface ScriptContext
name
- the name of the attribute
public Object getAttribute(String name, int scope)
getAttribute
in interface ScriptContext
name
- the name of the attributescope
- the value of the scope
public int getAttributesScope(String name)
getAttributesScope
in interface ScriptContext
name
- the name of attribute
public Bindings getBindings(int scope)
getBindings
in interface ScriptContext
scope
- the scope
public Object removeAttribute(String name, int scope)
removeAttribute
in interface ScriptContext
name
- the name of the attributescope
- the scope from which to remove the attribute
public void setAttribute(String name, Object value, int scope)
setAttribute
in interface ScriptContext
name
- the name of the attributevalue
- the value of the attributescope
- the scopepublic void setBindings(Bindings bindings, int scope)
setBindings
in interface ScriptContext
bindings
- the Bindings to be associated with the
specified scopescope
- the scopepublic List getScopes()
getScopes
in interface ScriptContext
public Reader getReader()
getReader
in interface ScriptContext
public void setReader(Reader reader)
setReader
in interface ScriptContext
reader
- the new readerpublic Writer getWriter()
getWriter
in interface ScriptContext
public void setWriter(Writer writer)
setWriter
in interface ScriptContext
writer
- the new writer.public Writer getErrorWriter()
getErrorWriter
in interface ScriptContext
public void setErrorWriter(Writer writer)
setErrorWriter
in interface ScriptContext
writer
- the new writer.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |