← 返回首页
ScriptService (SciJava Javadocs 0-SNAPSHOT API)
JavaScript is disabled on your browser.
org.scijava.script

Interface ScriptService

    • Field Detail

      • SCRIPTS_RESOURCE_DIR

        static final String SCRIPTS_RESOURCE_DIR
        Base directory for discovering scripts, including within classpath resources as well as beneath the application base directory.
        See Also: Constant Field Values
    • Method Detail

      • getLanguageByExtension

        default ScriptLanguage getLanguageByExtension(String extension)
        Gets the scripting language that handles the given file extension.
      • getLanguageByName

        default ScriptLanguage getLanguageByName(String name)
        Gets the scripting language with the given name.
      • getScriptDirectories

        List<File> getScriptDirectories()
        Gets the base directories to scan for scripts.
      • getMenuPrefix

        MenuPath getMenuPrefix(File scriptDirectory)
        Gets the menu path prefix for the given script directory, or null if none.
      • addScriptDirectory

        void addScriptDirectory(File scriptDirectory)
        Adds a base directory to scan for scripts.
      • addScriptDirectory

        void addScriptDirectory(File scriptDirectory, MenuPath menuPrefix)
        Adds a base directory to scan for scripts, placing discovered scripts beneath the given menu path prefix.
      • removeScriptDirectory

        void removeScriptDirectory(File scriptDirectory)
        Removes a base directory to scan for scripts.
      • getScript

        ScriptInfo getScript(File scriptFile)
        Gets the cached ScriptInfo metadata for the script at the given file, creating it if it does not already exist.
      • run

        Future<ScriptModule> run(File file, boolean process, Object... inputs) throws FileNotFoundException, ScriptException
        Executes the script in the given file.
        Parameters: file - File containing the script to execute. process - If true, executes the script with pre- and postprocessing steps from all available PreprocessorPlugins and PostprocessorPlugins in the plugin index; if false, executes the script with no pre- or postprocessing. inputs - List of input parameter names and values. The expected order is in pairs: an input name followed by its value, for each desired input to populate. Leaving some inputs unpopulated is allowed. Passing the name of an input that is not valid for the plugin, or passing a value of a type incompatible with the associated input parameter, will issue an error and ignore that name/value pair. Returns: Future of the module instance being executed. Calling Future.get() will block until execution is complete. Throws: FileNotFoundException ScriptException
      • run

        Future<ScriptModule> run(File file, boolean process, Map<String,Object> inputMap) throws FileNotFoundException, ScriptException
        Executes the script in the given file.
        Parameters: file - File containing the script to execute. process - If true, executes the script with pre- and postprocessing steps from all available PreprocessorPlugins and PostprocessorPlugins in the plugin index; if false, executes the script with no pre- or postprocessing. inputMap - Table of input parameter values, with keys matching the plugin's input parameter names. Passing a value of a type incompatible with the associated input parameter will issue an error and ignore that value. Returns: Future of the module instance being executed. Calling Future.get() will block until execution is complete. Throws: FileNotFoundException ScriptException
      • run

        default Future<ScriptModule> run(String path, String script, boolean process, Object... inputs)
        Executes the given script.
        Parameters: path - Pseudo-path to the script. This is important mostly for the path's file extension, which provides an important hint as to the language of the script. script - The script itself to execute. process - If true, executes the script with pre- and postprocessing steps from all available PreprocessorPlugins and PostprocessorPlugins in the plugin index; if false, executes the script with no pre- or postprocessing. inputs - List of input parameter names and values. The expected order is in pairs: an input name followed by its value, for each desired input to populate. Leaving some inputs unpopulated is allowed. Passing the name of an input that is not valid for the plugin, or passing a value of a type incompatible with the associated input parameter, will issue an error and ignore that name/value pair. Returns: Future of the module instance being executed. Calling Future.get() will block until execution is complete.
      • run

        default Future<ScriptModule> run(String path, String script, boolean process, Map<String,Object> inputMap)
        Executes the given script.
        Parameters: path - Pseudo-path to the script. This is important mostly for the path's file extension, which provides an important hint as to the language of the script. script - The script itself to execute. process - If true, executes the script with pre- and postprocessing steps from all available PreprocessorPlugins and PostprocessorPlugins in the plugin index; if false, executes the script with no pre- or postprocessing. inputMap - Table of input parameter values, with keys matching the plugin's input parameter names. Passing a value of a type incompatible with the associated input parameter will issue an error and ignore that value. Returns: Future of the module instance being executed. Calling Future.get() will block until execution is complete.
      • run

        default Future<ScriptModule> run(String path, Reader reader, boolean process, Object... inputs)
        Executes the given script.
        Parameters: path - Pseudo-path to the script. This is important mostly for the path's file extension, which provides an important hint as to the language of the script. reader - A stream providing the script contents. process - If true, executes the script with pre- and postprocessing steps from all available PreprocessorPlugins and PostprocessorPlugins in the plugin index; if false, executes the script with no pre- or postprocessing. inputs - List of input parameter names and values. The expected order is in pairs: an input name followed by its value, for each desired input to populate. Leaving some inputs unpopulated is allowed. Passing the name of an input that is not valid for the plugin, or passing a value of a type incompatible with the associated input parameter, will issue an error and ignore that name/value pair. Returns: Future of the module instance being executed. Calling Future.get() will block until execution is complete.
      • run

        default Future<ScriptModule> run(String path, Reader reader, boolean process, Map<String,Object> inputMap)
        Executes the given script.
        Parameters: path - Pseudo-path to the script. This is important mostly for the path's file extension, which provides an important hint as to the language of the script. reader - A stream providing the script contents. process - If true, executes the script with pre- and postprocessing steps from all available PreprocessorPlugins and PostprocessorPlugins in the plugin index; if false, executes the script with no pre- or postprocessing. inputMap - Table of input parameter values, with keys matching the plugin's input parameter names. Passing a value of a type incompatible with the associated input parameter will issue an error and ignore that value. Returns: Future of the module instance being executed. Calling Future.get() will block until execution is complete.
      • run

        Future<ScriptModule> run(ScriptInfo info, boolean process, Object... inputs)
        Executes the given script.
        Parameters: info - The script to instantiate and run. process - If true, executes the script with pre- and postprocessing steps from all available PreprocessorPlugins and PostprocessorPlugins in the plugin index; if false, executes the script with no pre- or postprocessing. inputs - List of input parameter names and values. The expected order is in pairs: an input name followed by its value, for each desired input to populate. Leaving some inputs unpopulated is allowed. Passing the name of an input that is not valid for the plugin, or passing a value of a type incompatible with the associated input parameter, will issue an error and ignore that name/value pair. Returns: Future of the module instance being executed. Calling Future.get() will block until execution is complete.
      • run

        Future<ScriptModule> run(ScriptInfo info, boolean process, Map<String,Object> inputMap)
        Executes the given script.
        Parameters: info - The script to instantiate and run. process - If true, executes the script with pre- and postprocessing steps from all available PreprocessorPlugins and PostprocessorPlugins in the plugin index; if false, executes the script with no pre- or postprocessing. inputMap - Table of input parameter values, with keys matching the plugin's input parameter names. Passing a value of a type incompatible with the associated input parameter will issue an error and ignore that value. Returns: Future of the module instance being executed. Calling Future.get() will block until execution is complete.
      • canHandleFile

        default boolean canHandleFile(File file)
        TODO
      • canHandleFile

        default boolean canHandleFile(String fileName)
        TODO
      • addAlias

        default void addAlias(Class<?> type)
        TODO
      • addAlias

        void addAlias(String alias, Class<?> type)
        TODO

Copyright © 2015–2022 SciJava. All rights reserved.