com.taserv.SMS
Class SMState

java.lang.Object
  extended by com.taserv.SMS.SMState
All Implemented Interfaces:
SMStateIF

public class SMState
extends java.lang.Object
implements SMStateIF

SM state implementation


Nested Class Summary
 class SMState.TransitionSegment
          Transition data holder
 
Constructor Summary
SMState(java.lang.Enum stateID)
           
SMState(java.lang.Enum stateID, java.lang.String stateName)
           
 
Method Summary
 void _entryTransition()
          Performs the state entry transisions, it should not be used or overloaded by user SM.
 void _exitTransition()
          Performs the state exit transisions, it should not be used or overloaded by user SM.
 void addEntryTransition(EntryStateTransition trans)
          Adds entry transition to be perfomed every time the state becomes current
 void addExitTransition(ExitStateTransition trans)
          Adds exit transition to be perfomed every time other state replaces the state as current
 void addTransition(java.lang.Class triggerEventCls, StateTransition transition)
          Adds transition to the state.
 void addTransition(java.lang.Class triggerEventCls, StateTransition transition, java.lang.Enum newState)
          Adds transition to the state.
 void copy(SMStateIF state)
          Copies state data such as transitions from the parameter state to the state
 void entryTransition()
           
 boolean equals(java.lang.Object state)
          The states assumed to be equal if their state ID are equal
 void exitTransition()
           
 java.util.HashSet<EntryStateTransition> getEntryTransitions()
          Returns the collection of the defined entry transitions
 java.util.HashMap<java.lang.Class,SMState.TransitionSegment> getEventTransitions()
          Returns collection of the transistions defined in the state
 java.util.HashSet<ExitStateTransition> getExitTransitions()
          Returns the collection of the defined exit transitions
 StateTransition getLastPerformedTrans()
          Returns the last transition performed by the state
 java.lang.Enum getStateID()
          Returns the Enum indetifying the state
 java.lang.String getStateName()
          Returns state name
 int hashCode()
          Returns state ID hashCode
protected  void performEntryTransition(EntryStateTransition trans)
           
protected  void performExitTransition(ExitStateTransition trans)
           
protected  java.lang.Enum performTransition(SMEvent event, StateTransition transition)
           
 void removeEntryTransition(EntryStateTransition trans)
          Removed entry transition
 java.lang.Enum stateHandleEvent(SMEvent event)
          Performs transition identified by the event class.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SMState

public SMState(java.lang.Enum stateID,
               java.lang.String stateName)

SMState

public SMState(java.lang.Enum stateID)
Method Detail

getStateID

public java.lang.Enum getStateID()
Description copied from interface: SMStateIF
Returns the Enum indetifying the state

Specified by:
getStateID in interface SMStateIF

getEventTransitions

public java.util.HashMap<java.lang.Class,SMState.TransitionSegment> getEventTransitions()
Description copied from interface: SMStateIF
Returns collection of the transistions defined in the state

Specified by:
getEventTransitions in interface SMStateIF
Returns:
the copy of the map of the defined transitions, the keys are the event classes that will trigger transitions

getEntryTransitions

public java.util.HashSet<EntryStateTransition> getEntryTransitions()
Description copied from interface: SMStateIF
Returns the collection of the defined entry transitions

Specified by:
getEntryTransitions in interface SMStateIF
Returns:
the copy of the Set of the entry transitions

getExitTransitions

public java.util.HashSet<ExitStateTransition> getExitTransitions()
Description copied from interface: SMStateIF
Returns the collection of the defined exit transitions

Specified by:
getExitTransitions in interface SMStateIF
Returns:
the copy of the Set of the exit transitions

getStateName

public java.lang.String getStateName()
Description copied from interface: SMStateIF
Returns state name

Specified by:
getStateName in interface SMStateIF

equals

public boolean equals(java.lang.Object state)
The states assumed to be equal if their state ID are equal

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Returns state ID hashCode

Overrides:
hashCode in class java.lang.Object

addTransition

public void addTransition(java.lang.Class triggerEventCls,
                          StateTransition transition)
Description copied from interface: SMStateIF
Adds transition to the state. If the transition for triggerEventCls exists, it will be replaced. New state returned by stateHandleEvent after executing the transition identified by the return value of the transition.

Specified by:
addTransition in interface SMStateIF
Parameters:
triggerEventCls - the class of the event that will trigger the transitions
transition - the transition object to be added

addTransition

public void addTransition(java.lang.Class triggerEventCls,
                          StateTransition transition,
                          java.lang.Enum newState)
Description copied from interface: SMStateIF
Adds transition to the state. If the transition for triggerEventCls exists, it will be replaced. New state returned by stateHandleEvent after executing the transition is newState if the return value of the transition is NULL

Specified by:
addTransition in interface SMStateIF
Parameters:
triggerEventCls - the class of the event that will trigger the transitions
transition - the transition object to be added
newState - Enum identifying the new state after performing the transition

performTransition

protected java.lang.Enum performTransition(SMEvent event,
                                           StateTransition transition)

stateHandleEvent

public java.lang.Enum stateHandleEvent(SMEvent event)
                                throws SMStateCanNotHandleEvent
Description copied from interface: SMStateIF
Performs transition identified by the event class. If the state does not have transition for the event class, SMStateCanNotHandleEvent thrown.

Specified by:
stateHandleEvent in interface SMStateIF
Parameters:
event - the event to be handled
Returns:
new state to set current. If transition object retuns non-NULL value, it is returned as new state, otherwise predefined newState returned
Throws:
SMStateCanNotHandleEvent - thrown if the state does not have a transition for the event class

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

addEntryTransition

public void addEntryTransition(EntryStateTransition trans)
Description copied from interface: SMStateIF
Adds entry transition to be perfomed every time the state becomes current

Specified by:
addEntryTransition in interface SMStateIF
Parameters:
trans - the transition to add

removeEntryTransition

public void removeEntryTransition(EntryStateTransition trans)
Description copied from interface: SMStateIF
Removed entry transition

Specified by:
removeEntryTransition in interface SMStateIF
Parameters:
trans - the transition to remove

addExitTransition

public void addExitTransition(ExitStateTransition trans)
Description copied from interface: SMStateIF
Adds exit transition to be perfomed every time other state replaces the state as current

Specified by:
addExitTransition in interface SMStateIF
Parameters:
trans - the transition to add

performExitTransition

protected void performExitTransition(ExitStateTransition trans)

_exitTransition

public void _exitTransition()
Description copied from interface: SMStateIF
Performs the state exit transisions, it should not be used or overloaded by user SM.

Specified by:
_exitTransition in interface SMStateIF

performEntryTransition

protected void performEntryTransition(EntryStateTransition trans)

_entryTransition

public void _entryTransition()
Description copied from interface: SMStateIF
Performs the state entry transisions, it should not be used or overloaded by user SM.

Specified by:
_entryTransition in interface SMStateIF

entryTransition

public void entryTransition()
Specified by:
entryTransition in interface SMStateIF

exitTransition

public void exitTransition()
Specified by:
exitTransition in interface SMStateIF

copy

public void copy(SMStateIF state)
          throws SMStateCanNotCopy
Description copied from interface: SMStateIF
Copies state data such as transitions from the parameter state to the state

Specified by:
copy in interface SMStateIF
Parameters:
state - the state to copy data from
Throws:
SMStateCanNotCopy

getLastPerformedTrans

public StateTransition getLastPerformedTrans()
Description copied from interface: SMStateIF
Returns the last transition performed by the state

Specified by:
getLastPerformedTrans in interface SMStateIF


Copyright © 2004 TAServ. All Rights Reserved.