Fields Summary |
---|
protected Writer | writerThis is the writer to be used to output from scripts.
By default, a PrintWriter based on System.out
is used. Accessor methods getWriter, setWriter are used to manage
this field. |
protected Writer | errorWriterThis is the writer to be used to output errors from scripts.
By default, a PrintWriter based on System.err is
used. Accessor methods getErrorWriter, setErrorWriter are used to manage
this field. |
protected Reader | readerThis is the reader to be used for input from scripts.
By default, a 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. |
protected Bindings | engineScopeThis is the engine scope bindings.
By default, a SimpleBindings is used. Accessor
methods setBindings, getBindings are used to manage this field. |
protected Bindings | globalScopeThis is the global scope bindings.
By default, a null value (which means no global scope) is used. Accessor
methods setBindings, getBindings are used to manage this field. |
private static List | scopes |
Methods Summary |
---|
public 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. The order
is determined by the numeric value of the scope parameter (lowest
scope values first.)
if (engineScope.containsKey(name)) {
return getAttribute(name, ENGINE_SCOPE);
} else if (globalScope != null && globalScope.containsKey(name)) {
return getAttribute(name, GLOBAL_SCOPE);
}
return null;
|
public java.lang.Object | getAttribute(java.lang.String name, int scope)Gets the value of an attribute in a given scope.
switch (scope) {
case ENGINE_SCOPE:
return engineScope.get(name);
case GLOBAL_SCOPE:
if (globalScope != null) {
return globalScope.get(name);
}
return null;
default:
throw new IllegalArgumentException("Illegal scope value.");
}
|
public int | getAttributesScope(java.lang.String name)Get the lowest scope in which an attribute is defined.
if (engineScope.containsKey(name)) {
return ENGINE_SCOPE;
} else if (globalScope != null && globalScope.containsKey(name)) {
return GLOBAL_SCOPE;
} else {
return -1;
}
|
public javax.script.Bindings | getBindings(int scope)Returns the value of the engineScope field if specified scope is
ENGINE_SCOPE . Returns the value of the globalScope field if the specified scope is
GLOBAL_SCOPE .
if (scope == ENGINE_SCOPE) {
return engineScope;
} else if (scope == GLOBAL_SCOPE) {
return globalScope;
} else {
throw new IllegalArgumentException("Illegal scope value.");
}
|
public java.io.Writer | getErrorWriter(){@inheritDoc}
return errorWriter;
|
public java.io.Reader | getReader(){@inheritDoc}
return reader;
|
public java.util.List | getScopes(){@inheritDoc}
return scopes;
|
public java.io.Writer | getWriter(){@inheritDoc}
return writer;
|
public java.lang.Object | removeAttribute(java.lang.String name, int scope)Remove an attribute in a given scope.
switch (scope) {
case ENGINE_SCOPE:
if (getBindings(ENGINE_SCOPE) != null) {
return getBindings(ENGINE_SCOPE).remove(name);
}
return null;
case GLOBAL_SCOPE:
if (getBindings(GLOBAL_SCOPE) != null) {
return getBindings(GLOBAL_SCOPE).remove(name);
}
return null;
default:
throw new IllegalArgumentException("Illegal scope value.");
}
|
public void | setAttribute(java.lang.String name, java.lang.Object value, int scope)Sets the value of an attribute in a given scope.
switch (scope) {
case ENGINE_SCOPE:
engineScope.put(name, value);
return;
case GLOBAL_SCOPE:
if (globalScope != null) {
globalScope.put(name, value);
}
return;
default:
throw new IllegalArgumentException("Illegal scope value.");
}
|
public void | setBindings(javax.script.Bindings bindings, int scope)Sets a 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.
switch (scope) {
case ENGINE_SCOPE:
if (bindings == null) {
throw new NullPointerException("Engine scope cannot be null.");
}
engineScope = bindings;
break;
case GLOBAL_SCOPE:
globalScope = bindings;
break;
default:
throw new IllegalArgumentException("Invalid scope value.");
}
|
public void | setErrorWriter(java.io.Writer writer){@inheritDoc}
this.errorWriter = writer;
|
public void | setReader(java.io.Reader reader){@inheritDoc}
this.reader = reader;
|
public void | setWriter(java.io.Writer writer){@inheritDoc}
this.writer = writer;
|