Package adams.flow.control
Class AbstractTee
-
- All Implemented Interfaces:
AdditionalInformationHandler,CleanUpHandler,Destroyable,GlobalInfoSupporter,LoggingLevelHandler,LoggingSupporter,OptionHandler,Pausable,QuickInfoSupporter,ShallowCopySupporter<Actor>,SizeOfHandler,Stoppable,StoppableWithFeedback,VariablesInspectionHandler,FlowPauseStateListener,VariableChangeListener,AtomicExecution,Actor,ActorHandler,ControlActor,ErrorHandler,Flushable,InputConsumer,MutableActorHandler,OutputProducer,SubFlowWrapUp,Serializable,Comparable
- Direct Known Subclasses:
RemoteExecutionTrigger,Tee,Trigger
public abstract class AbstractTee extends AbstractControlActor implements InputConsumer, OutputProducer, MutableActorHandler, AtomicExecution
Abstract ancestor for actors that tee-off tokens.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAbstractTee.TeeSwingWorkerSwingWorker for asynchronous execution of the tee's sub-actors.
-
Field Summary
Fields Modifier and Type Field Description static StringBACKUP_INPUTthe key for storing the input token in the backup.protected Sequencem_Actorsthe flow items.protected booleanm_Asynchronouswhether to execute sub-actors asynchronously.protected AbstractTee.TeeSwingWorkerm_AsynchronousWorkerthe swingworker in use for asynchronous execution.protected Tokenm_InputTokenthe input token.protected intm_MinimumActiveActorsthe minimum active actors this handler requires.protected Tokenm_OutputTokenthe output token.-
Fields inherited from class adams.flow.control.AbstractControlActor
m_Compatibility, m_PauseStateManager, m_SetUpSubActors
-
Fields inherited from class adams.flow.core.AbstractActor
m_Annotations, m_BackupState, m_DetectedObjectVariables, m_DetectedVariables, m_ErrorHandler, m_Executed, m_Executing, m_ExecutionListeningSupporter, m_FullName, m_LoggingPrefix, m_Name, m_Parent, m_ScopeHandler, m_Self, m_Silent, m_Skip, m_StopFlowOnError, m_StopMessage, m_Stopped, m_StorageHandler, m_VariablesUpdated
-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
Fields inherited from interface adams.flow.core.Actor
FILE_EXTENSION, FILE_EXTENSION_GZ
-
-
Constructor Summary
Constructors Constructor Description AbstractTee()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Class[]accepts()Returns the class that the consumer accepts.StringactorsTipText()Returns the tip text for this property.Stringadd(int index, Actor actor)Inserts the actor at the given position.Stringadd(Actor actor)Inserts the actor at the end.StringasynchronousTipText()Returns the tip text for this property.protected Hashtable<String,Object>backupState()Backs up the current state of the actor before update the variables.protected booleancanProcessInput(Token token)Returns whether the token can be processed in the tee actor.Stringcheck()Performs checks on the "sub-actors".protected abstract StringcheckTeeActor(int index, Actor actor)Checks the tee actor before it is set.protected abstract StringcheckTeeActors(Actor[] actors)Checks the tee actors before they are set via the setTeeActors method.voidcleanUp()Cleans up after the execution has finished.protected TokencreateTeeToken(Token token)Creates the token to tee-off.TokencurrentInput()Returns the current input token, if any.voiddefineOptions()Adds options to the internal list of options.protected StringdoExecute()Executes the flow item.Stringexecute()Executes the flow item.StringfinishBeforeStoppingTipText()Returns the tip text for this property.protected voidfinishedAsynchronousExecution()Called by the asynchronous swingworker when finished.voidflushExecution()Stops the processing of tokens without stopping the flow.protected voidforceVariables(Variables value)Updates the Variables instance in use.Class[]generates()Returns the class of objects that it generates.Actorget(int index)Returns the actor at the given position.ActorHandlerInfogetActorHandlerInfo()Returns some information about the actor handler, e.g., whether it can contain standalones and the actor execution.Actor[]getActors()Returns the actors to tee-off to.booleangetAsynchronous()Returns whether to finish processing before stopping execution.booleangetFinishBeforeStopping()Returns whether to finish processing before stopping execution.protected SequencegetInternalActors()Returns the internal representation of the actors.intgetMinimumActiveActors()Returns the minimum of (active) actors that need to be present in the tee branch.StringgetQuickInfo()Returns a quick info about the actor, which will be displayed in the GUI.intgetStoppingTimeout()Returns the timeout for waiting for the sub-flow to stop.booleanhasInput()Returns whether an input token is currently present.booleanhasPendingOutput()Checks whether there is pending output to be collected after executing the flow item.intindexOf(String actor)Returns the index of the actor.protected voidinitialize()Initializes the members.voidinput(Token token)The method that accepts the input token and then processes it.Tokenoutput()Returns the generated token.protected StringprocessInput(Token token)Processes the token normal, i.e., not in thread.Actorremove(int index)Removes the actor at the given position and returns the removed object.voidremoveAll()Removes all actors.protected voidrestoreState(Hashtable<String,Object> state)Restores the state of the actor before the variables got updated.Stringset(int index, Actor actor)Sets the actor at the given position.voidsetActors(Actor[] value)Sets the actor to tee-off to.voidsetAsynchronous(boolean value)Sets whether to finish processing before stopping execution.voidsetFinishBeforeStopping(boolean value)Sets whether to finish processing before stopping execution.voidsetLoggingLevel(LoggingLevel value)Sets the logging level.voidsetMinimumActiveActors(int value)Sets the minimum of (active) actors that need to be present in the tee branch.voidsetSkip(boolean value)Sets whether the transformation is skipped or not.voidsetStoppingTimeout(int value)Sets the timeout for waiting for the sub-flow to stop.protected StringsetUpSubActors()Performs the setUp of the sub-actors.protected abstract StringsetUpTeeActors()Gets called in the setUp() method.intsize()Returns the size of the group.voidstopExecution()Stops the execution.StringstoppingTimeoutTipText()Returns the tip text for this property.protected voidupdateParent()Updates the parent of all actors in this group.protected voidwaitForAsynchronousExecution()Waits for the asynchronous execution to finish.voidwrapUp()Finishes up the execution.-
Methods inherited from class adams.flow.control.AbstractControlActor
active, canInspectOptions, destroy, firstActive, firstInputConsumer, flowPauseStateChanged, isPaused, isSubFlowWrappedUp, lastActive, pauseExecution, preExecute, reset, resumeExecution, setParent, setUp, wrapUpSubFlow
-
Methods inherited from class adams.flow.core.AbstractActor
annotationsTipText, canPerformSetUpCheck, compareTo, configureLogger, equals, finalUpdateVariables, findVariables, findVariables, forCommandLine, forName, forName, getAdditionalInformation, getAnnotations, getDefaultName, getDetectedVariables, getErrorHandler, getFlowActors, getFlowExecutionListeningSupporter, getFullName, getName, getNextSibling, getParent, getParentComponent, getPreviousSibling, getRoot, getScopeHandler, getSilent, getSkip, getStopFlowOnError, getStopMessage, getStorageHandler, getVariables, handleError, handleException, hasErrorHandler, hasStopMessage, index, isBackedUp, isExecuted, isExecuting, isFinished, isHeadless, isStopped, nameTipText, performSetUpChecks, performVariableChecks, postExecute, pruneBackup, pruneBackup, setAnnotations, setErrorHandler, setName, setSilent, setStopFlowOnError, setVariables, shallowCopy, shallowCopy, silentTipText, sizeOf, skipTipText, stopExecution, stopFlowOnErrorTipText, updateDetectedVariables, updatePrefix, updateVariables, variableChanged
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, finishInit, getDefaultLoggingLevel, getOptionManager, globalInfo, loggingLevelTipText, newOptionManager, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.flow.core.Actor
compareTo, destroy, equals, findVariables, getAnnotations, getDefaultName, getDetectedVariables, getErrorHandler, getFlowExecutionListeningSupporter, getFullName, getName, getNextSibling, getParent, getParentComponent, getPreviousSibling, getRoot, getScopeHandler, getSilent, getSkip, getStopFlowOnError, getStopMessage, getStorageHandler, getVariables, handleError, hasErrorHandler, hasStopMessage, index, isExecuted, isFinished, isHeadless, isStopped, setAnnotations, setErrorHandler, setName, setParent, setSilent, setStopFlowOnError, setUp, setVariables, shallowCopy, shallowCopy, sizeOf, stopExecution, toCommandLine, variableChanged
-
Methods inherited from interface adams.flow.core.ActorHandler
firstActive, lastActive
-
Methods inherited from interface adams.core.AdditionalInformationHandler
getAdditionalInformation
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
Methods inherited from interface adams.core.logging.LoggingSupporter
getLogger, isLoggingEnabled
-
Methods inherited from interface adams.core.option.OptionHandler
cleanUpOptions, getOptionManager
-
Methods inherited from interface adams.core.VariablesInspectionHandler
canInspectOptions
-
-
-
-
Field Detail
-
BACKUP_INPUT
public static final String BACKUP_INPUT
the key for storing the input token in the backup.- See Also:
- Constant Field Values
-
m_Actors
protected Sequence m_Actors
the flow items.
-
m_InputToken
protected transient Token m_InputToken
the input token.
-
m_OutputToken
protected transient Token m_OutputToken
the output token.
-
m_MinimumActiveActors
protected int m_MinimumActiveActors
the minimum active actors this handler requires.
-
m_Asynchronous
protected boolean m_Asynchronous
whether to execute sub-actors asynchronously.
-
m_AsynchronousWorker
protected AbstractTee.TeeSwingWorker m_AsynchronousWorker
the swingworker in use for asynchronous execution.
-
-
Method Detail
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptionsin interfaceOptionHandler- Overrides:
defineOptionsin classAbstractActor
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initializein classAbstractControlActor
-
setLoggingLevel
public void setLoggingLevel(LoggingLevel value)
Sets the logging level.- Specified by:
setLoggingLevelin interfaceLoggingLevelHandler- Overrides:
setLoggingLevelin classAbstractOptionHandler- Parameters:
value- the level
-
setSkip
public void setSkip(boolean value)
Sets whether the transformation is skipped or not.- Specified by:
setSkipin interfaceActor- Overrides:
setSkipin classAbstractActor- Parameters:
value- true if transformation is to be skipped
-
check
public String check()
Performs checks on the "sub-actors".- Specified by:
checkin interfaceActorHandler- Overrides:
checkin classAbstractControlActor- Returns:
- null if checks passed or null in case of an error
-
checkTeeActor
protected abstract String checkTeeActor(int index, Actor actor)
Checks the tee actor before it is set. Returns an error message if the actor is not acceptable, null otherwise.- Parameters:
index- the index the actor gets setactor- the actor to check- Returns:
- null if accepted, otherwise error message
-
checkTeeActors
protected abstract String checkTeeActors(Actor[] actors)
Checks the tee actors before they are set via the setTeeActors method. Returns an error message if the actors are not acceptable, null otherwise.- Parameters:
actors- the actors to check- Returns:
- null if accepted, otherwise error message
-
setActors
public void setActors(Actor[] value)
Sets the actor to tee-off to.- Parameters:
value- the actor
-
getActors
public Actor[] getActors()
Returns the actors to tee-off to.- Returns:
- the actors
-
actorsTipText
public String actorsTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setFinishBeforeStopping
public void setFinishBeforeStopping(boolean value)
Sets whether to finish processing before stopping execution.- Specified by:
setFinishBeforeStoppingin interfaceAtomicExecution- Parameters:
value- if true then actor finishes processing first
-
getFinishBeforeStopping
public boolean getFinishBeforeStopping()
Returns whether to finish processing before stopping execution.- Specified by:
getFinishBeforeStoppingin interfaceAtomicExecution- Returns:
- true if actor finishes processing first
-
finishBeforeStoppingTipText
public String finishBeforeStoppingTipText()
Returns the tip text for this property.- Specified by:
finishBeforeStoppingTipTextin interfaceAtomicExecution- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setStoppingTimeout
public void setStoppingTimeout(int value)
Sets the timeout for waiting for the sub-flow to stop.- Specified by:
setStoppingTimeoutin interfaceAtomicExecution- Parameters:
value- timeout in milliseconds (<= 0 for infinity)
-
getStoppingTimeout
public int getStoppingTimeout()
Returns the timeout for waiting for the sub-flow to stop.- Specified by:
getStoppingTimeoutin interfaceAtomicExecution- Returns:
- timeout in milliseconds (<= 0 for infinity)
-
stoppingTimeoutTipText
public String stoppingTimeoutTipText()
Returns the tip text for this property.- Specified by:
stoppingTimeoutTipTextin interfaceAtomicExecution- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setAsynchronous
public void setAsynchronous(boolean value)
Sets whether to finish processing before stopping execution.- Parameters:
value- if true then actor finishes processing first
-
getAsynchronous
public boolean getAsynchronous()
Returns whether to finish processing before stopping execution.- Returns:
- true if actor finishes processing first
-
asynchronousTipText
public String asynchronousTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
updateParent
protected void updateParent()
Updates the parent of all actors in this group.- Overrides:
updateParentin classAbstractControlActor
-
forceVariables
protected void forceVariables(Variables value)
Updates the Variables instance in use.
Use with caution!- Overrides:
forceVariablesin classAbstractControlActor- Parameters:
value- the instance to use
-
size
public int size()
Returns the size of the group.- Specified by:
sizein interfaceActorHandler- Specified by:
sizein classAbstractControlActor- Returns:
- always 1
-
get
public Actor get(int index)
Returns the actor at the given position.- Specified by:
getin interfaceActorHandler- Specified by:
getin classAbstractControlActor- Parameters:
index- the position- Returns:
- the actor
-
set
public String set(int index, Actor actor)
Sets the actor at the given position.- Specified by:
setin interfaceActorHandler- Specified by:
setin classAbstractControlActor- Parameters:
index- the positionactor- the actor to set at this position- Returns:
- null if everything is fine, otherwise the error
- See Also:
checkTeeActor(int, Actor)
-
indexOf
public int indexOf(String actor)
Returns the index of the actor.- Specified by:
indexOfin interfaceActorHandler- Specified by:
indexOfin classAbstractControlActor- Parameters:
actor- the name of the actor to look for- Returns:
- the index of -1 if not found
-
add
public String add(Actor actor)
Inserts the actor at the end.- Specified by:
addin interfaceMutableActorHandler- Parameters:
actor- the actor to insert- Returns:
- null if everything is fine, otherwise the error
-
add
public String add(int index, Actor actor)
Inserts the actor at the given position.- Specified by:
addin interfaceMutableActorHandler- Parameters:
index- the positionactor- the actor to insert- Returns:
- null if everything is fine, otherwise the error
- See Also:
checkTeeActor(int, Actor)
-
remove
public Actor remove(int index)
Removes the actor at the given position and returns the removed object.- Specified by:
removein interfaceMutableActorHandler- Parameters:
index- the position- Returns:
- the removed actor
-
removeAll
public void removeAll()
Removes all actors.- Specified by:
removeAllin interfaceMutableActorHandler
-
getInternalActors
protected Sequence getInternalActors()
Returns the internal representation of the actors.- Returns:
- the internal actors
-
finishedAsynchronousExecution
protected void finishedAsynchronousExecution()
Called by the asynchronous swingworker when finished.
-
waitForAsynchronousExecution
protected void waitForAsynchronousExecution()
Waits for the asynchronous execution to finish.
-
getActorHandlerInfo
public ActorHandlerInfo getActorHandlerInfo()
Returns some information about the actor handler, e.g., whether it can contain standalones and the actor execution.- Specified by:
getActorHandlerInfoin interfaceActorHandler- Specified by:
getActorHandlerInfoin classAbstractControlActor- Returns:
- the info
-
getQuickInfo
public String getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.- Specified by:
getQuickInfoin interfaceActor- Specified by:
getQuickInfoin interfaceQuickInfoSupporter- Overrides:
getQuickInfoin classAbstractActor- Returns:
- null if no info available, otherwise short string
-
backupState
protected Hashtable<String,Object> backupState()
Backs up the current state of the actor before update the variables.- Overrides:
backupStatein classAbstractActor- Returns:
- the backup
- See Also:
AbstractActor.updateVariables(),AbstractActor.restoreState(Hashtable)
-
restoreState
protected void restoreState(Hashtable<String,Object> state)
Restores the state of the actor before the variables got updated.- Overrides:
restoreStatein classAbstractActor- Parameters:
state- the backup of the state to restore from- See Also:
AbstractActor.updateVariables(),AbstractActor.backupState()
-
accepts
public Class[] accepts()
Returns the class that the consumer accepts.- Specified by:
acceptsin interfaceInputConsumer- Returns:
- adams.flow.core.Unknown.class
-
setUpTeeActors
protected abstract String setUpTeeActors()
Gets called in the setUp() method. Returns null if tee-actors are fine, otherwise error message.- Returns:
- null if everything OK, otherwise error message
-
setMinimumActiveActors
public void setMinimumActiveActors(int value)
Sets the minimum of (active) actors that need to be present in the tee branch.- Parameters:
value- the required minimum of actors
-
getMinimumActiveActors
public int getMinimumActiveActors()
Returns the minimum of (active) actors that need to be present in the tee branch.- Returns:
- the required minimum of actors
-
setUpSubActors
protected String setUpSubActors()
Performs the setUp of the sub-actors.- Overrides:
setUpSubActorsin classAbstractControlActor- Returns:
- null if everything is fine, otherwise error message
-
createTeeToken
protected Token createTeeToken(Token token)
Creates the token to tee-off.- Parameters:
token- the input token- Returns:
- the token to tee-off
-
input
public void input(Token token)
The method that accepts the input token and then processes it.- Specified by:
inputin interfaceInputConsumer- Parameters:
token- the token to accept and process
-
hasInput
public boolean hasInput()
Returns whether an input token is currently present.- Specified by:
hasInputin interfaceInputConsumer- Returns:
- true if input token present
-
currentInput
public Token currentInput()
Returns the current input token, if any.- Specified by:
currentInputin interfaceInputConsumer- Returns:
- the input token, null if none present
-
canProcessInput
protected boolean canProcessInput(Token token)
Returns whether the token can be processed in the tee actor.- Parameters:
token- the token to process- Returns:
- true if token can be processed
-
processInput
protected String processInput(Token token)
Processes the token normal, i.e., not in thread.- Parameters:
token- the token to process- Returns:
- an optional error message, null if everything OK
-
doExecute
protected String doExecute()
Executes the flow item.- Specified by:
doExecutein classAbstractActor- Returns:
- null if everything is fine, otherwise error message
-
execute
public String execute()
Executes the flow item.- Specified by:
executein interfaceActor- Overrides:
executein classAbstractActor- Returns:
- null if everything is fine, otherwise error message
-
generates
public Class[] generates()
Returns the class of objects that it generates.- Specified by:
generatesin interfaceOutputProducer- Returns:
- adams.flow.core.Unknown.class
-
output
public Token output()
Returns the generated token.- Specified by:
outputin interfaceOutputProducer- Returns:
- the generated token
-
hasPendingOutput
public boolean hasPendingOutput()
Checks whether there is pending output to be collected after executing the flow item.- Specified by:
hasPendingOutputin interfaceOutputProducer- Returns:
- true if there is pending output
-
flushExecution
public void flushExecution()
Stops the processing of tokens without stopping the flow.- Specified by:
flushExecutionin interfaceActorHandler- Specified by:
flushExecutionin interfaceFlushable- Overrides:
flushExecutionin classAbstractControlActor
-
stopExecution
public void stopExecution()
Stops the execution.- Specified by:
stopExecutionin interfaceActor- Specified by:
stopExecutionin interfaceStoppable- Overrides:
stopExecutionin classAbstractControlActor
-
wrapUp
public void wrapUp()
Finishes up the execution.- Specified by:
wrapUpin interfaceActor- Overrides:
wrapUpin classAbstractControlActor
-
cleanUp
public void cleanUp()
Cleans up after the execution has finished. Also removes graphical components.- Specified by:
cleanUpin interfaceActor- Specified by:
cleanUpin interfaceCleanUpHandler- Overrides:
cleanUpin classAbstractControlActor
-
-