Class DefaultScriptLanguage

java.lang.Object
qupath.lib.scripting.languages.ScriptLanguage
qupath.lib.gui.scripting.languages.DefaultScriptLanguage
All Implemented Interfaces:
qupath.lib.scripting.languages.ExecutableLanguage
Direct Known Subclasses:
GroovyLanguage

public class DefaultScriptLanguage extends qupath.lib.scripting.languages.ScriptLanguage implements qupath.lib.scripting.languages.ExecutableLanguage
Default implementation for a ScriptLanguage, based on a ScriptEngine.
Since:
v0.4.0
  • Field Details

  • Constructor Details

    • DefaultScriptLanguage

      public DefaultScriptLanguage(ScriptEngineFactory factory)
      Constructor for a ExecutableLanguage based on a ScriptEngineFactory.

      Note: the scriptEngine is not stored within this class. It is always fetched via ScriptLanguageProvider.

      Parameters:
      factory -
    • DefaultScriptLanguage

      public DefaultScriptLanguage(String name, Collection<String> exts, qupath.lib.scripting.languages.ScriptAutoCompletor completor)
      Constructor for a ExecutableLanguage.

      Note: the scriptEngine is not stored within this class. It is always fetched via ScriptLanguageProvider.

      Parameters:
      name - the language name
      exts - the possible extensions for this language
      completor - the auto-completion object for this language
  • Method Details

    • getDefaultAutoCompletor

      protected qupath.lib.scripting.languages.ScriptAutoCompletor getDefaultAutoCompletor(String languageName)
      Default method to get a suitable auto completor for the given language name.
      Parameters:
      languageName -
      Returns:
    • execute

      public Object execute(qupath.lib.scripting.ScriptParameters params) throws ScriptException
      Specified by:
      execute in interface qupath.lib.scripting.languages.ExecutableLanguage
      Throws:
      ScriptException
    • tryToInterpretMessage

      protected String tryToInterpretMessage(Throwable cause, int line, boolean defaultImportsAvailable)
    • getDefaultScriptName

      protected String getDefaultScriptName()
    • createContext

      protected ScriptContext createContext(qupath.lib.scripting.ScriptParameters params)
      Create a ScriptContext containing information from the ScriptParameters.
      Parameters:
      params -
      Returns:
    • getAutoCompletor

      public qupath.lib.scripting.languages.ScriptAutoCompletor getAutoCompletor()
      Overrides:
      getAutoCompletor in class qupath.lib.scripting.languages.ScriptLanguage
    • getImportStatements

      public String getImportStatements(Collection<Class<?>> classes)
      Get the import statements as a String, to add at the beginning of the executed script.
      Parameters:
      classes - a collection of the classes to import
      Returns:
      import string
    • getStaticImportStatements

      public String getStaticImportStatements(Collection<Class<?>> classes)
      Get the static import statements as a String, to add at the beginning of the executed script.
      Parameters:
      classes - a collection of classes to import as static classes
      Returns:
      import string
    • getImportStatementGenerator

      protected DefaultScriptLanguage.ImportStatementGenerator getImportStatementGenerator()
      Get an DefaultScriptLanguage.ImportStatementGenerator. This attempts to make an educated guess, returning JAVA_IMPORTER or PYTHON_IMPORTER based on the name
      Returns: