public class DeterministicStateMachine extends java.lang.Object implements StateMachine
SynchronizedStateMachine| Modifier and Type | Field and Description |
|---|---|
protected FsmLogger |
logger
The logger.
|
INITIAL_STATE_NAME| Constructor and Description |
|---|
DeterministicStateMachine(java.lang.String name)
Create the object.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(StateListener listener)
Add a new listener.
|
void |
addListener(TransitionListener listener)
Add a new listener.
|
void |
addPreprocessor(Preprocessor preprocessor)
Add a new preprocessor.
|
void |
addState(State state)
Add a new state.
|
void |
addTransition(Transition transition)
Add a new transition.
|
void |
close()
Finish processing of the events and free all allocated resources.
|
boolean |
easterEgg()
Each software product should contain at least one easter egg.
|
State |
getActiveState()
Get the currently active state.
|
java.util.Set<State> |
getActiveStates()
Get the currently active states.
|
java.lang.String |
getName()
Get the name of the processor.
|
java.util.Set<State> |
getStates()
Get all defined states.
|
protected Transition |
getTransition(State state,
Event event)
Get transition of a specified event type defined for a state.
|
java.util.Set<Transition> |
getTransitions()
Get all defined transitions.
|
boolean |
isInFinalState()
Is the active state a final state?
|
Event |
process(Event event)
Process the event.
|
void |
setStartState(State state)
Set the start state.
|
void |
start()
Building of the processor is finished, prepare it to the events
processing.
|
java.lang.String |
toString() |
protected final FsmLogger logger
public DeterministicStateMachine(java.lang.String name)
name - the name of the state machinepublic void setStartState(State state) throws FsmException
StateMachinesetStartState in interface StateMachinestate - the stateFsmExceptionStateMachine.start(),
Processor.process(Event)public void start()
throws FsmException
Processorstart in interface Processorstart in interface StateMachineFsmException - if something failsProcessor.close()public void close()
ProcessorProcessor.close() should be
avoided. The behavior is not defined and may cause unpredictable
behavior, e.g. NullPointerException.close in interface java.lang.AutoCloseableclose in interface Processorclose in interface StateMachineProcessor.start()public void addState(State state) throws FsmException
StateMachineaddState in interface StateMachinestate - the stateFsmException - if something failspublic void addTransition(Transition transition) throws FsmException
StateMachineaddTransition in interface StateMachinetransition - the transitionFsmException - if something failspublic void addPreprocessor(Preprocessor preprocessor)
StateMachineaddPreprocessor in interface StateMachinepreprocessor - the preprocessorProcessor.process(Event),
StateMachine.start(),
StateMachine.close()public void addListener(StateListener listener)
StateMachineaddListener in interface StateMachinelistener - the listenerpublic void addListener(TransitionListener listener)
StateMachineaddListener in interface StateMachinelistener - the listenerpublic State getActiveState()
StateMachinegetActiveState in interface StateMachineStateMachine.getActiveStates()public java.util.Set<State> getActiveStates()
StateMachinegetActiveStates in interface StateMachineStateMachine.getActiveState()public Event process(Event event) throws FsmException
Processorprocess in interface Processorevent - the input eventFsmException - if something failspublic java.util.Set<State> getStates()
StateMachinegetStates in interface StateMachinepublic java.util.Set<Transition> getTransitions()
StateMachinegetTransitions in interface StateMachineprotected Transition getTransition(State state, Event event)
state - the state, it must be defined in the state machineevent - the eventpublic boolean isInFinalState()
StateMachineisInFinalState in interface StateMachinepublic java.lang.String toString()
toString in class java.lang.Objectpublic boolean easterEgg()
Copyright 2012-2013 Michal Turek, AnotherFSM.