public class ExprSimpleScriptContext
extends java.lang.Object
implements javax.script.ScriptContext
Modifier and Type | Field and Description |
---|---|
protected javax.script.Bindings |
engineScope
This is the engine scope bindings.
|
protected java.io.Writer |
errorWriter
This is the writer to be used to output errors from scripts.
|
protected javax.script.Bindings |
globalScope
This is the global scope bindings.
|
protected java.io.Reader |
reader
This is the reader to be used for input from scripts.
|
protected java.io.Writer |
writer
This is the writer to be used to output from scripts.
|
Constructor and Description |
---|
ExprSimpleScriptContext() |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
getAttribute(java.lang.String name)
Retrieves the value of the attribute with the given name in
the scope occurring earliest in the search order.
|
java.lang.Object |
getAttribute(java.lang.String name,
int scope)
Gets the value of an attribute in a given scope.
|
int |
getAttributesScope(java.lang.String name)
Get the lowest scope in which an attribute is defined.
|
javax.script.Bindings |
getBindings(int scope)
Returns the value of the
engineScope field if specified scope is
ENGINE_SCOPE . |
java.io.Writer |
getErrorWriter() |
java.io.Reader |
getReader() |
java.util.List<java.lang.Integer> |
getScopes() |
java.io.Writer |
getWriter() |
java.lang.Object |
removeAttribute(java.lang.String name,
int scope)
Remove an attribute in a given scope.
|
void |
setAttribute(java.lang.String name,
java.lang.Object value,
int scope)
Sets the value of an attribute in a given scope.
|
void |
setBindings(javax.script.Bindings bindings,
int scope)
Sets a
Bindings of attributes for the given scope. |
void |
setErrorWriter(java.io.Writer writer) |
void |
setReader(java.io.Reader reader) |
void |
setWriter(java.io.Writer writer) |
protected java.io.Writer writer
PrintWriter
based on System.out
is used. Accessor methods getWriter, setWriter are used to manage
this field.System.out
,
PrintWriter
protected java.io.Writer errorWriter
PrintWriter
based on System.err
is
used. Accessor methods getErrorWriter, setErrorWriter are used to manage
this field.System.err
,
PrintWriter
protected java.io.Reader reader
InputStreamReader
based on System.in
is used and default charset is used by this reader. Accessor methods
getReader, setReader are used to manage this field.System.in
,
InputStreamReader
protected javax.script.Bindings engineScope
SimpleBindings
is used. Accessor
methods setBindings, getBindings are used to manage this field.SimpleBindings
protected javax.script.Bindings globalScope
public void setBindings(javax.script.Bindings bindings, int scope)
Bindings
of attributes for the given scope. If the value
of scope is ENGINE_SCOPE
the given Bindings
replaces the
engineScope
field. If the value
of scope is GLOBAL_SCOPE
the given Bindings
replaces the
globalScope
field.setBindings
in interface javax.script.ScriptContext
bindings
- The Bindings
of attributes to set.scope
- The value of the scope in which the attributes are set.java.lang.IllegalArgumentException
- if scope is invalid.java.lang.NullPointerException
- if the value of scope is ENGINE_SCOPE
and
the specified Bindings
is null.public java.lang.Object getAttribute(java.lang.String name)
getAttribute
in interface javax.script.ScriptContext
name
- The name of the the attribute to retrieve.java.lang.NullPointerException
- if the name is null.java.lang.IllegalArgumentException
- if the name is empty.public java.lang.Object getAttribute(java.lang.String name, int scope)
getAttribute
in interface javax.script.ScriptContext
name
- The name of the attribute to retrieve.scope
- The scope in which to retrieve the attribute.null
is the name
does not exist in the given scope.java.lang.IllegalArgumentException
- if the name is empty or if the value of scope is invalid.java.lang.NullPointerException
- if the name is null.public java.lang.Object removeAttribute(java.lang.String name, int scope)
removeAttribute
in interface javax.script.ScriptContext
name
- The name of the attribute to removescope
- The scope in which to remove the attributejava.lang.IllegalArgumentException
- if the name is empty or if the scope is invalid.java.lang.NullPointerException
- if the name is null.public void setAttribute(java.lang.String name, java.lang.Object value, int scope)
setAttribute
in interface javax.script.ScriptContext
name
- The name of the attribute to setvalue
- The value of the attributescope
- The scope in which to set the attributejava.lang.IllegalArgumentException
- if the name is empty or if the scope is invalid.java.lang.NullPointerException
- if the name is null.public java.io.Writer getWriter()
getWriter
in interface javax.script.ScriptContext
public java.io.Reader getReader()
getReader
in interface javax.script.ScriptContext
public void setReader(java.io.Reader reader)
setReader
in interface javax.script.ScriptContext
public void setWriter(java.io.Writer writer)
setWriter
in interface javax.script.ScriptContext
public java.io.Writer getErrorWriter()
getErrorWriter
in interface javax.script.ScriptContext
public void setErrorWriter(java.io.Writer writer)
setErrorWriter
in interface javax.script.ScriptContext
public int getAttributesScope(java.lang.String name)
getAttributesScope
in interface javax.script.ScriptContext
name
- Name of the attribute
.java.lang.NullPointerException
- if name is null.java.lang.IllegalArgumentException
- if name is empty.public javax.script.Bindings getBindings(int scope)
engineScope
field if specified scope is
ENGINE_SCOPE
. Returns the value of the globalScope
field if the specified scope is
GLOBAL_SCOPE
.getBindings
in interface javax.script.ScriptContext
scope
- The specified scopeengineScope
or globalScope
field.java.lang.IllegalArgumentException
- if the value of scope is invalid.public java.util.List<java.lang.Integer> getScopes()
getScopes
in interface javax.script.ScriptContext