Arch4J 1.1

org.arch4j.clientcontroller
Class StateMachine

java.lang.Object
  |
  +--org.arch4j.clientcontroller.StateMachine

public class StateMachine
extends Object

Manages the transition and navigation of the current state and its sub-states.

Version:
1.0
Author:
David Colwell

Constructor Summary
protected StateMachine(Transition anEntryTransition, StateContext theParentContext)
          Constructor which accepts an entry transition and the parent context.
protected StateMachine(Transition anEntryTransition, Transition anExitTransition, StateContext theParentContext)
          Constructor which accepts an entry and exit transition and the parent context.
 
Method Summary
protected  void cleanupState()
          Recursively exit from the current state and state machine and all sub-states and sub-state machines.
protected  void cleanupSubState()
          Recursively exit from all sub-states and sub-state machines.
 ContextView getContextView()
          Returns a view of the current state's context.
 List getExternalEvents()
          Retrieves a String list of all possible external events that this state machine will react to.
 String getStateName()
          Retrieve the heirarchical state name given the current state.
 List getValidExternalEvents()
          Retrieve a String list of events based on transitions with currently passable guard conditions.
 void handleEvent(String event, Map arguments)
          This is the client's interface method for event handling.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StateMachine

protected StateMachine(Transition anEntryTransition,
                       StateContext theParentContext)
Constructor which accepts an entry transition and the parent context. The entry transition is executed and the current state is set to its result.


StateMachine

protected StateMachine(Transition anEntryTransition,
                       Transition anExitTransition,
                       StateContext theParentContext)
Constructor which accepts an entry and exit transition and the parent context. The entry transition is executed and the current state is set to its result.

Method Detail

getContextView

public ContextView getContextView()
Returns a view of the current state's context.


getExternalEvents

public List getExternalEvents()
Retrieves a String list of all possible external events that this state machine will react to. If the current state contains an embedded state machine, then its state is queried, and so on.


getValidExternalEvents

public List getValidExternalEvents()
Retrieve a String list of events based on transitions with currently passable guard conditions. This is based on the current state and any sub-states.


handleEvent

public void handleEvent(String event,
                        Map arguments)
This is the client's interface method for event handling. Most of the functionality is done by the handleExternalEvent method. handleEvent also handles any exceptions passed by action methods by putting the root state machine into an error state.

If the event is not handled, enter the error state. If any system related exceptions occur, they are reported and the state machine enters the error state.


cleanupSubState

protected void cleanupSubState()
                        throws StateMachineException
Recursively exit from all sub-states and sub-state machines.

Throws:
StateMachineException - if there is any problem processing the request. This might include a missing key-value, application server problems, failed domain validation, or data access errors.

cleanupState

protected void cleanupState()
                     throws StateMachineException
Recursively exit from the current state and state machine and all sub-states and sub-state machines.

Throws:
StateMachineException - if there is any problem processing the request. This might include a missing key-value, application server problems, failed domain validation, or data access errors.

getStateName

public String getStateName()
Retrieve the heirarchical state name given the current state. This will be of the form state1~state2~state3, for example, where state1 is state2's parent, and state2 is state3's parent. The total state will be from 1 to n layers deep.


Arch4J 1.1

Copyright © 2000-2004 SpiderLogic, a service of Wipfli Ullrich Bertelson LLP.