public abstract class Machine
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
PROPERTY_NAME_STATE
Property name for 'state'.
|
| Constructor and Description |
|---|
Machine(TaskContext taskContext)
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a property change listener for property changes.
|
void |
addTransitionListener(TransitionListener listener)
Adds given
listener to this machine. |
java.lang.Object |
getProperty(java.lang.String name)
Returns the property value mapped to given
name. |
State |
getState()
Returns current state.
|
protected abstract boolean |
isAllowed(Transition transition)
Checks if given
transition is allowed. |
boolean |
isFinished()
Returns
finished flag value. |
protected abstract boolean |
isFinishing(Transition transition)
Checks if given
transition is an finishing condition. |
boolean |
isStarted()
Returns
started flag value. |
protected abstract boolean |
isStarting(Transition transition)
Checks if given
transition is a starting condition. |
protected void |
perform(TransitionContext context,
Task... tasks)
Performs each of given
tasks with specified
context. |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes a property change listener for property changes.
|
void |
removeTransitionListener(TransitionListener listener)
Removes given
listener from this machine. |
java.lang.Object |
setProperty(java.lang.String name,
java.lang.Object value)
Sets a property.
|
void |
setState(State state)
Sets state.
|
public static final java.lang.String PROPERTY_NAME_STATE
public Machine(TaskContext taskContext)
taskContext - task contextpublic final State getState()
public final void setState(State state) throws FSMException
state - new stateFSMException - if an error occurs.protected void perform(TransitionContext context, Task... tasks) throws FSMException
tasks with specified
context. Each task can be performed concurrently. This
method must guarantee that all tasks are performed before return.context - transition contexttasks - tasksFSMException - if an error occurs.public final boolean isStarted()
started flag value.public final boolean isFinished()
finished flag value.public final java.lang.Object getProperty(java.lang.String name)
name.name - property namename.public final java.lang.Object setProperty(java.lang.String name,
java.lang.Object value)
name - property namevalue - property valueprotected abstract boolean isStarting(Transition transition)
transition is a starting condition.
Default implementation always returns true. Override this
method if customizations are needed.transition - transition to checktransition is a starting condition;
false otherwise.protected abstract boolean isAllowed(Transition transition)
transition is allowed. Default
implementation always returns true. Override this method if
customizations are needed.transition - transition to check.transition is allowed; false if not
allowed.protected abstract boolean isFinishing(Transition transition)
transition is an finishing condition.
Default implementation always returns false. Override this
method if customizations are needed.transition - transition to checktransition is a finishing condition;
false otherwise.public void addTransitionListener(TransitionListener listener)
listener to this machine.listener - the listener to be addedpublic void removeTransitionListener(TransitionListener listener)
listener from this machine.listener - the listener to be removedpublic void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
listener - the listener to be addedpublic void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
listener - the listener to be removedCopyright © 2011. All Rights Reserved.