org.squirrelframework.foundation.fsm.impl
Class TimedStateImpl<T extends StateMachine<T,S,E,C>,S,E,C>

java.lang.Object
  extended by org.squirrelframework.foundation.fsm.impl.TimedStateImpl<T,S,E,C>
All Implemented Interfaces:
SquirrelComponent, ImmutableState<T,S,E,C>, ImmutableTimedState<T,S,E,C>, MutableState<T,S,E,C>, MutableTimedState<T,S,E,C>, Visitable

public class TimedStateImpl<T extends StateMachine<T,S,E,C>,S,E,C>
extends Object
implements ImmutableTimedState<T,S,E,C>, MutableTimedState<T,S,E,C>


Field Summary
protected  Actions<T,S,E,C> entryActions
           
protected  Actions<T,S,E,C> exitActions
           
protected  S stateId
           
 
Method Summary
 void accept(Visitor visitor)
          Accepts a #Visitor.
 void addChildState(MutableState<T,S,E,C> childState)
           
 void addEntryAction(Action<T,S,E,C> newAction)
           
 void addEntryActions(List<Action<T,S,E,C>> newActions)
           
 void addExitAction(Action<T,S,E,C> newAction)
           
 void addExitActions(List<Action<T,S,E,C>> newActions)
           
 MutableTransition<T,S,E,C> addTransitionOn(E event)
           
 ImmutableTransition<T,S,E,C> checkConflictTransitions(ImmutableTransition<T,S,E,C> target, List<ImmutableTransition<T,S,E,C>> allTransitions)
           
 ImmutableState<T,S,E,C> enterByHistory(StateContext<T,S,E,C> stateContext)
          Enters this state by its history depending on its HistoryType.
 ImmutableState<T,S,E,C> enterDeep(StateContext<T,S,E,C> stateContext)
          Enters this state is deep mode: mode if there is one.
 ImmutableState<T,S,E,C> enterShallow(StateContext<T,S,E,C> stateContext)
          Enters this state is shallow mode: The entry action is executed and the initial state is entered in shallow mode if there is one.
 void entry(StateContext<T,S,E,C> stateContext)
          Entry state with state context
 void exit(StateContext<T,S,E,C> stateContext)
          Exit state with state context
 Set<E> getAcceptableEvents()
           
 List<ImmutableTransition<T,S,E,C>> getAllTransitions()
           
 C getAutoFireContext()
           
 E getAutoFireEvent()
           
 List<ImmutableState<T,S,E,C>> getChildStates()
           
 StateCompositeType getCompositeType()
           
 List<Action<T,S,E,C>> getEntryActions()
           
 List<Action<T,S,E,C>> getExitActions()
           
 HistoryType getHistoryType()
           
 long getInitialDelay()
           
 ImmutableState<T,S,E,C> getInitialState()
           
protected  String getKey(T stateMachine)
           
 int getLevel()
           
 ImmutableState<T,S,E,C> getParentState()
           
 String getPath()
           
 S getStateId()
           
 ImmutableState<T,S,E,C> getThis()
           
 long getTimeInterval()
           
 List<ImmutableTransition<T,S,E,C>> getTransitions(E event)
           
 boolean hasChildStates()
           
 void internalFire(StateContext<T,S,E,C> stateContext)
          Notify transitions when receiving event.
 boolean isFinalState()
           
 boolean isParallelState()
           
 boolean isRegion()
           
 boolean isRootState()
           
 void prioritizeTransitions()
           
 void setAutoFireContext(C context)
           
 void setAutoFireEvent(E event)
           
 void setCompositeType(StateCompositeType compositeType)
           
 void setFinal(boolean isFinal)
           
 void setHistoryType(HistoryType historyType)
           
 void setInitialDelay(long initialDelay)
           
 void setInitialState(MutableState<T,S,E,C> childInitialState)
           
 void setLevel(int level)
           
 void setParentState(MutableState<T,S,E,C> parent)
           
 void setTimeInterval(long timeInterval)
           
 String toString()
           
 void verify()
          Verify state correctness
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.squirrelframework.foundation.fsm.MutableState
addChildState, addEntryAction, addEntryActions, addExitAction, addExitActions, addTransitionOn, prioritizeTransitions, setCompositeType, setFinal, setHistoryType, setInitialState, setLevel, setParentState
 
Methods inherited from interface org.squirrelframework.foundation.fsm.ImmutableState
enterByHistory, enterDeep, enterShallow, entry, exit, getAcceptableEvents, getAllTransitions, getChildStates, getCompositeType, getEntryActions, getExitActions, getHistoryType, getInitialState, getLevel, getParentState, getPath, getStateId, getThis, getTransitions, hasChildStates, internalFire, isFinalState, isParallelState, isRegion, isRootState, verify
 
Methods inherited from interface org.squirrelframework.foundation.fsm.Visitable
accept
 

Field Detail

stateId

protected final S stateId

entryActions

protected final Actions<T extends StateMachine<T,S,E,C>,S,E,C> entryActions

exitActions

protected final Actions<T extends StateMachine<T,S,E,C>,S,E,C> exitActions
Method Detail

getTimeInterval

public long getTimeInterval()
Specified by:
getTimeInterval in interface ImmutableTimedState<T extends StateMachine<T,S,E,C>,S,E,C>

getAutoFireEvent

public E getAutoFireEvent()
Specified by:
getAutoFireEvent in interface ImmutableTimedState<T extends StateMachine<T,S,E,C>,S,E,C>

setTimeInterval

public void setTimeInterval(long timeInterval)
Specified by:
setTimeInterval in interface MutableTimedState<T extends StateMachine<T,S,E,C>,S,E,C>

setAutoFireEvent

public void setAutoFireEvent(E event)
Specified by:
setAutoFireEvent in interface MutableTimedState<T extends StateMachine<T,S,E,C>,S,E,C>

setInitialDelay

public void setInitialDelay(long initialDelay)
Specified by:
setInitialDelay in interface MutableTimedState<T extends StateMachine<T,S,E,C>,S,E,C>

getInitialDelay

public long getInitialDelay()
Specified by:
getInitialDelay in interface ImmutableTimedState<T extends StateMachine<T,S,E,C>,S,E,C>

setAutoFireContext

public void setAutoFireContext(C context)
Specified by:
setAutoFireContext in interface MutableTimedState<T extends StateMachine<T,S,E,C>,S,E,C>

getAutoFireContext

public C getAutoFireContext()
Specified by:
getAutoFireContext in interface ImmutableTimedState<T extends StateMachine<T,S,E,C>,S,E,C>

getStateId

public S getStateId()
Specified by:
getStateId in interface ImmutableState<T extends StateMachine<T,S,E,C>,S,E,C>
Returns:
state id

getEntryActions

public List<Action<T,S,E,C>> getEntryActions()
Specified by:
getEntryActions in interface ImmutableState<T extends StateMachine<T,S,E,C>,S,E,C>
Returns:
Activities executed when entering the state

getExitActions

public List<Action<T,S,E,C>> getExitActions()
Specified by:
getExitActions in interface ImmutableState<T extends StateMachine<T,S,E,C>,S,E,C>
Returns:
Activities executed when exiting the state

getAllTransitions

public List<ImmutableTransition<T,S,E,C>> getAllTransitions()
Specified by:
getAllTransitions in interface ImmutableState<T extends StateMachine<T,S,E,C>,S,E,C>
Returns:
All transitions start from this state

getTransitions

public List<ImmutableTransition<T,S,E,C>> getTransitions(E event)
Specified by:
getTransitions in interface ImmutableState<T extends StateMachine<T,S,E,C>,S,E,C>
Returns:
Transitions triggered by event

getAcceptableEvents

public Set<E> getAcceptableEvents()
Specified by:
getAcceptableEvents in interface ImmutableState<T extends StateMachine<T,S,E,C>,S,E,C>
Returns:
events that can be accepted by this state

prioritizeTransitions

public void prioritizeTransitions()
Specified by:
prioritizeTransitions in interface MutableState<T extends StateMachine<T,S,E,C>,S,E,C>

entry

public void entry(StateContext<T,S,E,C> stateContext)
Description copied from interface: ImmutableState
Entry state with state context

Specified by:
entry in interface ImmutableState<T extends StateMachine<T,S,E,C>,S,E,C>

exit

public void exit(StateContext<T,S,E,C> stateContext)
Description copied from interface: ImmutableState
Exit state with state context

Specified by:
exit in interface ImmutableState<T extends StateMachine<T,S,E,C>,S,E,C>

getParentState

public ImmutableState<T,S,E,C> getParentState()
Specified by:
getParentState in interface ImmutableState<T extends StateMachine<T,S,E,C>,S,E,C>
Returns:
parent state

getChildStates

public List<ImmutableState<T,S,E,C>> getChildStates()
Specified by:
getChildStates in interface ImmutableState<T extends StateMachine<T,S,E,C>,S,E,C>
Returns:
child states

hasChildStates

public boolean hasChildStates()
Specified by:
hasChildStates in interface ImmutableState<T extends StateMachine<T,S,E,C>,S,E,C>
Returns:
whether state has child states

setParentState

public void setParentState(MutableState<T,S,E,C> parent)
Specified by:
setParentState in interface MutableState<T extends StateMachine<T,S,E,C>,S,E,C>

getInitialState

public ImmutableState<T,S,E,C> getInitialState()
Specified by:
getInitialState in interface ImmutableState<T extends StateMachine<T,S,E,C>,S,E,C>
Returns:
initial child state

setInitialState

public void setInitialState(MutableState<T,S,E,C> childInitialState)
Specified by:
setInitialState in interface MutableState<T extends StateMachine<T,S,E,C>,S,E,C>

enterByHistory

public ImmutableState<T,S,E,C> enterByHistory(StateContext<T,S,E,C> stateContext)
Description copied from interface: ImmutableState
Enters this state by its history depending on its HistoryType. The Entry method has to be called already.

Specified by:
enterByHistory in interface ImmutableState<T extends StateMachine<T,S,E,C>,S,E,C>
Parameters:
stateContext - the state context.
Returns:
the active state. (depends on this statesHistoryType)

enterDeep

public ImmutableState<T,S,E,C> enterDeep(StateContext<T,S,E,C> stateContext)
Description copied from interface: ImmutableState
Enters this state is deep mode: mode if there is one.

Specified by:
enterDeep in interface ImmutableState<T extends StateMachine<T,S,E,C>,S,E,C>
Parameters:
stateContext - the event context.
Returns:
the active state.

enterShallow

public ImmutableState<T,S,E,C> enterShallow(StateContext<T,S,E,C> stateContext)
Description copied from interface: ImmutableState
Enters this state is shallow mode: The entry action is executed and the initial state is entered in shallow mode if there is one.

Specified by:
enterShallow in interface ImmutableState<T extends StateMachine<T,S,E,C>,S,E,C>
Returns:
child state entered by shadow

addTransitionOn

public MutableTransition<T,S,E,C> addTransitionOn(E event)
Specified by:
addTransitionOn in interface MutableState<T extends StateMachine<T,S,E,C>,S,E,C>

addEntryAction

public void addEntryAction(Action<T,S,E,C> newAction)
Specified by:
addEntryAction in interface MutableState<T extends StateMachine<T,S,E,C>,S,E,C>

addEntryActions

public void addEntryActions(List<Action<T,S,E,C>> newActions)
Specified by:
addEntryActions in interface MutableState<T extends StateMachine<T,S,E,C>,S,E,C>

addExitAction

public void addExitAction(Action<T,S,E,C> newAction)
Specified by:
addExitAction in interface MutableState<T extends StateMachine<T,S,E,C>,S,E,C>

addExitActions

public void addExitActions(List<Action<T,S,E,C>> newActions)
Specified by:
addExitActions in interface MutableState<T extends StateMachine<T,S,E,C>,S,E,C>

internalFire

public void internalFire(StateContext<T,S,E,C> stateContext)
Description copied from interface: ImmutableState
Notify transitions when receiving event.

Specified by:
internalFire in interface ImmutableState<T extends StateMachine<T,S,E,C>,S,E,C>

isRootState

public boolean isRootState()
Specified by:
isRootState in interface ImmutableState<T extends StateMachine<T,S,E,C>,S,E,C>
Returns:
whether state is root state

isFinalState

public boolean isFinalState()
Specified by:
isFinalState in interface ImmutableState<T extends StateMachine<T,S,E,C>,S,E,C>
Returns:
whether current state is final state

setFinal

public void setFinal(boolean isFinal)
Specified by:
setFinal in interface MutableState<T extends StateMachine<T,S,E,C>,S,E,C>

accept

public void accept(Visitor visitor)
Description copied from interface: Visitable
Accepts a #Visitor.

Specified by:
accept in interface Visitable
Parameters:
visitor - the visitor.

getLevel

public int getLevel()
Specified by:
getLevel in interface ImmutableState<T extends StateMachine<T,S,E,C>,S,E,C>
Returns:
hierarchy state level

setLevel

public void setLevel(int level)
Specified by:
setLevel in interface MutableState<T extends StateMachine<T,S,E,C>,S,E,C>

addChildState

public void addChildState(MutableState<T,S,E,C> childState)
Specified by:
addChildState in interface MutableState<T extends StateMachine<T,S,E,C>,S,E,C>

getHistoryType

public HistoryType getHistoryType()
Specified by:
getHistoryType in interface ImmutableState<T extends StateMachine<T,S,E,C>,S,E,C>
Returns:
Historical type of state

setHistoryType

public void setHistoryType(HistoryType historyType)
Specified by:
setHistoryType in interface MutableState<T extends StateMachine<T,S,E,C>,S,E,C>

getCompositeType

public StateCompositeType getCompositeType()
Specified by:
getCompositeType in interface ImmutableState<T extends StateMachine<T,S,E,C>,S,E,C>
Returns:
child states composite type

setCompositeType

public void setCompositeType(StateCompositeType compositeType)
Specified by:
setCompositeType in interface MutableState<T extends StateMachine<T,S,E,C>,S,E,C>

isParallelState

public boolean isParallelState()
Specified by:
isParallelState in interface ImmutableState<T extends StateMachine<T,S,E,C>,S,E,C>
Returns:
whether child states composite type is parallel

toString

public String toString()
Overrides:
toString in class Object

isRegion

public boolean isRegion()
Specified by:
isRegion in interface ImmutableState<T extends StateMachine<T,S,E,C>,S,E,C>

verify

public void verify()
Description copied from interface: ImmutableState
Verify state correctness

Specified by:
verify in interface ImmutableState<T extends StateMachine<T,S,E,C>,S,E,C>

checkConflictTransitions

public ImmutableTransition<T,S,E,C> checkConflictTransitions(ImmutableTransition<T,S,E,C> target,
                                                             List<ImmutableTransition<T,S,E,C>> allTransitions)

getThis

public ImmutableState<T,S,E,C> getThis()
Specified by:
getThis in interface ImmutableState<T extends StateMachine<T,S,E,C>,S,E,C>

getKey

protected String getKey(T stateMachine)

getPath

public String getPath()
Specified by:
getPath in interface ImmutableState<T extends StateMachine<T,S,E,C>,S,E,C>


Copyright © 2013-2014. All Rights Reserved.