org.apache.commons.workflow.base
Class BaseBlock

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

public abstract class BaseBlock
extends DescriptorStep
implements org.apache.commons.workflow.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: 1.5 $ $Date: 2004/02/28 03:35:54 $

Field Summary
protected  org.apache.commons.workflow.Step firstStep
          The first Step associated with this Block.
protected  org.apache.commons.workflow.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(org.apache.commons.workflow.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(org.apache.commons.workflow.Context context)
          Evaluate the condition specified by the Descriptors associated with this Block, and return the resulting boolean value.
 void execute(org.apache.commons.workflow.Context context)
          Perform the executable actions related to this Step, in the context of the specified Context.
 org.apache.commons.workflow.Step findStep(java.lang.String id)
          Return the identified Step from this Block, if it exists.
 org.apache.commons.workflow.Step getFirstStep()
          Return the first Step associated with this Block.
 org.apache.commons.workflow.Step getLastStep()
          Return the last Step associated with this Activity.
 org.apache.commons.workflow.Step[] getSteps()
          Return the set of Steps associated with this Block.
protected  void initial(org.apache.commons.workflow.Context context)
          Process the initial entry into this Block.
 void setSteps(org.apache.commons.workflow.Step[] steps)
          Set the set of Steps associated with this Block, replacing any existing ones.
protected  org.apache.commons.workflow.BlockState state(org.apache.commons.workflow.Context context)
          Peek at the top BlockState element on the stack maintained by our Context, and return it.
protected  void subsequent(org.apache.commons.workflow.Context context, org.apache.commons.workflow.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 org.apache.commons.workflow.Step firstStep
The first Step associated with this Block.


lastStep

protected org.apache.commons.workflow.Step lastStep
The last Step associated with this Block.

Constructor Detail

BaseBlock

public BaseBlock()
Method Detail

getFirstStep

public org.apache.commons.workflow.Step getFirstStep()
Return the first Step associated with this Block.

Specified by:
getFirstStep in interface org.apache.commons.workflow.Owner

getLastStep

public org.apache.commons.workflow.Step getLastStep()
Return the last Step associated with this Activity.

Specified by:
getLastStep in interface org.apache.commons.workflow.Owner

addStep

public void addStep(org.apache.commons.workflow.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 org.apache.commons.workflow.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 org.apache.commons.workflow.Owner

findStep

public org.apache.commons.workflow.Step findStep(java.lang.String id)
Return the identified Step from this Block, if it exists. Otherwise, return null.

Specified by:
findStep in interface org.apache.commons.workflow.Owner
Parameters:
id - Identifier of the desired Step

getSteps

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

Specified by:
getSteps in interface org.apache.commons.workflow.Owner

setSteps

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

Specified by:
setSteps in interface org.apache.commons.workflow.Owner
Parameters:
steps - The new set of steps.

execute

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

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

evaluate

protected boolean evaluate(org.apache.commons.workflow.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(org.apache.commons.workflow.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 org.apache.commons.workflow.BlockState state(org.apache.commons.workflow.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(org.apache.commons.workflow.Context context,
                          org.apache.commons.workflow.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-2005 The Apache Software Foundation. All Rights Reserved.