com.taserv.SMS
Interface SimpleStateMachineIF

All Known Implementing Classes:
SimpleStateMachine, SMCompositeState

public interface SimpleStateMachineIF

Defines contract for manipulating state machine(SM) behavior definitions and SM scheduling. All state machines and composite states implement this interface.


Method Summary
 void addEntryTransition(java.lang.Object state, EntryStateTransition trans)
          Adds entry transition to the state.
 void addExitTransition(java.lang.Object state, ExitStateTransition trans)
          Adds exit transition to the state.
 void addState(java.lang.Enum stateID)
          Adds new state to SM or replaces existing state.
 void addState(SMStateIF state)
          Adds new state to SM or replaces existing state.
 void addTransition(java.lang.Enum origStateEnum, java.lang.Class triggerEventCls, StateTransition transition)
          Adds new transition to the SM or replaces existing transition identified by the origStateEnum and the event class.
 void addTransition(java.lang.Enum origStateEnum, java.lang.Class triggerEventCls, StateTransition transition, java.lang.Enum newState)
          Adds new transition to the SM or replaces existing transition identified by the origStateEnum and the event class.
 void addTransition(SMStateIF origState, java.lang.Class triggerEventCls, StateTransition transition)
          Adds new transition to the SM or replaces existing transition identified by the origState and the event class.
 void addTransition(SMStateIF origState, java.lang.Class triggerEventCls, StateTransition transition, java.lang.Enum newState)
          Adds new transition to the SM or replaces existing transition identified by the origState and the event class.
 SMStateIF getCurrentState()
          Returns current SM state
 SimpleStateMachineIF getSMMachineIF(java.lang.Enum state)
          Returns SimpleStateMachineIF interface for the state identified by state Enum
 java.lang.String getStateMachineName()
          Returns SM name
 java.util.HashMap<java.lang.Enum,SMStateIF> getStates()
          Returns states defined in the SM
 boolean handleEvent(SMEvent event)
          Entry point for SM event handling.
 void removeEntryTransition(java.lang.Object state, EntryStateTransition trans)
          Removes entry transition.
 void setCurrentState(java.lang.Enum stateID)
          Sets current SM state to the state identified by stateID
 void setCurrentState(SMStateIF state)
          Sets current SM state to the state
 void setSMMatrix(java.lang.Object[][] smMatrix)
          Adds states and transitions identified by smMatrix to the SM.
 void setSMMatrix(java.lang.Object stateObj, java.lang.Object[][] smMatrix)
          Adds states and transitions identified by smMatrix to the state identified by stateObj.
 

Method Detail

handleEvent

boolean handleEvent(SMEvent event)
Entry point for SM event handling. This method is used by SM scheduler to dispatch events to target SM. This method dispatches the event to the current SM state and if the state consumes the event, updates SM current state according to the state returned value. If the returned value is NULL, the current state does not change.

Parameters:
event - event to be handled by SM
Returns:
true if event was consumed by SM, false otherwise

addState

void addState(SMStateIF state)
              throws SMStateCanNotCopy
Adds new state to SM or replaces existing state. In case of replace existing state data such as events, transitions, etc. copied into new state.

Parameters:
state - state to be added
Throws:
SMStateCanNotCopy - Thrown if the new state can not copy existing state into itself

addState

void addState(java.lang.Enum stateID)
              throws SMStateCanNotCopy
Adds new state to SM or replaces existing state. In case of replace existing state data such as events, transitions, etc. copied into new state.

Parameters:
stateID - enum id of the state to be added
Throws:
SMStateCanNotCopy - Thrown if the new state can not copy existing state into itself

setCurrentState

void setCurrentState(SMStateIF state)
                     throws SMStateNotFound
Sets current SM state to the state

Parameters:
state - the state to be set current
Throws:
SMStateNotFound - Thrown if the state does not exist in the SM

setCurrentState

void setCurrentState(java.lang.Enum stateID)
                     throws SMStateNotFound
Sets current SM state to the state identified by stateID

Parameters:
stateID - enum id of the state to be set current
Throws:
SMStateNotFound - Thrown if the state does not exist in the SM

addTransition

void addTransition(SMStateIF origState,
                   java.lang.Class triggerEventCls,
                   StateTransition transition)
                   throws SMStateCanNotCopy
Adds new transition to the SM or replaces existing transition identified by the origState and the event class. The new state after execution of the transition identified by the return value of transition.

Parameters:
origState - the originating state of the transition
triggerEventCls - the class of the event that should trigger the transition
transition - the transition that will be preformed during handling of the triggerEvent assuming the current state is origState
Throws:
SMStateCanNotCopy - Thrown if the state identified by origState.stateID existed in the SM and was not equal to the origState and the existed state data can not be copied into the origState

addTransition

void addTransition(SMStateIF origState,
                   java.lang.Class triggerEventCls,
                   StateTransition transition,
                   java.lang.Enum newState)
                   throws SMStateCanNotCopy
Adds new transition to the SM or replaces existing transition identified by the origState and the event class. The new state after execution of the transition identified by newState if the return value of transition is NULL, otherwise the new states set to the return value of the transition

Parameters:
origState - the originating state of the transition
triggerEventCls - the class of the event that should trigger the transition
transition - the transition that will be preformed during handling of the triggerEvent assuming the current state is origState
newState - enum id of the state to set current after execution of the transition if the return value of the transition is NULL
Throws:
SMStateCanNotCopy - Thrown if the state identified by origState.stateID existed in the SM and was not equal to the origState and the existed state data can not be copied into the origState

addTransition

void addTransition(java.lang.Enum origStateEnum,
                   java.lang.Class triggerEventCls,
                   StateTransition transition)
                   throws SMStateCanNotCopy
Adds new transition to the SM or replaces existing transition identified by the origStateEnum and the event class. The new state after execution of the transition identified by the return value of the transition

Parameters:
origStateEnum - the originating state of the transition
triggerEventCls - the class of the event that should trigger the transition
transition - the transition that will be preformed during handling of the triggerEvent assuming the current state is origState
Throws:
SMStateCanNotCopy - Thrown if the state identified by origState.stateID existed in the SM and was not equal to the origState and the existed state data can not be copied into the origState

addTransition

void addTransition(java.lang.Enum origStateEnum,
                   java.lang.Class triggerEventCls,
                   StateTransition transition,
                   java.lang.Enum newState)
                   throws SMStateCanNotCopy
Adds new transition to the SM or replaces existing transition identified by the origStateEnum and the event class. The new state after execution of the transition identified by newState if the return value of transition is NULL, otherwise the new states set to the return value of the transition

Parameters:
origStateEnum - the originating state of the transition
triggerEventCls - the class of the event that should trigger the transition
transition - the transition that will be preformed during handling of the triggerEvent assuming the current state is origState
newState - enum id of the state to set current after execution of the transition if the return value of the transition is NULL
Throws:
SMStateCanNotCopy - Thrown if the state identified by origState.stateID existed in the SM and was not equal to the origState and the existed state data can not be copied into the origState

setSMMatrix

void setSMMatrix(java.lang.Object[][] smMatrix)
                 throws SMBadMatrix,
                        SMStateCanNotCopy
Adds states and transitions identified by smMatrix to the SM.

Parameters:
smMatrix - transitions matrix identifying the behavior of the SM. The matrix should have the following format:
    
{
 { state <Enum or SMStateIF>, eventClass<Class>, transitionObject<StateTransition>, newState <Enum>},
 { state1 <Enum or SMStateIF>, eventClass1<Class>, transitionObject1<StateTransition>, newState1 <Enum>},
 …
}
Throws:
SMBadMatrix - if smMatrix format does not comform to the above format
SMStateCanNotCopy - if one of the states has to be replaced and the existing state data could not be copied to the new state

setSMMatrix

void setSMMatrix(java.lang.Object stateObj,
                 java.lang.Object[][] smMatrix)
                 throws SMBadMatrix,
                        SMStateCanNotCopy
Adds states and transitions identified by smMatrix to the state identified by stateObj. The state identified by stateObj will be converted to SMCompositeState if needed.

Parameters:
stateObj - Enum or SMStateIF identifying the state that should have behavior identified by smMatrix
smMatrix - transitions matrix identifying the behavior of the state identified by stateObj The matrix should have the following format:
    
{
 { state <Enum or SMStateIF>, eventClass<Class>, transitionObject<StateTransition>, newState <Enum>},
 { state1 <Enum or SMStateIF>, eventClass1<Class>, transitionObject1<StateTransition>, newState1 <Enum>},
 …
}
Throws:
SMBadMatrix - if smMatrix format does not comform to the above format or stateObj is not Enum or SMStateIF
SMStateCanNotCopy - if one of the states has to be replaced and the existing state data could not be copied to the new state

addEntryTransition

void addEntryTransition(java.lang.Object state,
                        EntryStateTransition trans)
                        throws SMBadMatrix,
                               SMStateCanNotCopy
Adds entry transition to the state. The transition will be preformed every time the SM current state changes to the state

Parameters:
state - Enum or SMStateIF identifying the state
trans - the entry transition
Throws:
SMBadMatrix - if state is not Enum or SMStateIF
SMStateCanNotCopy - if can not copy state data

removeEntryTransition

void removeEntryTransition(java.lang.Object state,
                           EntryStateTransition trans)
                           throws SMBadMatrix
Removes entry transition.

Parameters:
state - Enum or SMStateIF identifying the state
trans - the entry transition
Throws:
SMBadMatrix - if state is not Enum or SMStateIF

addExitTransition

void addExitTransition(java.lang.Object state,
                       ExitStateTransition trans)
                       throws SMBadMatrix,
                              SMStateCanNotCopy
Adds exit transition to the state. The transition will be preformed every time the SM current state changes from the state to any other state

Parameters:
state - Enum or SMStateIF identifying the state
trans - the exit transition
Throws:
SMBadMatrix - if state is not Enum or SMStateIF
SMStateCanNotCopy - if can not copy state data

getSMMachineIF

SimpleStateMachineIF getSMMachineIF(java.lang.Enum state)
                                    throws SMNotCompositeState,
                                           SMStateNotFound
Returns SimpleStateMachineIF interface for the state identified by state Enum

Parameters:
state - Enum identifying the state
Returns:
SimpleStateMachineIF interface if the state is composite, otherwise throws SMNotCompositeState
Throws:
SMNotCompositeState - if the state is not composite
SMStateNotFound - if the state does not exist

getStates

java.util.HashMap<java.lang.Enum,SMStateIF> getStates()
Returns states defined in the SM

Returns:
copy of the defined states collection

getStateMachineName

java.lang.String getStateMachineName()
Returns SM name


getCurrentState

SMStateIF getCurrentState()
Returns current SM state



Copyright © 2004 TAServ. All Rights Reserved.