|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.taserv.SMS.SimpleStateMachine
public class SimpleStateMachine
State machine implementation
Field Summary | |
---|---|
static StateMachineObserverIF |
stateMachineObserver
The mechanism for tracing state machines and thier behavior. |
Constructor Summary | |
---|---|
SimpleStateMachine()
|
|
SimpleStateMachine(java.lang.String stateMachineName)
|
Method Summary | |
---|---|
void |
addEntryTransition(java.lang.Object stateObj,
EntryStateTransition trans)
Adds entry transition to the state. |
void |
addExitTransition(java.lang.Object stateObj,
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 origState,
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 |
printDebugInfo()
|
void |
removeEntryTransition(java.lang.Object stateObj,
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. |
void |
setSMName(java.lang.String name)
|
static void |
setStateMachineObserver(StateMachineObserverIF observer)
Sets state machine observer for tracing purposes. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static StateMachineObserverIF stateMachineObserver
setStateMachineObserver method
or by setting SMSDebuggerClass system property to the name of the class that should be
set as the observer.
Constructor Detail |
---|
public SimpleStateMachine()
public SimpleStateMachine(java.lang.String stateMachineName)
Method Detail |
---|
public static void setStateMachineObserver(StateMachineObserverIF observer)
observer
- the observer to be used for all state machinespublic java.lang.String getStateMachineName()
SimpleStateMachineIF
getStateMachineName
in interface SimpleStateMachineIF
public void setSMName(java.lang.String name)
public java.util.HashMap<java.lang.Enum,SMStateIF> getStates()
SimpleStateMachineIF
getStates
in interface SimpleStateMachineIF
public SMStateIF getCurrentState()
SimpleStateMachineIF
getCurrentState
in interface SimpleStateMachineIF
public void setSMMatrix(java.lang.Object[][] smMatrix) throws SMBadMatrix, SMStateCanNotCopy
SimpleStateMachineIF
setSMMatrix
in interface SimpleStateMachineIF
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>}, … }
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 statepublic void setSMMatrix(java.lang.Object stateObj, java.lang.Object[][] smMatrix) throws SMBadMatrix, SMStateCanNotCopy
SimpleStateMachineIF
setSMMatrix
in interface SimpleStateMachineIF
stateObj
- Enum or SMStateIF identifying the state that should have
behavior identified by smMatrixsmMatrix
- 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>}, … }
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 statepublic void addState(java.lang.Enum stateID) throws SMStateCanNotCopy
SimpleStateMachineIF
addState
in interface SimpleStateMachineIF
stateID
- enum id of the state to be added
SMStateCanNotCopy
- Thrown if the new state can not copy existing state into itselfpublic void addState(SMStateIF state) throws SMStateCanNotCopy
SimpleStateMachineIF
addState
in interface SimpleStateMachineIF
state
- state to be added
SMStateCanNotCopy
- Thrown if the new state can not copy existing state into itselfpublic void setCurrentState(SMStateIF state) throws SMStateNotFound
SimpleStateMachineIF
setCurrentState
in interface SimpleStateMachineIF
state
- the state to be set current
SMStateNotFound
- Thrown if the state does not exist in the SMpublic void setCurrentState(java.lang.Enum stateID) throws SMStateNotFound
SimpleStateMachineIF
setCurrentState
in interface SimpleStateMachineIF
stateID
- enum id of the state to be set current
SMStateNotFound
- Thrown if the state does not exist in the SMpublic void addTransition(SMStateIF origState, java.lang.Class triggerEventCls, StateTransition transition) throws SMStateCanNotCopy
SimpleStateMachineIF
addTransition
in interface SimpleStateMachineIF
origState
- the originating state of the transitiontriggerEventCls
- the class of the event that should trigger the transitiontransition
- the transition that will be preformed during handling
of the triggerEvent assuming the current state is origState
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 origStatepublic void addTransition(SMStateIF origState, java.lang.Class triggerEventCls, StateTransition transition, java.lang.Enum newState) throws SMStateCanNotCopy
SimpleStateMachineIF
addTransition
in interface SimpleStateMachineIF
origState
- the originating state of the transitiontriggerEventCls
- the class of the event that should trigger the transitiontransition
- the transition that will be preformed during handling
of the triggerEvent assuming the current state is origStatenewState
- enum id of the state to set current after execution of the
transition if the return value of the transition is NULL
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 origStatepublic void addTransition(java.lang.Enum origState, java.lang.Class triggerEventCls, StateTransition transition) throws SMStateCanNotCopy
SimpleStateMachineIF
addTransition
in interface SimpleStateMachineIF
origState
- the originating state of the transitiontriggerEventCls
- the class of the event that should trigger the transitiontransition
- the transition that will be preformed during handling
of the triggerEvent assuming the current state is origState
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 origStatepublic void addTransition(java.lang.Enum origStateEnum, java.lang.Class triggerEventCls, StateTransition transition, java.lang.Enum newState) throws SMStateCanNotCopy
SimpleStateMachineIF
addTransition
in interface SimpleStateMachineIF
origStateEnum
- the originating state of the transitiontriggerEventCls
- the class of the event that should trigger the transitiontransition
- the transition that will be preformed during handling
of the triggerEvent assuming the current state is origStatenewState
- enum id of the state to set current after execution of the
transition if the return value of the transition is NULL
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 origStatepublic boolean handleEvent(SMEvent event)
SimpleStateMachineIF
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.
handleEvent
in interface SimpleStateMachineIF
event
- event to be handled by SM
public void addEntryTransition(java.lang.Object stateObj, EntryStateTransition trans) throws SMBadMatrix, SMStateCanNotCopy
SimpleStateMachineIF
addEntryTransition
in interface SimpleStateMachineIF
stateObj
- Enum or SMStateIF identifying the statetrans
- the entry transition
SMBadMatrix
- if state is not Enum or SMStateIF
SMStateCanNotCopy
- if can not copy state datapublic void removeEntryTransition(java.lang.Object stateObj, EntryStateTransition trans) throws SMBadMatrix
SimpleStateMachineIF
removeEntryTransition
in interface SimpleStateMachineIF
stateObj
- Enum or SMStateIF identifying the statetrans
- the entry transition
SMBadMatrix
- if state is not Enum or SMStateIFpublic void addExitTransition(java.lang.Object stateObj, ExitStateTransition trans) throws SMBadMatrix, SMStateCanNotCopy
SimpleStateMachineIF
addExitTransition
in interface SimpleStateMachineIF
stateObj
- Enum or SMStateIF identifying the statetrans
- the exit transition
SMBadMatrix
- if state is not Enum or SMStateIF
SMStateCanNotCopy
- if can not copy state datapublic SimpleStateMachineIF getSMMachineIF(java.lang.Enum state) throws SMNotCompositeState, SMStateNotFound
SimpleStateMachineIF
getSMMachineIF
in interface SimpleStateMachineIF
state
- Enum identifying the state
SMNotCompositeState
- if the state is not composite
SMStateNotFound
- if the state does not existpublic void printDebugInfo()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |