com.ptc.windchill.upgrade.util.fsm
Class StateDefinition

java.lang.Object
  extended bycom.ptc.windchill.upgrade.util.fsm.StateDefinition
Direct Known Subclasses:
BasicStateDefinition, StartStateDefinition, StopStateDefinition

public abstract class StateDefinition
extends Object

A description of a single state of a state machine (eg a MetaState). StateDefinitions record the events that a particular state can handle, and the actions that can be conditionally taken for each event type.


Field Summary
private  HashMap handlers_
           
(package private)  StateInstantiator stateInstantiator_
           
 
Constructor Summary
(package private) StateDefinition(StateInstantiator state_instantiator)
          A package internal method: create an instance
 
Method Summary
(package private)  State createStateInstance(StateMachine state_machine)
          A package internal method: use the state instantiator to create an instance of a state that uses this state definition.
 void describe()
          Dumps a description of this state definition to System.out.
private  ArrayList getEnabledReactionsFor(EventType event_type, State state)
          A package internal method: determine what reactions are applicable for the specified event_type, evaluating the conditions agaist the provided state.
(package private)  List getEventTypes()
          A package internal method: ask for the set of registered event types.
(package private)  void handleEvent(Event event)
          A package internal method: perform reaaction for the specified event.
(package private)  boolean isEventTypeEnabled(EventType event_type, State state)
          A package internal method: return whether the EventType enabled for the particular state instance.
(package private)  void registerHandler(EventType event_type, Condition condition, Reaction reaction)
          A package internal method: record that the reaction may be taken upon receiving events of type event_type, if the condition evaluates to true against the event's source state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

handlers_

private final HashMap handlers_

stateInstantiator_

final StateInstantiator stateInstantiator_
Constructor Detail

StateDefinition

StateDefinition(StateInstantiator state_instantiator)
A package internal method: create an instance

Method Detail

createStateInstance

final State createStateInstance(StateMachine state_machine)
A package internal method: use the state instantiator to create an instance of a state that uses this state definition.

Returns:
non-null state instance

registerHandler

final void registerHandler(EventType event_type,
                           Condition condition,
                           Reaction reaction)
A package internal method: record that the reaction may be taken upon receiving events of type event_type, if the condition evaluates to true against the event's source state.


getEnabledReactionsFor

private ArrayList getEnabledReactionsFor(EventType event_type,
                                         State state)
A package internal method: determine what reactions are applicable for the specified event_type, evaluating the conditions agaist the provided state.


handleEvent

final void handleEvent(Event event)
A package internal method: perform reaaction for the specified event. This looks up all actions registered for the Event's type, and determines which ones are applicable by evaluating the corresponding condition against the event's source state. If a single reaction is applicable, it will be executed. If no reactions are applicable, nothing will happen. If more than one reaction is applicable, a runtime exception will be thrown.


isEventTypeEnabled

final boolean isEventTypeEnabled(EventType event_type,
                                 State state)
A package internal method: return whether the EventType enabled for the particular state instance.


getEventTypes

final List getEventTypes()
A package internal method: ask for the set of registered event types.


describe

public void describe()
Dumps a description of this state definition to System.out.