Package adams.flow.source
Class SwitchedSource
-
- All Implemented Interfaces:
AdditionalInformationHandler,CleanUpHandler,Destroyable,GlobalInfoSupporter,LoggingLevelHandler,LoggingSupporter,OptionHandler,QuickInfoSupporter,ShallowCopySupporter<Actor>,SizeOfHandler,Stoppable,StoppableWithFeedback,VariablesInspectionHandler,VariableChangeListener,IndexedBooleanConditionSupporter,Actor,ActorHandler,ErrorHandler,Flushable,MutableActorHandler,OutputProducer,Serializable,Comparable
public class SwitchedSource extends AbstractSource implements MutableActorHandler, IndexedBooleanConditionSupporter
- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Actorm_ActiveCasethe active case.protected List<Actor>m_Casesthe "cases" to execute if the corresponding expression matches.protected BooleanCondition[]m_Conditionsthe "conditions" for the various switch cases.-
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 SwitchedSource()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Stringadd(int index, Actor actor)Inserts the actor at the given position.Stringadd(Actor actor)Inserts the actor at the end.StringcasesTipText()Returns the tip text for this property.Stringcheck()Performs checks on the "sub-actors".Stringcheck(int index, Actor actor)Performs checks on the "sub-actor".StringconditionsTipText()Returns the tip text for this property.voiddefineOptions()Adds options to the internal list of options.protected StringdoExecute()Executes the flow item.ActorfirstActive()Returns the first non-skipped actor.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[]getCases()Returns the cases.BooleanCondition[]getConditions()Returns the conditions to evaluate.StringgetQuickInfo()Returns a quick info about the actor, which will be displayed in the GUI.StringglobalInfo()Returns a string describing the object.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.ActorlastActive()Returns the last non-skipped actor.Tokenoutput()Returns the generated token.Actorremove(int index)Removes the actor at the given position and returns the removed object.voidremoveAll()Removes all actors.protected voidreset()Resets the actor.Stringset(int index, Actor actor)Sets the actor at the given position.voidsetCases(Actor[] value)Sets the cases.voidsetConditions(BooleanCondition[] value)Sets the conditions to evaluate.StringsetUp()Initializes the sub-actors for flow execution.intsize()Returns the size of the group.voidstopExecution()Stops the execution.booleansupports(BooleanCondition condition)Returns whether the condition is supported.protected voidupdateParent()Updates the parent of all actors in this group.protected intwhichCase()Determines which case to execute.-
Methods inherited from class adams.flow.core.AbstractActor
annotationsTipText, backupState, canInspectOptions, canPerformSetUpCheck, cleanUp, compareTo, configureLogger, destroy, equals, execute, 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, preExecute, pruneBackup, pruneBackup, restoreState, setAnnotations, setErrorHandler, setName, setParent, setSilent, setSkip, setStopFlowOnError, setVariables, shallowCopy, shallowCopy, silentTipText, sizeOf, skipTipText, stopExecution, stopFlowOnErrorTipText, updateDetectedVariables, updatePrefix, updateVariables, variableChanged, wrapUp
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, finishInit, getDefaultLoggingLevel, getOptionManager, loggingLevelTipText, newOptionManager, setLoggingLevel, 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
cleanUp, compareTo, destroy, equals, execute, 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, setSkip, setStopFlowOnError, setVariables, shallowCopy, shallowCopy, sizeOf, stopExecution, toCommandLine, variableChanged, wrapUp
-
Methods inherited from interface adams.core.AdditionalInformationHandler
getAdditionalInformation
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel, setLoggingLevel
-
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
-
m_Conditions
protected BooleanCondition[] m_Conditions
the "conditions" for the various switch cases.
-
m_Cases
protected List<Actor> m_Cases
the "cases" to execute if the corresponding expression matches.
-
m_ActiveCase
protected Actor m_ActiveCase
the active case.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfoin interfaceGlobalInfoSupporter- Specified by:
globalInfoin classAbstractOptionHandler- Returns:
- a description suitable for displaying in the gui
-
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 classAbstractActor
-
reset
protected void reset()
Resets the actor.- Overrides:
resetin classAbstractActor
-
setConditions
public void setConditions(BooleanCondition[] value)
Sets the conditions to evaluate.- Parameters:
value- the conditions
-
getConditions
public BooleanCondition[] getConditions()
Returns the conditions to evaluate.- Returns:
- the conditions
-
conditionsTipText
public String conditionsTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setCases
public void setCases(Actor[] value)
Sets the cases.- Parameters:
value- the cases
-
getCases
public Actor[] getCases()
Returns the cases.- Returns:
- the cases
-
casesTipText
public String casesTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
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
-
size
public int size()
Returns the size of the group.- Specified by:
sizein interfaceActorHandler- Returns:
- the number of cases
-
get
public Actor get(int index)
Returns the actor at the given position.- Specified by:
getin interfaceActorHandler- Parameters:
index- the position- Returns:
- the actor
-
updateParent
protected void updateParent()
Updates the parent of all actors in this group.
-
set
public String set(int index, Actor actor)
Sets the actor at the given position.- Specified by:
setin interfaceActorHandler- Parameters:
index- the positionactor- the actor to set at this position- Returns:
- null if successful, otherwise error message
-
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 successful, otherwise error message
-
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 successful, otherwise error message
-
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
-
indexOf
public int indexOf(String actor)
Returns the index of the actor.- Specified by:
indexOfin interfaceActorHandler- Parameters:
actor- the name of the actor to look for- Returns:
- the index of -1 if not found
-
firstActive
public Actor firstActive()
Returns the first non-skipped actor.- Specified by:
firstActivein interfaceActorHandler- Returns:
- the first 'active' actor, null if none available
-
lastActive
public Actor lastActive()
Returns the last non-skipped actor.- Specified by:
lastActivein interfaceActorHandler- Returns:
- the last 'active' actor, null if none available
-
supports
public boolean supports(BooleanCondition condition)
Returns whether the condition is supported.- Specified by:
supportsin interfaceIndexedBooleanConditionSupporter- Returns:
- true if supported, false otherwise
-
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- Returns:
- the info
-
forceVariables
protected void forceVariables(Variables value)
Updates the Variables instance in use.
Use with caution!- Overrides:
forceVariablesin classAbstractActor- Parameters:
value- the instance to use
-
check
public String check(int index, Actor actor)
Performs checks on the "sub-actor".- Parameters:
index- the index of the actoractor- the actor to check- Returns:
- null if successful passed, otherwise error message
-
check
public String check()
Performs checks on the "sub-actors".- Specified by:
checkin interfaceActorHandler- Returns:
- null
-
setUp
public String setUp()
Initializes the sub-actors for flow execution.- Specified by:
setUpin interfaceActor- Overrides:
setUpin classAbstractActor- Returns:
- null if everything is fine, otherwise error message
- See Also:
AbstractActor.reset()
-
whichCase
protected int whichCase()
Determines which case to execute.- Returns:
- the index of the case to execute
-
doExecute
protected String doExecute()
Executes the flow item.- Specified by:
doExecutein 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:
- the Class of the generated tokens
-
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
-
output
public Token output()
Returns the generated token.- Specified by:
outputin interfaceOutputProducer- Returns:
- the generated token
-
flushExecution
public void flushExecution()
Stops the processing of tokens without stopping the flow.- Specified by:
flushExecutionin interfaceActorHandler- Specified by:
flushExecutionin interfaceFlushable
-
stopExecution
public void stopExecution()
Stops the execution.- Specified by:
stopExecutionin interfaceActor- Specified by:
stopExecutionin interfaceStoppable- Overrides:
stopExecutionin classAbstractActor
-
-