public class ExplangScriptContext extends Object implements ScriptContext
| Modifier and Type | Field and Description |
|---|---|
protected Bindings |
engineScope
This is the engine scope bindings.
|
protected Writer |
errorWriter
This is the writer to be used to output errors from scripts.
|
protected Bindings |
globalScope
This is the global scope bindings.
|
protected Reader |
reader
This is the reader to be used for input from scripts.
|
protected Writer |
writer
This is the writer to be used to output from scripts.
|
ENGINE_SCOPE, GLOBAL_SCOPE| Constructor and Description |
|---|
ExplangScriptContext()
Create an instance.
|
| Modifier and Type | Method and Description |
|---|---|
Object |
getAttribute(String name)
Retrieves the value of the attribute with the given name in the scope occurring earliest in the
search order.
|
Object |
getAttribute(String name,
int scope)
Gets the value of an attribute in a given scope.
|
int |
getAttributesScope(String name)
Get the lowest scope in which an attribute is defined.
|
Bindings |
getBindings(int scope)
Returns the value of the
engineScope field if specified scope is
ENGINE_SCOPE. |
Writer |
getErrorWriter() |
Reader |
getReader() |
List<Integer> |
getScopes() |
Writer |
getWriter() |
Object |
removeAttribute(String name,
int scope)
Remove an attribute in a given scope.
|
void |
setAttribute(String name,
Object value,
int scope)
Sets the value of an attribute in a given scope.
|
void |
setBindings(Bindings bindings,
int scope)
Sets a
Bindings of attributes for the given scope. |
void |
setErrorWriter(Writer writer) |
void |
setReader(Reader reader) |
void |
setWriter(Writer writer) |
protected Writer writer
PrintWriter
based on System.out is used. Accessor methods getWriter, setWriter are used to
manage this field.System.out,
PrintWriterprotected Writer errorWriter
PrintWriter
based on System.err is used. Accessor methods getErrorWriter,
setErrorWriter are used to manage this field.System.err,
PrintWriterprotected 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,
InputStreamReaderprotected Bindings engineScope
SimpleBindings is used. Accessor
methods setBindings, getBindings are used to manage this field.SimpleBindingsprotected Bindings globalScope
public void setBindings(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 ScriptContextbindings - The Bindings of attributes to set.scope - The value of the scope in which the attributes are set.IllegalArgumentException - if scope is invalid.NullPointerException - if the value of scope is ENGINE_SCOPE and the
specified Bindings is null.public Object getAttribute(String name)
getAttribute in interface ScriptContextname - The name of the attribute to retrieve.NullPointerException - if the name is null.IllegalArgumentException - if the name is empty.public Object getAttribute(String name, int scope)
getAttribute in interface ScriptContextname - 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.IllegalArgumentException - if the name is empty or if the value of scope is invalid.NullPointerException - if the name is null.public Object removeAttribute(String name, int scope)
removeAttribute in interface ScriptContextname - The name of the attribute to removescope - The scope in which to remove the attributeIllegalArgumentException - if the name is empty or if the scope is invalid.NullPointerException - if the name is null.public void setAttribute(String name, Object value, int scope)
GLOBAL_SCOPE and
no Bindings is set for GLOBAL_SCOPE, then setAttribute call is a no-op.setAttribute in interface ScriptContextname - The name of the attribute to setvalue - The value of the attributescope - The scope in which to set the attributeIllegalArgumentException - if the name is empty or if the scope is invalid.NullPointerException - if the name is null.public Writer getWriter()
getWriter in interface ScriptContextpublic Reader getReader()
getReader in interface ScriptContextpublic void setReader(Reader reader)
setReader in interface ScriptContextpublic void setWriter(Writer writer)
setWriter in interface ScriptContextpublic Writer getErrorWriter()
getErrorWriter in interface ScriptContextpublic void setErrorWriter(Writer writer)
setErrorWriter in interface ScriptContextpublic int getAttributesScope(String name)
getAttributesScope in interface ScriptContextname - Name of the attribute .NullPointerException - if name is null.IllegalArgumentException - if name is empty.public 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 ScriptContextscope - The specified scopeengineScope or globalScope field.IllegalArgumentException - if the value of scope is invalid.public List<Integer> getScopes()
getScopes in interface ScriptContextCopyright © 2022. All rights reserved.