adams.flow.transformer
Class Jython

java.lang.Object
  extended by adams.core.ConsoleObject
      extended by adams.core.option.AbstractOptionHandler
          extended by adams.flow.core.AbstractActor
              extended by adams.flow.core.AbstractScriptActor
                  extended by adams.flow.core.AbstractJythonActor
                      extended by adams.flow.transformer.Jython
All Implemented Interfaces:
adams.core.AdditionalInformationHandler, adams.core.CleanUpHandler, adams.core.Debuggable, adams.core.DebugOutputHandler, adams.core.Destroyable, OptionHandler, adams.core.QuickInfoSupporter, adams.core.ShallowCopySupporter<AbstractActor>, adams.core.SizeOfHandler, adams.core.Stoppable, VariableChangeListener, Actor, ErrorHandler, InputConsumer, OutputProducer, Serializable, Comparable

public class Jython
extends AbstractJythonActor
implements InputConsumer, OutputProducer

A transformer that uses a Jython script for processing the token(s).

Input/output:
- accepts:
   adams.flow.core.Unknown
- generates:
   adams.flow.core.Unknown

Valid options are:

-D (property: debug)
    If set to true, scheme may output additional info to the console.
 
-name <java.lang.String> (property: name)
    The name of the actor.
    default: Jython
 
-annotation <adams.core.base.BaseText> (property: annotations)
    The annotations to attach to this actor.
    default:
 
-skip (property: skip)
    If set to true, transformation is skipped and the input token is just forwarded
    as it is.
 
-script <adams.core.io.PlaceholderFile> (property: scriptFile)
    The script file to load and execute.
    default: .
 
-options <java.lang.String> (property: scriptOptions)
    The options for the Jython script; must consist of 'key=value' pairs separated
    by blanks; the value of 'key' can be accessed via the 'getAdditionalOption
    (String)' in the Jython actor.
    default:
 

Version:
$Revision: 4584 $
Author:
fracpete (fracpete at waikato dot ac dot nz)
See Also:
Serialized Form

Field Summary
static String BACKUP_INPUT
          the key for storing the current input in the backup.
protected  Token m_InputToken
          the current input token.
 
Fields inherited from class adams.flow.core.AbstractJythonActor
m_ActorObject, m_InlineScript
 
Fields inherited from class adams.flow.core.AbstractScriptActor
m_ScriptFile, m_ScriptObject, m_ScriptOptions
 
Fields inherited from class adams.flow.core.AbstractActor
m_Annotations, m_BackupState, m_DetectedObjectVariables, m_DetectedVariables, m_ErrorHandler, m_Executed, m_Executing, m_FullName, m_Headless, m_Name, m_Parent, m_Root, m_Self, m_Skip, m_StopFlowOnError, m_StopMessage, m_Stopped, m_StorageHandler, m_VariablesUpdated
 
Fields inherited from class adams.core.option.AbstractOptionHandler
m_DebugLevel, m_OptionManager
 
Fields inherited from interface adams.flow.core.Actor
FILE_EXTENSION, FILE_EXTENSION_GZ
 
Constructor Summary
Jython()
           
 
Method Summary
 Class[] accepts()
          Returns the class of objects that it accepts.
protected  Hashtable<String,Object> backupState()
          Backs up the current state of the actor before update the variables.
protected  String doExecute()
          Executes the flow item.
 Class[] generates()
          Returns the class of objects that it generates.
 String globalInfo()
          Returns a string describing the object.
 boolean hasPendingOutput()
          Checks whether there is pending output to be collected after executing the flow item.
 void input(Token token)
          The method that accepts the input token and then processes it.
 Token output()
          Returns the generated token.
protected  void pruneBackup()
          Removes entries from the backup.
protected  void restoreState(Hashtable<String,Object> state)
          Restores the state of the actor before the variables got updated.
 void wrapUp()
          Cleans up after the execution has finished.
 
Methods inherited from class adams.flow.core.AbstractJythonActor
checkScriptObject, defineOptions, getDefaultInlineScript, getInlineScript, getQuickInfo, inlineScriptTipText, loadScriptObject, scriptOptionsTipText, setInlineScript, setUp
 
Methods inherited from class adams.flow.core.AbstractScriptActor
getScriptFile, getScriptOptions, initScriptObject, scriptFileTipText, setScriptFile, setScriptOptions
 
Methods inherited from class adams.flow.core.AbstractActor
annotationsTipText, canInspectOptions, canPerformSetUpCheck, cleanUp, compareTo, debug, destroy, equals, execute, findVariables, findVariables, findVariables, forceVariables, forCommandLine, forName, getAdditionalInformation, getAnnotations, getDefaultName, getDetectedVariables, getErrorHandler, getFlowActors, getFullName, getName, getNextSibling, getParent, getPreviousSibling, getRoot, getSkip, getStopFlowOnError, getStopMessage, getStorageHandler, getVariables, handleError, handleException, hasErrorHandler, hasStopMessage, index, initialize, isBackedUp, isExecuted, isExecuting, isFinished, isHeadless, isStopped, nameTipText, performSetUpChecks, postExecute, preExecute, pruneBackup, reset, setAnnotations, setErrorHandler, setHeadless, setName, setParent, setSkip, setStopFlowOnError, setVariables, shallowCopy, shallowCopy, sizeOf, skipTipText, stopExecution, stopExecution, stopFlowOnErrorTipText, updateDetectedVariables, updatePrefix, updateVariables, variableChanged
 
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, debug, debugLevelTipText, finishInit, getDebugLevel, getOptionManager, isDebugOn, newOptionManager, setDebugLevel, toCommandLine, toString
 
Methods inherited from class adams.core.ConsoleObject
getDebugging, getSystemErr, getSystemOut
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface adams.flow.core.Actor
cleanUp, compareTo, debug, destroy, equals, execute, findVariables, getAnnotations, getDefaultName, getDetectedVariables, getErrorHandler, getFullName, getName, getNextSibling, getParent, getPreviousSibling, getQuickInfo, getRoot, getSkip, getStopFlowOnError, getStopMessage, getStorageHandler, getVariables, handleError, hasErrorHandler, hasStopMessage, index, isExecuted, isFinished, isHeadless, isStopped, setAnnotations, setErrorHandler, setHeadless, setName, setParent, setSkip, setStopFlowOnError, setUp, setVariables, sizeOf, stopExecution, stopExecution, variableChanged
 
Methods inherited from interface adams.core.AdditionalInformationHandler
getAdditionalInformation
 
Methods inherited from interface adams.core.option.OptionHandler
cleanUpOptions, defineOptions, getOptionManager
 

Field Detail

BACKUP_INPUT

public static final String BACKUP_INPUT
the key for storing the current input in the backup.

See Also:
Constant Field Values

m_InputToken

protected Token m_InputToken
the current input token.

Constructor Detail

Jython

public Jython()
Method Detail

globalInfo

public String globalInfo()
Returns a string describing the object.

Specified by:
globalInfo in class AbstractOptionHandler
Returns:
a description suitable for displaying in the gui

pruneBackup

protected void pruneBackup()
Removes entries from the backup.

Overrides:
pruneBackup in class AbstractActor

backupState

protected Hashtable<String,Object> backupState()
Backs up the current state of the actor before update the variables.

Overrides:
backupState in class AbstractActor
Returns:
the backup

restoreState

protected void restoreState(Hashtable<String,Object> state)
Restores the state of the actor before the variables got updated.

Overrides:
restoreState in class AbstractActor
Parameters:
state - the backup of the state to restore from

accepts

public Class[] accepts()
Returns the class of objects that it accepts.

Specified by:
accepts in interface InputConsumer
Returns:
adams.flow.core.Unknown.class

input

public void input(Token token)
The method that accepts the input token and then processes it.

Specified by:
input in interface InputConsumer
Parameters:
token - the token to accept and process

generates

public Class[] generates()
Returns the class of objects that it generates.

Specified by:
generates in interface OutputProducer
Returns:
adams.flow.core.Unknown.class

doExecute

protected String doExecute()
Executes the flow item.

Specified by:
doExecute in class AbstractActor
Returns:
null if everything is fine, otherwise error message

output

public Token output()
Returns the generated token.

Specified by:
output in interface OutputProducer
Returns:
the generated token

hasPendingOutput

public boolean hasPendingOutput()
Checks whether there is pending output to be collected after executing the flow item.

Specified by:
hasPendingOutput in interface OutputProducer
Returns:
true if there is pending output

wrapUp

public void wrapUp()
Cleans up after the execution has finished.

Specified by:
wrapUp in interface Actor
Overrides:
wrapUp in class AbstractJythonActor


Copyright © 2012 University of Waikato, Hamilton, NZ. All Rights Reserved.