org.scijava.script
Class ScriptModule

java.lang.Object
  extended by org.scijava.module.AbstractModule
      extended by org.scijava.script.ScriptModule
All Implemented Interfaces:
Runnable, Contextual, Module

public class ScriptModule
extends AbstractModule
implements Contextual

A Module which executes a script.

Author:
Curtis Rueden, Johannes Schindelin

Field Summary
static String RETURN_VALUE
           
 
Constructor Summary
ScriptModule(ScriptInfo info)
           
 
Method Summary
 Context context()
          Gets the application context to which the object belongs.
 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.
 ScriptEngine getEngine()
          Gets the script engine used to execute the script.
 ScriptInfo getInfo()
          Gets metadata about this module.
 ScriptLanguage getLanguage()
          Gets the scripting language of the script.
 Object getReturnValue()
          Gets the return value of the script.
 void run()
           
 void setContext(Context context)
          Sets the application context to which the object belongs.
 void setErrorWriter(Writer error)
          Sets the writer used to record the standard error stream.
 void setLanguage(ScriptLanguage scriptLanguage)
          Overrides the script language to use when executing the script.
 void setOutputWriter(Writer output)
          Sets the writer used to record the standard output stream.
 
Methods inherited from class org.scijava.module.AbstractModule
cancel, getDelegateObject, getInput, getInputs, getOutput, getOutputs, initialize, isResolved, preview, setInput, setInputs, setOutput, setOutputs, setResolved
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RETURN_VALUE

public static final String RETURN_VALUE
See Also:
Constant Field Values
Constructor Detail

ScriptModule

public ScriptModule(ScriptInfo info)
Method Detail

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.


setOutputWriter

public void setOutputWriter(Writer output)
Sets the writer used to record the standard output stream.


setErrorWriter

public void setErrorWriter(Writer error)
Sets the writer used to record the standard error stream.


getEngine

public ScriptEngine getEngine()
Gets the script engine used to execute the script.


getReturnValue

public Object getReturnValue()
Gets the return value of the script.


getInfo

public ScriptInfo getInfo()
Description copied from interface: Module
Gets metadata about this module.

Specified by:
getInfo in interface Module

run

public void run()
Specified by:
run in interface Runnable

context

public Context context()
Description copied from interface: Contextual
Gets the application context to which the object belongs.

Specified by:
context in interface Contextual
See Also:
Contextual.getContext()

getContext

public Context getContext()
Description copied from interface: Contextual
Gets the application context to which the object belongs, or null if Contextual.setContext(Context) has not yet been called on this object.

Specified by:
getContext in interface Contextual
See Also:
Contextual.context()

setContext

public void setContext(Context context)
Description copied from interface: Contextual
Sets 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 throw IllegalStateException if this method is invoked again.

Specified by:
setContext in interface Contextual
See Also:
Context.inject(Object), for an example of how to implement this interface


Copyright © 2009–2015 SciJava. All rights reserved.