Class ScriptRunner


  • public final class ScriptRunner
    extends java.lang.Object
    • 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, if script is null, as read from the file associated with the supplied ScriptItem.
      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 supplied ScriptItem.
      static java.util.List<java.lang.String> getAvailableScriptExtensions()  
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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
      • 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 supplied ScriptItem. This is a convenience method for executeScript(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, if script is null, as read from the file associated with the supplied ScriptItem. The engine is resolved via the filename extension associated with item (defaults to DEFAULT_SCRIPT).

        This is a convenience method for executeScript(String, ScriptEngine, Map).

        Parameters:
        script - The script in string form. Can be null.
        item - The associated ScriptItem. Must not be null. If script 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 the item will be included in the bindings as VAR_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 form
        engine - The engine
        additionalBindings - 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()