Package adams.flow.control
Class WhileLoop
-
- All Implemented Interfaces:
AdditionalInformationHandler
,CleanUpHandler
,Destroyable
,GlobalInfoSupporter
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,Pausable
,QuickInfoSupporter
,ShallowCopySupporter<Actor>
,SizeOfHandler
,Stoppable
,StoppableWithFeedback
,VariablesInspectionHandler
,FlowPauseStateListener
,VariableChangeListener
,BooleanConditionSupporter
,Actor
,ActorHandler
,ControlActor
,ErrorHandler
,Flushable
,InputConsumer
,MutableActorHandler
,SubFlowWrapUp
,Serializable
,Comparable
public class WhileLoop extends AbstractControlActor implements InputConsumer, MutableActorHandler, BooleanConditionSupporter
Emulates a while-loop. The sub-actor gets executed as long as the condition evaluates to 'true'.
Valid options are:
-D <int> (property: debugLevel) The greater the number the more additional info the scheme may output to the console (0 = off). default: 0 minimum: 0
-name <java.lang.String> (property: name) The name of the actor. default: WhileLoop
-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.
-stop-flow-on-error (property: stopFlowOnError) If set to true, the flow gets stopped in case this actor encounters an error; useful for critical actors.
-condition <adams.flow.condition.bool.BooleanCondition> (property: condition) The condition to evaluate - only as long as it evaluates to 'true' the loop actors get executed. default: adams.flow.condition.bool.Expression
-loop <adams.flow.core.Actor> [-loop ...] (property: actors) The actors to execute in the loop. default:
- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Sequence
m_Actors
the actors to execute.protected BooleanCondition
m_Condition
the boolean condition to evaluate.-
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 WhileLoop()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Class[]
accepts()
Returns the class that the consumer accepts.String
actorsTipText()
Returns the tip text for this property.String
add(int index, Actor actor)
Inserts the actor at the given position.String
add(Actor actor)
Inserts the actor at the end.String
conditionTipText()
Returns the tip text for this property.Token
currentInput()
Returns the current input token, if any.void
defineOptions()
Adds options to the internal list of options.protected String
doExecute()
Executes the flow item.protected boolean
doLoop()
Checks whether the loop should be executed.void
flushExecution()
Stops the processing of tokens without stopping the flow.protected void
forceVariables(Variables value)
Updates the Variables instance in use.Actor
get(int index)
Returns the actor at the given position.ActorHandlerInfo
getActorHandlerInfo()
Returns some information about the actor handler, e.g., whether it can contain standalones and the actor execution.Actor[]
getActors()
Returns the actors of the loop.BooleanCondition
getCondition()
Returns the condtion to evaluate.String
getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.String
globalInfo()
Returns a string describing the object.boolean
hasInput()
Returns whether an input token is currently present.int
indexOf(String actor)
Returns the index of the actor.protected void
initialize()
Initializes the members.void
input(Token token)
Does nothing.Actor
remove(int index)
Removes the actor at the given position and returns the removed object.void
removeAll()
Removes all actors.String
set(int index, Actor actor)
Sets the actor at the given position.void
setActors(Actor[] value)
Sets the actors of the loop.void
setCondition(BooleanCondition value)
Sets the condition to evaluate.void
setLoggingLevel(LoggingLevel value)
Sets the logging level.void
setSkip(boolean value)
Sets whether the transformation is skipped or not.String
setUp()
Initializes the sub-actors for flow execution.protected String
setUpLoopActors()
Gets called in the setUp() method.protected String
setUpSubActors()
Performs the setUp of the sub-actors.int
size()
Returns the size of the group.void
stopExecution()
Stops the execution.protected void
updateParent()
Updates the parent of all actors in this group.-
Methods inherited from class adams.flow.control.AbstractControlActor
active, canInspectOptions, check, cleanUp, destroy, firstActive, firstInputConsumer, flowPauseStateChanged, isPaused, isSubFlowWrappedUp, lastActive, pauseExecution, preExecute, reset, resumeExecution, setParent, wrapUp, wrapUpSubFlow
-
Methods inherited from class adams.flow.core.AbstractActor
annotationsTipText, backupState, canPerformSetUpCheck, compareTo, configureLogger, 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, pruneBackup, pruneBackup, restoreState, 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, 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
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, setStopFlowOnError, setVariables, shallowCopy, shallowCopy, sizeOf, stopExecution, toCommandLine, variableChanged, wrapUp
-
Methods inherited from interface adams.flow.core.ActorHandler
check, 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
-
m_Condition
protected BooleanCondition m_Condition
the boolean condition to evaluate.
-
m_Actors
protected Sequence m_Actors
the actors to execute.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfo
in interfaceGlobalInfoSupporter
- Specified by:
globalInfo
in classAbstractOptionHandler
- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptions
in interfaceOptionHandler
- Overrides:
defineOptions
in classAbstractActor
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initialize
in classAbstractControlActor
-
setLoggingLevel
public void setLoggingLevel(LoggingLevel value)
Sets the logging level.- Specified by:
setLoggingLevel
in interfaceLoggingLevelHandler
- Overrides:
setLoggingLevel
in classAbstractOptionHandler
- Parameters:
value
- the level
-
setSkip
public void setSkip(boolean value)
Sets whether the transformation is skipped or not.- Specified by:
setSkip
in interfaceActor
- Overrides:
setSkip
in classAbstractActor
- Parameters:
value
- true if transformation is to be skipped
-
setCondition
public void setCondition(BooleanCondition value)
Sets the condition to evaluate.- Specified by:
setCondition
in interfaceBooleanConditionSupporter
- Parameters:
value
- the condition
-
getCondition
public BooleanCondition getCondition()
Returns the condtion to evaluate.- Specified by:
getCondition
in interfaceBooleanConditionSupporter
- Returns:
- the condition
-
conditionTipText
public String conditionTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setActors
public void setActors(Actor[] value)
Sets the actors of the loop.- Parameters:
value
- the actors
-
getActors
public Actor[] getActors()
Returns the actors of the loop.- 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.
-
updateParent
protected void updateParent()
Updates the parent of all actors in this group.- Overrides:
updateParent
in classAbstractControlActor
-
getQuickInfo
public String getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.- Specified by:
getQuickInfo
in interfaceActor
- Specified by:
getQuickInfo
in interfaceQuickInfoSupporter
- Overrides:
getQuickInfo
in classAbstractActor
- Returns:
- null if no info available, otherwise short string
-
forceVariables
protected void forceVariables(Variables value)
Updates the Variables instance in use.
Use with caution!- Overrides:
forceVariables
in classAbstractControlActor
- Parameters:
value
- the instance to use
-
size
public int size()
Returns the size of the group.- Specified by:
size
in interfaceActorHandler
- Specified by:
size
in classAbstractControlActor
- Returns:
- always 1
-
get
public Actor get(int index)
Returns the actor at the given position.- Specified by:
get
in interfaceActorHandler
- Specified by:
get
in 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:
set
in interfaceActorHandler
- Specified by:
set
in classAbstractControlActor
- Parameters:
index
- the positionactor
- the actor to set at this position- Returns:
- null if successful, otherwise error message
-
indexOf
public int indexOf(String actor)
Returns the index of the actor.- Specified by:
indexOf
in interfaceActorHandler
- Specified by:
indexOf
in 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:
add
in 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:
add
in 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:
remove
in interfaceMutableActorHandler
- Parameters:
index
- the position- Returns:
- the removed actor
-
removeAll
public void removeAll()
Removes all actors.- Specified by:
removeAll
in interfaceMutableActorHandler
-
getActorHandlerInfo
public ActorHandlerInfo getActorHandlerInfo()
Returns some information about the actor handler, e.g., whether it can contain standalones and the actor execution.- Specified by:
getActorHandlerInfo
in interfaceActorHandler
- Specified by:
getActorHandlerInfo
in classAbstractControlActor
- Returns:
- the info
-
accepts
public Class[] accepts()
Returns the class that the consumer accepts.- Specified by:
accepts
in interfaceInputConsumer
- Returns:
- adams.flow.core.Unknown.class
-
setUpLoopActors
protected String setUpLoopActors()
Gets called in the setUp() method. Returns null if loop-actors are fine, otherwise error message.- Returns:
- null if everything OK, otherwise error message
-
setUpSubActors
protected String setUpSubActors()
Performs the setUp of the sub-actors.- Overrides:
setUpSubActors
in classAbstractControlActor
- Returns:
- null if everything is fine, otherwise error message
-
setUp
public String setUp()
Initializes the sub-actors for flow execution.- Specified by:
setUp
in interfaceActor
- Overrides:
setUp
in classAbstractControlActor
- Returns:
- null if everything is fine, otherwise error message
- See Also:
AbstractActor.reset()
-
input
public void input(Token token)
Does nothing.- Specified by:
input
in interfaceInputConsumer
- Parameters:
token
- the token to accept and process
-
hasInput
public boolean hasInput()
Returns whether an input token is currently present.- Specified by:
hasInput
in interfaceInputConsumer
- Returns:
- always false
-
currentInput
public Token currentInput()
Returns the current input token, if any.- Specified by:
currentInput
in interfaceInputConsumer
- Returns:
- always null
-
doLoop
protected boolean doLoop()
Checks whether the loop should be executed.- Returns:
- true if the loop should be executed
-
doExecute
protected String doExecute()
Executes the flow item.- Specified by:
doExecute
in classAbstractActor
- Returns:
- null if everything is fine, otherwise error message
-
flushExecution
public void flushExecution()
Stops the processing of tokens without stopping the flow.- Specified by:
flushExecution
in interfaceActorHandler
- Specified by:
flushExecution
in interfaceFlushable
- Overrides:
flushExecution
in classAbstractControlActor
-
stopExecution
public void stopExecution()
Stops the execution.- Specified by:
stopExecution
in interfaceActor
- Specified by:
stopExecution
in interfaceStoppable
- Overrides:
stopExecution
in classAbstractControlActor
-
-