public class EvaluableScript extends Object
| Modifier and Type | Field and Description |
|---|---|
private CompiledScript |
compiledScript
The compiled form of the script, if the script engine supports compiling.
|
private String |
script
The script to execute.
|
private ScriptEngine |
scriptEngine
The script engine to execute the script.
|
private String |
scriptLanguage
The scripting language.
|
| Constructor and Description |
|---|
EvaluableScript(String scriptSource)
Constructor.
|
EvaluableScript(String engineName,
File scriptSource)
Constructor.
|
EvaluableScript(String engineName,
String scriptSource)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
Object |
eval(Bindings scriptBindings)
Evaluates this script against the given bindings.
|
Object |
eval(ScriptContext scriptContext)
Evaluates this script against the given context.
|
String |
getScript()
Gets the script source.
|
String |
getScriptLanguage()
Gets the script language.
|
private void |
initialize()
Initializes the scripting engine and compiles the script, if possible.
|
private final String scriptLanguage
private final String script
private ScriptEngine scriptEngine
private CompiledScript compiledScript
public EvaluableScript(@Nonnull@NotEmpty String engineName, @Nonnull@NotEmpty String scriptSource) throws ScriptException
engineName - the JSR-223 scripting engine namescriptSource - the script sourceScriptException - thrown if the scripting engine supports compilation and the script does not compilepublic EvaluableScript(@Nonnull@NotEmpty String scriptSource) throws ScriptException
scriptSource - the script sourceScriptException - thrown if the scripting engine supports compilation and the script does not compilepublic EvaluableScript(@Nonnull@NotEmpty String engineName, @Nonnull File scriptSource) throws ScriptException
engineName - the JSR-223 scripting engine namescriptSource - the script sourceScriptException - thrown if the script source file can not be read or the scripting engine supports
compilation and the script does not compile@Nonnull public String getScriptLanguage()
@Nullable public Object eval(Bindings scriptBindings) throws ScriptException
scriptBindings - the script bindingsScriptException - thrown if there was a problem evaluating the script@Nullable public Object eval(ScriptContext scriptContext) throws ScriptException
scriptContext - the script contextScriptException - thrown if there was a problem evaluating the scriptprivate void initialize()
throws ScriptException
ScriptException - thrown if the scripting engine supports compilation and the script does not compileCopyright © 1999–2015. All rights reserved.