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, outputs
getIconPath, getMenuPath, getMenuRoot, getPriority, getSelectionGroup, isEnabled, isSelectable, isSelected, isVisible, setEnabled, setIconPath, setMenuPath, setMenuRoot, setPriority, setSelectable, setSelected, setSelectionGroup, setVisible, toString
get, getDescription, getLabel, getName, is, set, setDescription, setLabel, setName
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
canCancel, canPreview, getInitializer, getProblems, getTitle, isInteractive, isValid, update
compareTo, getIconPath, getMenuPath, getMenuRoot, getSelectionGroup, isEnabled, isSelectable, isSelected, isVisible, setEnabled, setIconPath, setMenuPath, setMenuRoot, setSelectable, setSelected, setSelectionGroup, setVisible
get, getDescription, getLabel, is, set, setDescription, setLabel
getPriority, setPriority
public 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.IOException
public 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 AbstractModuleInfo
ParameterScriptProcessor
,
ScriptProcessorService.process(org.scijava.script.ScriptInfo)
public void clearParameters()
AbstractModuleInfo
clearParameters
in class AbstractModuleInfo
public void registerInput(ModuleItem<?> input)
AbstractModuleInfo
AbstractModuleInfo.parseParameters()
methods.registerInput
in class AbstractModuleInfo
public void registerOutput(ModuleItem<?> output)
AbstractModuleInfo
AbstractModuleInfo.parseParameters()
methods.registerOutput
in class AbstractModuleInfo
public String getDelegateClassName()
ModuleInfo
createModule().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 ModuleInfo
public Class<?> loadDelegateClass()
ModuleInfo
ModuleInfo.getDelegateClassName()
.loadDelegateClass
in interface ModuleInfo
Instantiable.loadClass()
public ScriptModule createModule() throws ModuleException
ModuleInfo
createModule
in interface ModuleInfo
ModuleException
public boolean canRunHeadless()
ModuleInfo
canRunHeadless
in interface ModuleInfo
public Context context()
Contextual
context
in interface Contextual
Contextual.getContext()
public Context getContext()
Contextual
Contextual.setContext(Context)
has not yet been called on this object.getContext
in interface Contextual
Contextual.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 Contextual
Context.inject(Object)
public String getIdentifier()
Identifiable
getIdentifier
in interface Identifiable
getIdentifier
in interface ModuleInfo
public String getLocation()
Locatable
getLocation
in interface Locatable
getLocation
in interface ModuleInfo
public String getVersion()
Versioned
getVersion
in interface ModuleInfo
getVersion
in interface Versioned
@Deprecated public boolean isReturnValueDeclared()
isReturnValueAppended()
instead.Copyright © 2015–2022 SciJava. All rights reserved.