|
Framework Professional Edition Package |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.prosyst.util.asm.StateMachine
public class StateMachine
The StateMachine is NFA (non-deterministic Finite State Machine) implementation. The difference, compared to the DFA, is that the state transitions depends not only on the current input event, but also on an arbitrary number of subsequent input events. Until these subsequent events occur it is not possible to determine which state the machine is in. Without theory, here are some important definitions:
Filter object. Those filters are matched to the state machine
properties.
In addition, it is allowed, to attach a listener to the state machine and
receive notification when:
| Field Summary | |
|---|---|
static int |
COMMAND_TRIGGER
|
static int |
EVENT_TRIGGER
|
| Constructor Summary | |
|---|---|
StateMachine()
|
|
| Method Summary | |
|---|---|
void |
addState(java.lang.String name)
Informs the state machine of availability of state |
void |
addTriggerCommand(java.lang.String command,
Transition transition)
Adds a new command with associated transition. |
void |
addTriggerEvent(org.osgi.framework.Filter rule,
Transition transition)
This method is used to add internal state transition forced by change of some of the state machine parameters. |
void |
call(java.lang.String command)
Calls a command, that was previously added with addCommand()
method. |
void |
clean()
Restores the state machine to it's initial *unfilled* state. |
boolean |
getBooleanProperty(java.lang.String name)
This is an utility method to obtain a property of boolean type |
java.lang.String |
getCurrentState()
Returns the current state of the machine. |
double |
getDoubleProperty(java.lang.String name,
double defaultValue)
This is an utility method to obtain fixed point double values. |
long |
getLongProperty(java.lang.String name,
long defaultValue)
This is an utility method to obtain a property that is of long, int, short or byte value. |
java.util.Dictionary |
getProperties()
Returns a dictionary of custom properties. |
java.lang.Object |
getProperty(java.lang.String name)
Gets a single property of the state machine |
void |
removeState(java.lang.String name)
Removes a state of the state machine if it was added by mistake. |
void |
reset()
Resets the state machine to it's initial state. |
void |
setCurrentState(java.lang.String name)
Manually sets the current state. |
protected void |
setCurrentState(java.lang.String newState,
java.lang.String transition)
This method would change the current state while notifying the listener that transition is executed. |
void |
setInitialState(java.lang.String name)
Sets the initial state of the state machine. |
void |
setProperty(java.lang.String name,
java.lang.Object value)
Sets a custom, user defined property. |
void |
setStateListener(StateMachineListener stateListener)
Assigns a new state listener. |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int COMMAND_TRIGGER
public static final int EVENT_TRIGGER
| Constructor Detail |
|---|
public StateMachine()
| Method Detail |
|---|
public void addTriggerEvent(org.osgi.framework.Filter rule,
Transition transition)
rule - the filter describing the expected properties valuetransition - the transition that is forced if the rule is satisfied.
public void addTriggerCommand(java.lang.String command,
Transition transition)
command - the command that triggers the transitiontransition - a transition triggered by the command
java.lang.IllegalArgumentException - in case that the transition is already
added for that command, fromState is set but is not added to the
state machine or toState is not added to the state machine.addState(String)public void addState(java.lang.String name)
name - the name of the state to addpublic void call(java.lang.String command)
addCommand()
method.
command - the name of the command to call
java.lang.IllegalArgumentException - if the command is not defined
java.lang.IllegalStateException - if the command may not be executed within the
current stateaddTriggerCommand(String, Transition)public void clean()
public java.lang.String getCurrentState()
public java.util.Dictionary getProperties()
setProperty(String,Object)public java.lang.Object getProperty(java.lang.String name)
name - the name of the property
public long getLongProperty(java.lang.String name,
long defaultValue)
name - the name of the propertydefaultValue - is returned in case that the property is not set. This
value will not be returned if the value is set, but is not of the
expected type.
public boolean getBooleanProperty(java.lang.String name)
name - the name of the property
false is returned.
public double getDoubleProperty(java.lang.String name,
double defaultValue)
name - the name of the propertydefaultValue - is returned in case that the property is not set. This
value will not be returned if the value is set, but is not of the
expected type.
public void removeState(java.lang.String name)
name - the name of the stateaddState(String)public void reset()
protected void setCurrentState(java.lang.String newState,
java.lang.String transition)
newState - the name of the new statetransition - the name of the transition that is executed or
nullpublic void setCurrentState(java.lang.String name)
name - the new state
java.lang.IllegalArgumentException - if the state is not addedaddState(String)public void setInitialState(java.lang.String name)
name - the name of the initial state
java.lang.IllegalArgumentException - if state is not understoodaddState(String)
public void setProperty(java.lang.String name,
java.lang.Object value)
name - the name of the propertyvalue - and it's valuepublic void setStateListener(StateMachineListener stateListener)
stateListener - The stateListener to set.public java.lang.String toString()
toString in class java.lang.ObjectObject.toString()
|
Framework Professional Edition Package |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||