Arch4J 1.1

org.arch4j.clientcontroller
Class Transition

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

public abstract class Transition
extends Object

A collection of transitions are specified by each state and driven by the state machine. A transition will handle an event if its guard conditions are met. The transition action leads to a new state.

All deriving transition implementations should have a section of javadoc in the class heading based on the following:

Transition overview

Version:
1.0
Author:
David Colwell

Constructor Summary
Transition()
          Constructs a Transition object.
 
Method Summary
abstract  State doAction(Map arguments, StateContext context)
          Complete any action for the transition and specify a resulting State.
protected  Object getExpectedValueFromArguments(Map arguments, String aKey)
          Helper method to retrieve an expected value from the argument list.
abstract  String getExternalEvent()
          Retrieves the name of the external event which this transition reacts to.
protected  Object getValueFromArguments(Map arguments, String aKey)
          Helper method to retrieve a value from the argument list.
protected  boolean isExternal()
          Allow the state machine to know if this is an external/internal transition.
abstract  boolean isGuardConditionMet(StateContext context)
          Checks guard conditions for this transition.
protected  void setAsInternal()
          Specify that this is an internal transition.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Transition

public Transition()
Constructs a Transition object.

Method Detail

setAsInternal

protected void setAsInternal()
Specify that this is an internal transition. That is, the transition does not change the current state and no exit or entry actions are called.


isExternal

protected boolean isExternal()
Allow the state machine to know if this is an external/internal transition.


getExternalEvent

public abstract String getExternalEvent()
Retrieves the name of the external event which this transition reacts to. If this is specified to be "*", then this Transition will match all events. Note that the guard condition will still be checked and the priority order for registered Transitions is sill valid.


isGuardConditionMet

public abstract boolean isGuardConditionMet(StateContext context)
Checks guard conditions for this transition. Guard conditions allow for event handling based on current context in addition to the event name. However, they are not intended to directly control state. For example, testing a username/password to transition to a logon state should be done in the doAction method which can also specify the logoff state on failure.

Returns:
true if conditions are met, otherwise false.

doAction

public abstract State doAction(Map arguments,
                               StateContext context)
                        throws StateMachineException
Complete any action for the transition and specify a resulting State.

Parameters:
arguments - a list of arguments for the event handler, may be null.
Returns:
the resulting State.
Throws:
StateMachineException - if there is a system related problem processing the request. This might be a missing key-value, application server problems, failed domain validation, or data access errors.

getExpectedValueFromArguments

protected Object getExpectedValueFromArguments(Map arguments,
                                               String aKey)
                                        throws ValueNotFoundException
Helper method to retrieve an expected value from the argument list. If the value doesn't exist it is assumed to be due to a development error.

Returns:
the value, if found.
Throws:
ValueNotFoundException - if the expected key-value is not found in the arguments.

getValueFromArguments

protected Object getValueFromArguments(Map arguments,
                                       String aKey)
                                throws ValueNotFoundException
Helper method to retrieve a value from the argument list.

Returns:
the value, if found, else null.
ValueNotFoundException

Arch4J 1.1

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