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