Class ScriptInfo
- java.lang.Object
-
- org.scijava.AbstractBasicDetails
-
- org.scijava.AbstractUIDetails
-
- org.scijava.module.AbstractModuleInfo
-
- org.scijava.script.ScriptInfo
-
- All Implemented Interfaces:
Comparable<Prioritized>,BasicDetails,Contextual,Identifiable,Locatable,ModuleInfo,Named,Prioritized,UIDetails,Validated,Versioned
public class ScriptInfo extends AbstractModuleInfo implements Contextual
Metadata about a script.- Author:
- Curtis Rueden, Johannes Schindelin
-
-
Field Summary
-
Fields inherited from interface org.scijava.UIDetails
APPLICATION_MENU_ROOT
-
-
Constructor Summary
Constructors Constructor Description ScriptInfo(Context context, File file)Creates a script metadata object which describes the given script file.ScriptInfo(Context context, String path)Creates a script metadata object which describes the given script file.ScriptInfo(Context context, String path, Reader reader)Creates a script metadata object which describes a script provided by the givenReader.ScriptInfo(Context context, URL url, String path)Creates a script metadata object which describes a script at the given URL.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description List<ScriptCallback>callbacks()Gets the list of routines which should be invoked each time the script is about to execute.booleancanRunHeadless()Gets whether the module condones headless execution.voidclearParameters()Clears input and output parameters.Contextcontext()Gets the application context to which the object belongs.ScriptModulecreateModule()Instantiates the module described by this module info.ContextgetContext()Gets the application context to which the object belongs, or null ifContextual.setContext(Context)has not yet been called on this object.StringgetDelegateClassName()Gets the fully qualified name of the class containing the module's actual implementation.StringgetIdentifier()Gets a string intended to function as an identifier for the object.ScriptLanguagegetLanguage()Gets the scripting language of the script.StringgetLocation()Gets the URL string defining the object's location.StringgetPath()Gets the path to the script on disk.StringgetProcessedScript()Gets the script contents after script processing.BufferedReadergetReader()Gets a reader which delivers the script's content.URLgetURL()Gets the URL of the script.StringgetVersion()Gets the version of the object.booleanisReturnValueAppended()Gets whether the return value is appended as an additional output.booleanisReturnValueDeclared()Deprecated.UseisReturnValueAppended()instead.Class<?>loadDelegateClass()Loads the class containing the module's actual implementation.voidparseParameters()Performs script processing.voidregisterInput(ModuleItem<?> input)Adds an input.voidregisterOutput(ModuleItem<?> output)Adds an output.voidsetContext(Context context)Sets the application context to which the object belongs.voidsetLanguage(ScriptLanguage scriptLanguage)Overrides the script language to use when executing the script.voidsetReturnValueAppended(boolean appendReturnValue)Gets whether the return value is appended as an additional output.-
Methods inherited from class org.scijava.module.AbstractModuleInfo
getInput, getInput, getOutput, getOutput, inputList, inputMap, inputs, outputList, outputMap, outputs
-
Methods inherited from class org.scijava.AbstractUIDetails
getIconPath, getMenuPath, getMenuRoot, getPriority, getSelectionGroup, isEnabled, isSelectable, isSelected, isVisible, setEnabled, setIconPath, setMenuPath, setMenuRoot, setPriority, setSelectable, setSelected, setSelectionGroup, setVisible, toString
-
Methods inherited from class org.scijava.AbstractBasicDetails
get, getDescription, getLabel, getName, is, set, setDescription, setLabel, setName
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.scijava.BasicDetails
get, getDescription, getLabel, is, set, setDescription, setLabel
-
Methods inherited from interface org.scijava.module.ModuleInfo
canCancel, canPreview, getInitializer, getProblems, getTitle, isInteractive, isValid, update
-
Methods inherited from interface org.scijava.Prioritized
getPriority, setPriority
-
Methods inherited from interface org.scijava.UIDetails
compareTo, getIconPath, getMenuPath, getMenuRoot, getSelectionGroup, isEnabled, isSelectable, isSelected, isVisible, setEnabled, setIconPath, setMenuPath, setMenuRoot, setSelectable, setSelected, setSelectionGroup, setVisible
-
-
-
-
Constructor Detail
-
ScriptInfo
public ScriptInfo(Context context, File file)
Creates a script metadata object which describes the given script file.- Parameters:
context- The SciJava application context to use when populating service inputs.file- The script file.
-
ScriptInfo
public ScriptInfo(Context context, String path)
Creates a script metadata object which describes the given script file.- Parameters:
context- The SciJava application context to use when populating service inputs.path- Path to the script file.
-
ScriptInfo
public ScriptInfo(Context context, URL url, String path) throws IOException
Creates a script metadata object which describes a script at the given URL.- Parameters:
context- The SciJava application context to use when populating service inputs.url- URL which references the script.path- Pseudo-path to the script file. This file does not actually need to exist, but rather provides a name for the script with file extension.- Throws:
IOException
-
ScriptInfo
public ScriptInfo(Context context, String path, Reader reader)
Creates a script metadata object which describes a script provided by the givenReader.- Parameters:
context- The SciJava application context to use when populating service inputs.path- Pseudo-path to the script file. This file does not actually need to exist, but rather provides a name for the script with file extension.reader- Reader which provides the script itself (i.e., its contents).
-
-
Method Detail
-
getURL
public URL getURL()
Gets the URL of the script.If the actual source of the script is a URL (provided via
ScriptInfo(Context, URL, String)), then this will return it.Alternately, if the path (from
getPath()) is a real file on disk (provided viaScriptInfo(Context, File)orScriptInfo(Context, String)), then the URL returned here will be afile://one reference to it.Otherwise, this method will return null.
-
getPath
public String getPath()
Gets the path to the script on disk.If the path doesn't actually exist on disk, then this is a pseudo-path merely for the purpose of naming the script with a file extension, and the actual script content is delivered by the
BufferedReadergiven bygetReader().
-
getReader
public BufferedReader getReader()
Gets a reader which delivers the script's content.This might be null, in which case the content is stored in a file on disk given by
getPath().
-
getProcessedScript
public String getProcessedScript()
Gets the script contents after script processing.- Returns:
- The processed script.
- See Also:
ScriptProcessorService.process(org.scijava.script.ScriptInfo)
-
getLanguage
public ScriptLanguage getLanguage()
Gets the scripting language of the script.
-
setLanguage
public void setLanguage(ScriptLanguage scriptLanguage)
Overrides the script language to use when executing the script.
-
isReturnValueAppended
public boolean isReturnValueAppended()
Gets whether the return value is appended as an additional output.
-
setReturnValueAppended
public void setReturnValueAppended(boolean appendReturnValue)
Gets whether the return value is appended as an additional output.
-
callbacks
public List<ScriptCallback> callbacks()
Gets the list of routines which should be invoked each time the script is about to execute.- Returns:
- Reference to the mutable list of
Runnableobjects which theScriptModulewill run prior to executing the script itself.
-
parseParameters
public void parseParameters()
Performs script processing. In particular, parses the script parameters.- Overrides:
parseParametersin classAbstractModuleInfo- See Also:
ParameterScriptProcessor,ScriptProcessorService.process(org.scijava.script.ScriptInfo)
-
clearParameters
public void clearParameters()
Description copied from class:AbstractModuleInfoClears input and output parameters.- Overrides:
clearParametersin classAbstractModuleInfo
-
registerInput
public void registerInput(ModuleItem<?> input)
Description copied from class:AbstractModuleInfoAdds an input. Intended to be called from overriddenAbstractModuleInfo.parseParameters()methods.- Overrides:
registerInputin classAbstractModuleInfo
-
registerOutput
public void registerOutput(ModuleItem<?> output)
Description copied from class:AbstractModuleInfoAdds an output. Intended to be called from overriddenAbstractModuleInfo.parseParameters()methods.- Overrides:
registerOutputin classAbstractModuleInfo
-
getDelegateClassName
public String getDelegateClassName()
Description copied from interface:ModuleInfoGets the fully qualified name of the class containing the module's actual implementation. By definition, this is the same value returned bycreateModule().getDelegateObject().getClass().getName(), and hence is also the class containing any callback methods specified byModuleItem.getCallback().The nature of this method is implementation-specific; for example, a
CommandModulewill return the class name of its associatedCommand. For modules that are not commands, the result may be something else.If you are implementing this interface directly, a good rule of thumb is to return the class name of the associated
Module(i.e., the same value given bycreateModule().getClass().getName()).- Specified by:
getDelegateClassNamein interfaceModuleInfo
-
loadDelegateClass
public Class<?> loadDelegateClass()
Description copied from interface:ModuleInfoLoads the class containing the module's actual implementation. The name of the loaded class will match the value returned byModuleInfo.getDelegateClassName().- Specified by:
loadDelegateClassin interfaceModuleInfo- See Also:
Instantiable.loadClass()
-
createModule
public ScriptModule createModule() throws ModuleException
Description copied from interface:ModuleInfoInstantiates the module described by this module info.- Specified by:
createModulein interfaceModuleInfo- Throws:
ModuleException
-
canRunHeadless
public boolean canRunHeadless()
Description copied from interface:ModuleInfoGets whether the module condones headless execution. Strictly speaking, there is no guarantee that any module will work headless just because it declares itself so, but this flag hints that headless execution is likely to succeed (if flag is true), or fail (if flag is false).- Specified by:
canRunHeadlessin interfaceModuleInfo
-
context
public Context context()
Description copied from interface:ContextualGets the application context to which the object belongs.- Specified by:
contextin interfaceContextual- See Also:
Contextual.getContext()
-
getContext
public Context getContext()
Description copied from interface:ContextualGets the application context to which the object belongs, or null ifContextual.setContext(Context)has not yet been called on this object.- Specified by:
getContextin interfaceContextual- See Also:
Contextual.context()
-
setContext
public void setContext(Context context)
Description copied from interface:ContextualSets the application context to which the object belongs.Typically this method simply delegates to
Context.inject(Object), and should be called only once to populate the context. Most contextual objects do not support later alteration of the context, and will throwIllegalStateExceptionif this method is invoked again.- Specified by:
setContextin interfaceContextual- See Also:
Context.inject(Object)
-
getIdentifier
public String getIdentifier()
Description copied from interface:IdentifiableGets a string intended to function as an identifier for the object.- Specified by:
getIdentifierin interfaceIdentifiable- Specified by:
getIdentifierin interfaceModuleInfo
-
getLocation
public String getLocation()
Description copied from interface:LocatableGets the URL string defining the object's location.- Specified by:
getLocationin interfaceLocatable- Specified by:
getLocationin interfaceModuleInfo
-
getVersion
public String getVersion()
Description copied from interface:VersionedGets the version of the object.- Specified by:
getVersionin interfaceModuleInfo- Specified by:
getVersionin interfaceVersioned
-
isReturnValueDeclared
@Deprecated public boolean isReturnValueDeclared()
Deprecated.UseisReturnValueAppended()instead.
-
-