Class DefaultScriptLanguage
java.lang.Object
qupath.lib.scripting.languages.ScriptLanguage
qupath.lib.gui.scripting.languages.DefaultScriptLanguage
- All Implemented Interfaces:
ExecutableLanguage
- Direct Known Subclasses:
GroovyLanguage
Default implementation for a
ScriptLanguage, based on a ScriptEngine.- Since:
- v0.4.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static interfaceInterface defining how the import statements should be generated for the language. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final DefaultScriptLanguage.ImportStatementGeneratorJava-like import statementsprotected static final DefaultScriptLanguage.ImportStatementGeneratorPythonic import statements -
Constructor Summary
ConstructorsConstructorDescriptionDefaultScriptLanguage(String name, Collection<String> exts, ScriptAutoCompletor completor) Constructor for aExecutableLanguage.DefaultScriptLanguage(ScriptEngineFactory factory) Constructor for aExecutableLanguagebased on aScriptEngineFactory. -
Method Summary
Modifier and TypeMethodDescriptionprotected ScriptContextcreateContext(ScriptParameters params) Create aScriptContextcontaining information from theScriptParameters.execute(ScriptParameters params) Execute the given script String.Get theScriptAutoCompletorobject that takes care of this language's auto-completion.protected ScriptAutoCompletorgetDefaultAutoCompletor(String languageName) Default method to get a suitable auto completor for the given language name.protected StringgetImportStatements(Collection<Class<?>> classes) Get the import statements as a String, to add at the beginning of the executed script.getStaticImportStatements(Collection<Class<?>> classes) Get the static import statements as a String, to add at the beginning of the executed script.protected StringtryToInterpretMessage(Throwable cause, int line, boolean defaultImportsAvailable) Methods inherited from class qupath.lib.scripting.languages.ScriptLanguage
getExtensions, getName, toString
-
Field Details
-
JAVA_IMPORTER
Java-like import statements -
PYTHON_IMPORTER
Pythonic import statements
-
-
Constructor Details
-
DefaultScriptLanguage
Constructor for aExecutableLanguagebased on aScriptEngineFactory.Note: the scriptEngine is not stored within this class. It is always fetched via
ScriptLanguageProvider.- Parameters:
factory-
-
DefaultScriptLanguage
Constructor for aExecutableLanguage.Note: the scriptEngine is not stored within this class. It is always fetched via
ScriptLanguageProvider.- Parameters:
name- the language nameexts- the possible extensions for this languagecompletor- the auto-completion object for this language
-
-
Method Details
-
getDefaultAutoCompletor
Default method to get a suitable auto completor for the given language name.- Parameters:
languageName-- Returns:
-
execute
Description copied from interface:ExecutableLanguageExecute the given script String.- Specified by:
executein interfaceExecutableLanguage- Parameters:
params-- Returns:
- Throws:
ScriptException
-
tryToInterpretMessage
-
getDefaultScriptName
-
createContext
Create aScriptContextcontaining information from theScriptParameters.- Parameters:
params-- Returns:
-
getAutoCompletor
Description copied from class:ScriptLanguageGet theScriptAutoCompletorobject that takes care of this language's auto-completion.Can return
nullif the script editor should not handle auto-completion for this language.- Overrides:
getAutoCompletorin classScriptLanguage- Returns:
- auto-completor
-
getImportStatements
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
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
Get anDefaultScriptLanguage.ImportStatementGenerator. This attempts to make an educated guess, returning JAVA_IMPORTER or PYTHON_IMPORTER based on the name- Returns:
-