StateMachine
tracks state and manages transitions between them.
Attributes | Name and Description |
---|---|
|
caplin.trading.statemachine.StateMachine(caplin.trading.statemachine.StateModel oStateModel)
Constructs a |
Attributes | Name and Description |
---|---|
|
void
addStateChangedListener(caplin.trading.statemachine.StateChangedListener oStateChangedListener)
Adds a listener that will be notified any time the state of this statemachine changes. |
|
void
addTriggerActiveChangedListener(caplin.trading.statemachine.TriggerActiveChangedListener oTriggerActiveChangedListener, String sEvent)
Adds a listener that will be notified any time the supplied trigger goes from active to inactive or inactive to active. |
|
caplin.trading.statemachine.State
getCurrentState()
Gets the current state that the state machine is in. |
|
String
getName()
Returns the name that this state machine represents. |
|
String
getStateModel()
Returns the state model the state machine is an instance of. |
|
caplin.trading.validation.ValidationResult
processEvent(String sEvent, Object oContext)
Attempts to change the state to a new state, following a transition defined as being activated by the supplied Event. |
|
void
removeStateChangedListener(caplin.trading.statemachine.StateChangedListener oStateChangedListener)
Removes a StateChangedListener. |
|
void
removeTriggerActiveChangedListener(caplin.trading.statemachine.TriggerActiveChangedListener oTriggerActiveChangedListener, String sEvent)
Removes the specified listener from the list of those to be notified when the specified event triggers a transition from one state to another. |
|
void
testContext(Object oContext)
Tests a specific context against the current state. |
►
caplin.trading.statemachine.StateMachine(caplin.trading.statemachine.StateModel oStateModel)
Constructs a StateMachine
that uses the specified StateModel
to
determine which transitions are possible from the current state.
caplin.trading.statemachine.StateModel | oStateModel | The statemodel for this statemachine. May not be null. |
►
void
addStateChangedListener(caplin.trading.statemachine.StateChangedListener oStateChangedListener)
Adds a listener that will be notified any time the state of this statemachine changes.
caplin.trading.statemachine.StateChangedListener | oStateChangedListener | The listener that wishes to be notified of state changes. May not be null or undefined. |
►
void
addTriggerActiveChangedListener(caplin.trading.statemachine.TriggerActiveChangedListener oTriggerActiveChangedListener, String sEvent)
Adds a listener that will be notified any time the supplied trigger goes from active to inactive or inactive to active. A trigger is considered active if there is an event that would trigger a transition from the current state given the supplied context.
caplin.trading.statemachine.TriggerActiveChangedListener | oTriggerActiveChangedListener | The listener that wishes to be notified of possible state changes. May not be null or undefined. |
String | sEvent | The Event that we're interested in. Must be a non-null string. |
►
caplin.trading.statemachine.State
getCurrentState()
Gets the current state that the state machine is in.
►
String
getName()
Returns the name that this state machine represents.
►
String
getStateModel()
Returns the state model the state machine is an instance of.
►
caplin.trading.validation.ValidationResult
processEvent(String sEvent, Object oContext)
Attempts to change the state to a new state, following a transition defined as being activated by the supplied Event. If the validators pass, it will change state. If they do not pass, the state will remain the same.
String | sEvent | The event that triggers a transition to a new state. |
Object | oContext | The data to be validated - indicating whether or not the transition is allowed. |
►
void
removeStateChangedListener(caplin.trading.statemachine.StateChangedListener oStateChangedListener)
Removes a StateChangedListener.
caplin.trading.statemachine.StateChangedListener | oStateChangedListener | The listener that no longer wishes to be notified of state changes. May not be null or undefined. |
►
void
removeTriggerActiveChangedListener(caplin.trading.statemachine.TriggerActiveChangedListener oTriggerActiveChangedListener, String sEvent)
Removes the specified listener from the list of those to be notified when the specified event triggers a transition from one state to another.
caplin.trading.statemachine.TriggerActiveChangedListener | oTriggerActiveChangedListener | The listener that no longer wants to be notified of possible state changes. May not be null or undefined. |
String | sEvent | The Event that we're no longer interested in. Must be a non-null string. |
►
void
testContext(Object oContext)
Tests a specific context against the current state. If this new context would change the result of calling any validators - i.e. some transitions that under the previously tested context could not be followed can, under the supplied context be followed (or vice versa) - then all the TriggerActiveChangedListeners associated with the Event that would give a different result to before are notified. A concrete example is an execute button. It wants to be told any time the situation of the Execute trigger changes.
Object | oContext | the data context. May not be null or undefined. |