it.amattioli.workstate.core
Class SequentialState

Show UML class diagram
java.lang.Object
  extended by it.amattioli.workstate.core.State
      extended by it.amattioli.workstate.core.RealState
          extended by it.amattioli.workstate.core.CompositeState
              extended by it.amattioli.workstate.core.SequentialState
All Implemented Interfaces:
AttributeHandler, AttributeReader, Receiver
Direct Known Subclasses:
Machine

public class SequentialState
extends CompositeState


Field Summary
static String CURRENT_STATE_TAG
           
 
Fields inherited from class it.amattioli.workstate.core.CompositeState
substates
 
Constructor Summary
SequentialState(MetaSequentialState metaState, CompositeState parent)
           
 
Method Summary
 void enter()
          Enter this state and execute the transition associated to the initial state.
 void enter(Stack<MetaState> entryStack)
          Enter in this state and position itself in one of its sub-states.
 void enterCurrent(Stack<MetaState> entryStack)
          Change the current sub-state of this state.
 void exitCurrent()
           
 State getCurrentState()
          Return the current sub-state of this state.
 boolean isRegion()
          Check if this state is a region of a ConcurrentState.
 void reEnterCurrent()
           
 void restore(StateMemento memento)
           
 void terminate()
           
 
Methods inherited from class it.amattioli.workstate.core.CompositeState
addAvailableEvents, admitEvent, buildEvent, equals, exit, getMemento, isComplete, receive, receiveEvent, reEnter
 
Methods inherited from class it.amattioli.workstate.core.RealState
addAllAttributes, getAllAttributes, getAttribute, getLocalAttributes, getTag, hasAllowedAttribute, hasOwnAttribute, reExit, setAttribute, toString
 
Methods inherited from class it.amattioli.workstate.core.State
checkActive, findAncestor, getAvailableEvents, getId, getMemento, getParent, getRootMachine, hasMetaState, isActive
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CURRENT_STATE_TAG

public static final String CURRENT_STATE_TAG
See Also:
Constant Field Values
Constructor Detail

SequentialState

public SequentialState(MetaSequentialState metaState,
                       CompositeState parent)
Method Detail

getCurrentState

public State getCurrentState()
Return the current sub-state of this state. At each time a sequential state is in one and only one sub-state. This method allows to know which is this sub-state. The current sub-state makes sense only for active states so, before entering and after entering this state the current sub-state will be null.

Returns:
the current sub-state of this state

enter

public void enter()
           throws WorkflowException
Enter this state and execute the transition associated to the initial state.

Overrides:
enter in class RealState
Throws:
WorkflowException

enter

public void enter(Stack<MetaState> entryStack)
           throws WorkflowException
Enter in this state and position itself in one of its sub-states. The given stack must contain a sequence of the sub-states that must be entered, the same as for enterCurrent(Stack). The difference between this method and enterCurrent(Stack) is that this method assumes that this state is not active so enters it and activate it while enterCurrent(Stack) assumes this state is already active.

Throws:
WorkflowException - if an action throws an exception

exitCurrent

public void exitCurrent()
                 throws WorkflowException
Throws:
WorkflowException

reEnterCurrent

public void reEnterCurrent()
                    throws WorkflowException
Throws:
WorkflowException

enterCurrent

public void enterCurrent(Stack<MetaState> entryStack)
                  throws WorkflowException
Change the current sub-state of this state. The given stack must contain the list of the tags of MetaState to enter. This method will set as current sub-state the one whose tag is on the top of the stack and will enter it passing the same stack after removing the top element. In this way the sub-state will set as its sub-state the one whose tag was in second position, and so on. Before calling this method exitCurrent() must be called so to exit the current sub-state.

Throws:
NullPointerException - if the parameter is null
IllegalArgumentException - if the stack is empty or contains an invalid tag
IllegalStateException - if the current sub-state is still active
WorkflowException - if an action throws an exception

restore

public void restore(StateMemento memento)
             throws WorkflowException
Overrides:
restore in class RealState
Throws:
WorkflowException

isRegion

public boolean isRegion()
Description copied from class: State
Check if this state is a region of a ConcurrentState. Only SequentialStates can be regions so the default implementation of this method return false.

Overrides:
isRegion in class State
Returns:
true if this state is a region of a ConcurrentState, false otherwise

terminate

public void terminate()
               throws WorkflowException
Overrides:
terminate in class CompositeState
Throws:
WorkflowException


Copyright © 2011. All Rights Reserved.