newstate
Class FSMContext

java.lang.Object
  |
  +--java.util.Dictionary
        |
        +--java.util.Hashtable
              |
              +--newstate.FSMContext

public class FSMContext
extends java.util.Hashtable
implements java.io.Serializable

This is the context of a FSM. A context holds a reference to the current state and also functions as a repository for objects. To do that it extends from java.util.Hashtable. Objects can be stored with the hashtable's put method and retrieved with the hashtables get method.

See Also:
Serialized Form

Constructor Summary
FSMContext()
           
FSMContext(newstate.State s, FSM fsm)
          Create a new context with s as the first state
FSMContext(newstate.State s, FSM fsm, FSMAction i)
          Create a new context with s as the first state.
 
Method Summary
 void dispatch(java.lang.String event, java.lang.Object data)
          Dispatch an event e.
 java.util.Vector getEvents()
          Find out what events can be sent to the current state
 newstate.State getFirstState()
           
 FSM getFSM()
           
 FSMAction getInitialAction()
           
 newstate.State getState()
           
 void initialize()
          Initialize the context.
 void setFirstState(newstate.State s)
           
 void setFSM(FSM fsm)
           
 void setInitialAction(FSMAction a)
           
 void setState(newstate.State s)
           
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, rehash, remove, size, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FSMContext

public FSMContext()

FSMContext

public FSMContext(newstate.State s,
                  FSM fsm)
Create a new context with s as the first state
Parameters:
s - The first state

FSMContext

public FSMContext(newstate.State s,
                  FSM fsm,
                  FSMAction i)
Create a new context with s as the first state. an then execute i to initialize the context.
Parameters:
s - The first state
i - The initial action
Method Detail

setFSM

public void setFSM(FSM fsm)

getFSM

public FSM getFSM()

getEvents

public java.util.Vector getEvents()
Find out what events can be sent to the current state
Returns:
A list of events

initialize

public void initialize()
Initialize the context. Set first state and execute initial action.

setState

public void setState(newstate.State s)

getState

public newstate.State getState()

setFirstState

public void setFirstState(newstate.State s)

getFirstState

public newstate.State getFirstState()

setInitialAction

public void setInitialAction(FSMAction a)

getInitialAction

public FSMAction getInitialAction()

dispatch

public void dispatch(java.lang.String event,
                     java.lang.Object data)
Dispatch an event e.
Parameters:
e - The event - @param data Some additional data