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
-
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, qupath.lib.scripting.languages.ScriptAutoCompletor completor) Constructor for aExecutableLanguage.DefaultScriptLanguage(ScriptEngineFactory factory) Constructor for aExecutableLanguagebased on aScriptEngineFactory. -
Method Summary
Modifier and TypeMethodDescriptionprotected ScriptContextcreateContext(qupath.lib.scripting.ScriptParameters params) Create aScriptContextcontaining information from theScriptParameters.execute(qupath.lib.scripting.ScriptParameters params) qupath.lib.scripting.languages.ScriptAutoCompletorprotected qupath.lib.scripting.languages.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
public DefaultScriptLanguage(String name, Collection<String> exts, qupath.lib.scripting.languages.ScriptAutoCompletor completor) 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
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
- Specified by:
executein interfacequpath.lib.scripting.languages.ExecutableLanguage- Throws:
ScriptException
-
tryToInterpretMessage
-
getDefaultScriptName
-
createContext
Create aScriptContextcontaining information from theScriptParameters.- Parameters:
params-- Returns:
-
getAutoCompletor
public qupath.lib.scripting.languages.ScriptAutoCompletor getAutoCompletor()- Overrides:
getAutoCompletorin classqupath.lib.scripting.languages.ScriptLanguage
-
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:
-