T
- The evaluation response type.public class ScriptRunner<T> extends Object
Runs scripts written in a programming language supported by the provided script engine. Java SE 6 and higher includes the JSR 223 API, which allows to "plug" any script engines to support your favorite scripting language.
The JavaScript (ECMAScript) script engine should already be present as part of your Java installation and is the default script engine used by this class when none is specified. As of Java 8, the Oracle version of Java uses the Nashorn engine, an implementation of the ECMAScript Edition 5.1 language specification (greater version of Java may use a more recent edition). Prior to version 8, Java used a JavaScript engine based on Mozilla Rhino.
As of 2.7.0, support for the
Lua script engine is available.
It relies on the
LuaJ project to do so.
To use it, set "lua" as the scripting engine with
setEngineName(String)
.
Several third-party script engines already exist to support additional languages such as Groovy, JRuby, Scala, Fantom, Jython, etc. Refer to appropriate third-party documentation about these languages to find out how to use them.
Note: While using a scripting language can be very convenient, it requires extra knowledge and should only be considered by experimented or adventurous users. Use at your own risk.
ScriptFilter
,
ScriptTagger
,
ScriptTransformer
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_SCRIPT_ENGINE |
static String |
JAVASCRIPT_ENGINE |
static String |
LUA_ENGINE |
Constructor and Description |
---|
ScriptRunner() |
ScriptRunner(String engineName) |
Modifier and Type | Method and Description |
---|---|
Bindings |
createBindings() |
boolean |
equals(Object other) |
T |
eval(Bindings bindings) |
String |
getEngineName() |
String |
getScript() |
int |
hashCode() |
void |
setEngineName(String engineName) |
void |
setScript(String script) |
String |
toString() |
public static final String LUA_ENGINE
public static final String JAVASCRIPT_ENGINE
public static final String DEFAULT_SCRIPT_ENGINE
public ScriptRunner()
public ScriptRunner(String engineName)
public String getEngineName()
public void setEngineName(String engineName)
public String getScript()
public void setScript(String script)
public Bindings createBindings() throws ImporterHandlerException
ImporterHandlerException
public T eval(Bindings bindings) throws ImporterHandlerException
ImporterHandlerException
Copyright © 2009–2023 Norconex Inc.. All rights reserved.