public class ScriptInfo extends AbstractModuleInfo implements Contextual
APPLICATION_MENU_ROOT| Constructor and 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
given
Reader. |
ScriptInfo(Context context,
URL url,
String path)
Creates a script metadata object which describes a script at the given URL.
|
| Modifier and Type | Method and Description |
|---|---|
List<ScriptCallback> |
callbacks()
Gets the list of routines which should be invoked each time the script is
about to execute.
|
boolean |
canRunHeadless()
Gets whether the module condones headless execution.
|
void |
clearParameters()
Clears input and output parameters.
|
Context |
context()
Gets the application context to which the object belongs.
|
ScriptModule |
createModule()
Instantiates the module described by this module info.
|
Context |
getContext()
Gets the application context to which the object belongs, or null if
Contextual.setContext(Context) has not yet been called on this object. |
String |
getDelegateClassName()
Gets the fully qualified name of the class containing the module's actual
implementation.
|
String |
getIdentifier()
Gets a string intended to function as an identifier for the object.
|
ScriptLanguage |
getLanguage()
Gets the scripting language of the script.
|
String |
getLocation()
Gets the URL string defining the object's location.
|
String |
getPath()
Gets the path to the script on disk.
|
String |
getProcessedScript()
Gets the script contents after script processing.
|
BufferedReader |
getReader()
Gets a reader which delivers the script's content.
|
URL |
getURL()
Gets the URL of the script.
|
String |
getVersion()
Gets the version of the object.
|
boolean |
isReturnValueAppended()
Gets whether the return value is appended as an additional output.
|
boolean |
isReturnValueDeclared()
Deprecated.
Use
isReturnValueAppended() instead. |
Class<?> |
loadDelegateClass()
Loads the class containing the module's actual implementation.
|
void |
parseParameters()
Performs script processing.
|
void |
registerInput(ModuleItem<?> input)
Adds an input.
|
void |
registerOutput(ModuleItem<?> output)
Adds an output.
|
void |
setContext(Context context)
Sets the application context to which the object belongs.
|
void |
setLanguage(ScriptLanguage scriptLanguage)
Overrides the script language to use when executing the script.
|
void |
setReturnValueAppended(boolean appendReturnValue)
Gets whether the return value is appended as an additional output.
|
getInput, getInput, getOutput, getOutput, inputList, inputMap, inputs, outputList, outputMap, outputsgetIconPath, getMenuPath, getMenuRoot, getPriority, getSelectionGroup, isEnabled, isSelectable, isSelected, isVisible, setEnabled, setIconPath, setMenuPath, setMenuRoot, setPriority, setSelectable, setSelected, setSelectionGroup, setVisible, toStringget, getDescription, getLabel, getName, is, set, setDescription, setLabel, setNameclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitcanCancel, canPreview, getInitializer, getProblems, getTitle, isInteractive, isValid, updatecompareTo, getIconPath, getMenuPath, getMenuRoot, getSelectionGroup, isEnabled, isSelectable, isSelected, isVisible, setEnabled, setIconPath, setMenuPath, setMenuRoot, setSelectable, setSelected, setSelectionGroup, setVisibleget, getDescription, getLabel, is, set, setDescription, setLabelgetPriority, setPrioritypublic ScriptInfo(Context context, File file)
context - The SciJava application context to use when populating
service inputs.file - The script file.public ScriptInfo(Context context, String path)
context - The SciJava application context to use when populating
service inputs.path - Path to the script file.public ScriptInfo(Context context, URL url, String path) throws IOException
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.IOExceptionpublic ScriptInfo(Context context, String path, Reader reader)
Reader.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).public URL getURL()
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 via ScriptInfo(Context, File) or
ScriptInfo(Context, String)), then the URL returned here will be a
file:// one reference to it.
Otherwise, this method will return null.
public String getPath()
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 BufferedReader given by
getReader().
public BufferedReader getReader()
This might be null, in which case the content is stored in a file on disk
given by getPath().
public String getProcessedScript()
ScriptProcessorService.process(org.scijava.script.ScriptInfo)public ScriptLanguage getLanguage()
public void setLanguage(ScriptLanguage scriptLanguage)
public boolean isReturnValueAppended()
public void setReturnValueAppended(boolean appendReturnValue)
public List<ScriptCallback> callbacks()
Runnable objects which the
ScriptModule will run prior to executing the script itself.public void parseParameters()
parseParameters in class AbstractModuleInfoParameterScriptProcessor,
ScriptProcessorService.process(org.scijava.script.ScriptInfo)public void clearParameters()
AbstractModuleInfoclearParameters in class AbstractModuleInfopublic void registerInput(ModuleItem<?> input)
AbstractModuleInfoAbstractModuleInfo.parseParameters() methods.registerInput in class AbstractModuleInfopublic void registerOutput(ModuleItem<?> output)
AbstractModuleInfoAbstractModuleInfo.parseParameters() methods.registerOutput in class AbstractModuleInfopublic String getDelegateClassName()
ModuleInfocreateModule().getDelegateObject().getClass().getName(), and hence
is also the class containing any callback methods specified by
ModuleItem.getCallback().
The nature of this method is implementation-specific; for example, a
CommandModule will return the class name of its associated
Command. 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 by createModule().getClass().getName()).
getDelegateClassName in interface ModuleInfopublic Class<?> loadDelegateClass()
ModuleInfoModuleInfo.getDelegateClassName().loadDelegateClass in interface ModuleInfoInstantiable.loadClass()public ScriptModule createModule() throws ModuleException
ModuleInfocreateModule in interface ModuleInfoModuleExceptionpublic boolean canRunHeadless()
ModuleInfocanRunHeadless in interface ModuleInfopublic Context context()
Contextualcontext in interface ContextualContextual.getContext()public Context getContext()
ContextualContextual.setContext(Context) has not yet been called on this object.getContext in interface ContextualContextual.context()public void setContext(Context context)
Contextual
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 throw
IllegalStateException if this method is invoked again.
setContext in interface ContextualContext.inject(Object)public String getIdentifier()
IdentifiablegetIdentifier in interface IdentifiablegetIdentifier in interface ModuleInfopublic String getLocation()
LocatablegetLocation in interface LocatablegetLocation in interface ModuleInfopublic String getVersion()
VersionedgetVersion in interface ModuleInfogetVersion in interface Versioned@Deprecated public boolean isReturnValueDeclared()
isReturnValueAppended() instead.Copyright © 2015–2022 SciJava. All rights reserved.