org.apache.commons.workflow.base
Class BaseBlock

java.lang.Object
  extended by org.apache.commons.workflow.base.BaseStep
      extended by org.apache.commons.workflow.base.DescriptorStep
          extended by org.apache.commons.workflow.base.BaseBlock
All Implemented Interfaces:
Block, Descriptors, Owner, Step
Direct Known Subclasses:
IfStep, WhileStep

public abstract class BaseBlock
extends DescriptorStep
implements Block

BaseBlock is a convenient base class for more sophisticated Block implementations. It includes management of the static relationships of nested Steps for this Step (each of which could conceptually also be a Block and have its own nested Steps).

Version:
$Revision: 155475 $ $Date: 2005-02-26 13:31:11 +0000 (Sat, 26 Feb 2005) $
Author:
Craig R. McClanahan

Field Summary
protected  Step firstStep
          The first Step associated with this Block.
protected  Step lastStep
          The last Step associated with this Block.
 
Fields inherited from class org.apache.commons.workflow.base.DescriptorStep
descriptors
 
Fields inherited from class org.apache.commons.workflow.base.BaseStep
id, nextStep, owner, previousStep
 
Constructor Summary
BaseBlock()
           
 
Method Summary
 void addStep(Step step)
          Add a new Step to the end of the sequence of Steps associated with this Block.
 void clearSteps()
          Clear any existing Steps associated with this Block.
protected  boolean evaluate(Context context)
          Evaluate the condition specified by the Descriptors associated with this Block, and return the resulting boolean value.
 void execute(Context context)
          Perform the executable actions related to this Step, in the context of the specified Context.
 Step findStep(String id)
          Return the identified Step from this Block, if it exists.
 Step getFirstStep()
          Return the first Step associated with this Block.
 Step getLastStep()
          Return the last Step associated with this Activity.
 Step[] getSteps()
          Return the set of Steps associated with this Block.
protected  void initial(Context context)
          Process the initial entry into this Block.
 void setSteps(Step[] steps)
          Set the set of Steps associated with this Block, replacing any existing ones.
protected  BlockState state(Context context)
          Peek at the top BlockState element on the stack maintained by our Context, and return it.
protected  void subsequent(Context context, BlockState state)
          Process the return from nested execution of the Steps associated with this Block.
 
Methods inherited from class org.apache.commons.workflow.base.DescriptorStep
addDescriptor, findDescriptors, removeDescriptor
 
Methods inherited from class org.apache.commons.workflow.base.BaseStep
getId, getNextStep, getOwner, getPreviousStep, setId, setNextStep, setOwner, setPreviousStep
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.commons.workflow.Step
getId, getNextStep, getOwner, getPreviousStep, setId, setNextStep, setOwner, setPreviousStep
 

Field Detail

firstStep

protected Step firstStep
The first Step associated with this Block.


lastStep

protected Step lastStep
The last Step associated with this Block.

Constructor Detail

BaseBlock

public BaseBlock()
Method Detail

getFirstStep

public Step getFirstStep()
Return the first Step associated with this Block.

Specified by:
getFirstStep in interface Owner

getLastStep

public Step getLastStep()
Return the last Step associated with this Activity.

Specified by:
getLastStep in interface Owner

addStep

public void addStep(Step step)

Add a new Step to the end of the sequence of Steps associated with this Block.

IMPLEMENTATION NOTE - The last nested Step is looped back to the owning Block in order to support the execution flow of control required by our BaseContext.

Specified by:
addStep in interface Owner
Parameters:
step - The new step to be added

clearSteps

public void clearSteps()
Clear any existing Steps associated with this Block.

Specified by:
clearSteps in interface Owner

findStep

public Step findStep(String id)
Return the identified Step from this Block, if it exists. Otherwise, return null.

Specified by:
findStep in interface Owner
Parameters:
id - Identifier of the desired Step

getSteps

public Step[] getSteps()
Return the set of Steps associated with this Block.

Specified by:
getSteps in interface Owner

setSteps

public void setSteps(Step[] steps)
Set the set of Steps associated with this Block, replacing any existing ones.

Specified by:
setSteps in interface Owner
Parameters:
steps - The new set of steps.

execute

public void execute(Context context)
             throws StepException
Perform the executable actions related to this Step, in the context of the specified Context.

Specified by:
execute in interface Step
Specified by:
execute in class BaseStep
Parameters:
context - The Context that is tracking our execution state
Throws:
StepException - if a processing error has occurred

evaluate

protected boolean evaluate(Context context)

Evaluate the condition specified by the Descriptors associated with this Block, and return the resulting boolean value. The default implementation returns false unconditionally.

Parameters:
context - Context within which to evaluate the descriptors

initial

protected void initial(Context context)

Process the initial entry into this Block. The default implementation unconditionally skips the nested Steps.

Parameters:
context - Context within which to evaluate the condition

state

protected BlockState state(Context context)

Peek at the top BlockState element on the stack maintained by our Context, and return it. If there is no such top element, return null instead.

Parameters:
context - Context within which to evaluate the current BlockState

subsequent

protected void subsequent(Context context,
                          BlockState state)

Process the return from nested execution of the Steps associated with this Block. The default implementation unconditionally proceeds to the next Step at the current nesting level, without iterating again.

Parameters:
context - Context within which to evaluate the condition
state - BlockState for our block


Copyright © 2001-2010 The Apache Software Foundation. All Rights Reserved.