Class ForLoop<InputType>
- Type Parameters:
InputType-
- All Implemented Interfaces:
AttachableCommand<InputType>,BypassableCommand<InputType>,Command<InputType>,OrchestrationAware<InputType>
This command has the four components of a typical 'for' loop:
This command runs in two modes that are determined by the value of "evaluateAfterEveryCommand"
If evaluateAfterEveryCommand is true then the condition is evaluated after every command. If it is condition is true then the command aborts after the command.Else it continues.
If evaluateAfterEveryCommand is false then the condition is evaluated once after all the commands. If the condition is true then it repeats.
Please see the test case for a good example of this.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Stringprivate static final Stringprivate static final Stringprivate CommandDescriptor<InputType>Fields inherited from class org.chenile.owiz.impl.Chain
commandDescSet, currentIndex, INDEXFields inherited from class org.chenile.owiz.impl.CommandBase
commandDescriptor, orchConfigurator -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidattachCommand(AttachmentDescriptor<InputType> attachmentDescriptor, CommandDescriptor<InputType> command) Allow a command to attach itself to this chain.protected voidprotected booleanisConditionTrue(InputType context) protected booleanshouldRepeat(InputType context) Determines if the loop should repeat.protected booleanshouldStopChain(InputType context) AN extension point to allow sub classes to stop a chain if a condition is satisfied.Methods inherited from class org.chenile.owiz.impl.Chain
obtainExecutionCommandsMethods inherited from class org.chenile.owiz.impl.CommandBase
bypass, execute, getConfigValue, getId, getParentId, obtainCommand, postprocess, preprocess, setCommandDescriptor, setOrchConfigurator
-
Field Details
-
CONDITION
- See Also:
-
INCREMENT
- See Also:
-
EVALUATE_AFTER_EVERY_COMMAND
- See Also:
-
incrementCommand
-
-
Constructor Details
-
ForLoop
public ForLoop()
-
-
Method Details
-
shouldRepeat
Determines if the loop should repeat. If the condition expression does not exist, it will evaluate to false.The increment command (if it exists) is then executed before evaluating the condition using OGNL
Note that if the incrementCommand does not exist, then the body of the loop must have done the incrementation (just like a normal for loop). Else there can be an infinite loop!
- Parameters:
context- the execution context- Returns:
- true if loops should repeat, false otherwise.
- Throws:
Exception- OGNL exception
-
isConditionTrue
- Throws:
Exception
-
shouldStopChain
Description copied from class:ChainAN extension point to allow sub classes to stop a chain if a condition is satisfied.- Overrides:
shouldStopChainin classChain<InputType>- Parameters:
context- containing the data required.- Returns:
- false by default.
- Throws:
Exception- .
-
doExecute
-
attachCommand
public void attachCommand(AttachmentDescriptor<InputType> attachmentDescriptor, CommandDescriptor<InputType> command) Description copied from class:ChainAllow a command to attach itself to this chain. If the index is not specified then the attachment order defines the execution order. Else if index is explicitly specified then the execution order would be the ascending order of the index.- Specified by:
attachCommandin interfaceAttachableCommand<InputType>- Overrides:
attachCommandin classChain<InputType>
-