Methods Summary |
---|
public java.lang.Object | eval(java.lang.String script, javax.script.Bindings bindings)Same as eval(Reader, Bindings) except that the abstract
eval(String, ScriptContext) is used.
ScriptContext ctxt = getScriptContext(bindings);
return eval(script , ctxt);
|
public java.lang.Object | eval(java.io.Reader reader)eval(Reader) calls the abstract
eval(Reader, ScriptContext) passing the value of the context
field.
return eval(reader, context);
|
public java.lang.Object | eval(java.lang.String script)Same as eval(Reader) except that the abstract
eval(String, ScriptContext) is used.
return eval(script, context);
|
public java.lang.Object | eval(java.io.Reader reader, javax.script.Bindings bindings)eval(Reader, Bindings) calls the abstract
eval(Reader, ScriptContext) method, passing it a ScriptContext
whose Reader, Writers and Bindings for scopes other that ENGINE_SCOPE
are identical to those members of the protected context field. The specified
Bindings is used instead of the ENGINE_SCOPE
Bindings of the context field.
ScriptContext ctxt = getScriptContext(bindings);
return eval(reader, ctxt);
|
public java.lang.Object | get(java.lang.String key)Gets the value for the specified key in the ENGINE_SCOPE of the
protected context field.
Bindings nn = getBindings(ScriptContext.ENGINE_SCOPE);
if (nn != null) {
return nn.get(key);
}
return null;
|
public javax.script.Bindings | getBindings(int scope)Returns the Bindings with the specified scope value in
the protected context field.
if (scope == ScriptContext.GLOBAL_SCOPE) {
return context.getBindings(ScriptContext.GLOBAL_SCOPE);
} else if (scope == ScriptContext.ENGINE_SCOPE) {
return context.getBindings(ScriptContext.ENGINE_SCOPE);
} else {
throw new IllegalArgumentException("Invalid scope value.");
}
|
public javax.script.ScriptContext | getContext()Returns the value of the protected context field.
return context;
|
protected javax.script.ScriptContext | getScriptContext(javax.script.Bindings nn)Returns a SimpleScriptContext . The SimpleScriptContext :
- Uses the specified
Bindings for its ENGINE_SCOPE
- Uses the
Bindings returned by the abstract getGlobalScope
method as its GLOBAL_SCOPE
- Uses the Reader and Writer in the default
ScriptContext of this
ScriptEngine
A SimpleScriptContext returned by this method is used to implement eval methods
using the abstract eval(Reader,Bindings) and eval(String,Bindings)
versions.
SimpleScriptContext ctxt = new SimpleScriptContext();
Bindings gs = getBindings(ScriptContext.GLOBAL_SCOPE);
if (gs != null) {
ctxt.setBindings(gs, ScriptContext.GLOBAL_SCOPE);
}
if (nn != null) {
ctxt.setBindings(nn,
ScriptContext.ENGINE_SCOPE);
} else {
throw new NullPointerException("Engine scope Bindings may not be null.");
}
ctxt.setReader(context.getReader());
ctxt.setWriter(context.getWriter());
ctxt.setErrorWriter(context.getErrorWriter());
return ctxt;
|
public void | put(java.lang.String key, java.lang.Object value)Sets the specified value with the specified key in the ENGINE_SCOPE
Bindings of the protected context field.
Bindings nn = getBindings(ScriptContext.ENGINE_SCOPE);
if (nn != null) {
nn.put(key, value);
}
|
public void | setBindings(javax.script.Bindings bindings, int scope)Sets the Bindings with the corresponding scope value in the
context field.
if (scope == ScriptContext.GLOBAL_SCOPE) {
context.setBindings(bindings, ScriptContext.GLOBAL_SCOPE);;
} else if (scope == ScriptContext.ENGINE_SCOPE) {
context.setBindings(bindings, ScriptContext.ENGINE_SCOPE);;
} else {
throw new IllegalArgumentException("Invalid scope value.");
}
|
public void | setContext(javax.script.ScriptContext ctxt)Sets the value of the protected context field to the specified
ScriptContext .
if (ctxt == null) {
throw new NullPointerException("null context");
}
context = ctxt;
|