org.xnap.util
Class AbstractStateMachine

java.lang.Object
  extended by org.xnap.util.AbstractStateMachine
Direct Known Subclasses:
FiniteStateMachine

public abstract class AbstractStateMachine
extends java.lang.Object

Provides an abstract state machine. Subclasses need to take care of the state transitions.


Constructor Summary
AbstractStateMachine(State initialState)
           
 
Method Summary
protected abstract  void canChange(State currentState, State newState)
          Invoked when a state transition is attempted.
 java.lang.String getDescription()
           
 State getState()
           
 void setDescription(java.lang.String description)
           
 void setState(State newState)
           
 void setState(State newState, java.lang.String description)
           
protected abstract  void stateChanged(State oldState, State newState)
          Invoked when the state has changed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractStateMachine

public AbstractStateMachine(State initialState)
Method Detail

getDescription

public java.lang.String getDescription()

getState

public State getState()

setDescription

public void setDescription(java.lang.String description)

setState

public void setState(State newState,
                     java.lang.String description)

setState

public void setState(State newState)

canChange

protected abstract void canChange(State currentState,
                                  State newState)
Invoked when a state transition is attempted. Should throw an exception if transistion is invalid.


stateChanged

protected abstract void stateChanged(State oldState,
                                     State newState)
Invoked when the state has changed.



Copyright © 2001-2005 XNap Team. All Rights Reserved.