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.StringDEFAULT_SCRIPTstatic javax.script.ScriptEngineManagerMANAGERstatic java.lang.StringSCRIPT_GUI_FUNCTION_NAMEScripts 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.StringVAR_CONSOLEstatic java.lang.StringVAR_COREstatic java.lang.StringVAR_EDITORstatic java.lang.StringVAR_GLOSSARYstatic java.lang.StringVAR_MAINWINDOWstatic java.lang.StringVAR_PROJECTstatic java.lang.StringVAR_RESOURCES
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.ObjectexecuteScript(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.StringexecuteScript(java.lang.String script, ScriptItem item, java.util.Map<java.lang.String,java.lang.Object> additionalBindings)Execute a script either in string form or, ifscriptis null, as read from the file associated with the suppliedScriptItem.static java.lang.StringexecuteScript(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.ScriptExceptionjava.io.IOExceptionjava.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.ScriptExceptionExecute a script either in string form or, ifscriptis 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. Ifscriptis 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 theitemwill be included in the bindings asVAR_RESOURCES.additionalBindings- A map of bindings that will be included along with other bindings- Returns:
- Throws:
java.io.IOExceptionjavax.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.ScriptExceptionExecute 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()
-
-