Package org.omegat.gui.scripting
Class ScriptRunner
- java.lang.Object
-
- org.omegat.gui.scripting.ScriptRunner
-
public final class ScriptRunner extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DEFAULT_SCRIPT
static javax.script.ScriptEngineManager
MANAGER
static java.lang.String
SCRIPT_GUI_FUNCTION_NAME
Scripts that want to run on the Event Dispatch Thread should define a top-level function with this name and NOT evaluate it.static java.lang.String
VAR_CONSOLE
static java.lang.String
VAR_CORE
static java.lang.String
VAR_EDITOR
static java.lang.String
VAR_GLOSSARY
static java.lang.String
VAR_MAINWINDOW
static java.lang.String
VAR_PROJECT
static java.lang.String
VAR_RESOURCES
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.Object
executeScript(java.lang.String script, javax.script.ScriptEngine engine, java.util.Map<java.lang.String,java.lang.Object> additionalBindings)
Execute a script with a given engine and bindings.static java.lang.String
executeScript(java.lang.String script, ScriptItem item, java.util.Map<java.lang.String,java.lang.Object> additionalBindings)
Execute a script either in string form or, ifscript
is null, as read from the file associated with the suppliedScriptItem
.static java.lang.String
executeScript(ScriptItem item, java.util.Map<java.lang.String,java.lang.Object> additionalBindings)
Execute as read from the file associated with the suppliedScriptItem
.static java.util.List<java.lang.String>
getAvailableScriptExtensions()
-
-
-
Field Detail
-
SCRIPT_GUI_FUNCTION_NAME
public static final java.lang.String SCRIPT_GUI_FUNCTION_NAME
Scripts that want to run on the Event Dispatch Thread should define a top-level function with this name and NOT evaluate it.- See Also:
- Constant Field Values
-
DEFAULT_SCRIPT
public static final java.lang.String DEFAULT_SCRIPT
- See Also:
- Constant Field Values
-
VAR_CONSOLE
public static final java.lang.String VAR_CONSOLE
- See Also:
- Constant Field Values
-
VAR_MAINWINDOW
public static final java.lang.String VAR_MAINWINDOW
- See Also:
- Constant Field Values
-
VAR_GLOSSARY
public static final java.lang.String VAR_GLOSSARY
- See Also:
- Constant Field Values
-
VAR_CORE
public static final java.lang.String VAR_CORE
- See Also:
- Constant Field Values
-
VAR_EDITOR
public static final java.lang.String VAR_EDITOR
- See Also:
- Constant Field Values
-
VAR_PROJECT
public static final java.lang.String VAR_PROJECT
- See Also:
- Constant Field Values
-
VAR_RESOURCES
public static final java.lang.String VAR_RESOURCES
- See Also:
- Constant Field Values
-
MANAGER
public static final javax.script.ScriptEngineManager MANAGER
-
-
Method Detail
-
executeScript
public static java.lang.String executeScript(ScriptItem item, java.util.Map<java.lang.String,java.lang.Object> additionalBindings) throws java.io.IOException, javax.script.ScriptException
Execute as read from the file associated with the suppliedScriptItem
. This is a convenience method forexecuteScript(String, ScriptItem, Map)
.- Parameters:
item
-additionalBindings
-- Returns:
- Throws:
javax.script.ScriptException
java.io.IOException
java.lang.Exception
-
executeScript
public static java.lang.String executeScript(java.lang.String script, ScriptItem item, java.util.Map<java.lang.String,java.lang.Object> additionalBindings) throws java.io.IOException, javax.script.ScriptException
Execute a script either in string form or, ifscript
is null, as read from the file associated with the suppliedScriptItem
. The engine is resolved via the filename extension associated withitem
(defaults toDEFAULT_SCRIPT
).This is a convenience method for
executeScript(String, ScriptEngine, Map)
.- Parameters:
script
- The script in string form. Can be null.item
- The associatedScriptItem
. Must not be null. Ifscript
is null, the script content will be read from the associated file. The script engine will be resolved from the filename. The resource bundle associated with theitem
will be included in the bindings asVAR_RESOURCES
.additionalBindings
- A map of bindings that will be included along with other bindings- Returns:
- Throws:
java.io.IOException
javax.script.ScriptException
-
executeScript
public static java.lang.Object executeScript(java.lang.String script, javax.script.ScriptEngine engine, java.util.Map<java.lang.String,java.lang.Object> additionalBindings) throws javax.script.ScriptException
Execute a script with a given engine and bindings.- Parameters:
script
- The script in string formengine
- The engineadditionalBindings
- A map of bindings that will be included along with other bindings- Returns:
- The evaluation result
- Throws:
javax.script.ScriptException
-
getAvailableScriptExtensions
public static java.util.List<java.lang.String> getAvailableScriptExtensions()
-
-