Caplin Trader 4.7.1

Class: module:caplin/trading/statemachine/State

module:caplin/trading/statemachine/State

Constructor

new module:caplin/trading/statemachine/State(sName, nTimeoutopt, sTimeoutStateopt)

Constructs a new instance of caplin.trading.statemachine.State with the specified attributes.

A State represents one of the conditions that a {@link module:caplin/trading/statemachine/StateMachine StateMachine} can be in. The complete set of states are held within a {@link module:caplin/trading/statemachine/StateModel StateModel} object, and the network diagram between those states is modeled as a list of possible state transitions from each State object.

Parameters:
Name Type Attributes Description
sName String The name of this state.
nTimeout int <optional>
The number of seconds after which this state will automatically timeout to another state.
sTimeoutState int <optional>
The state that will be transitioned to, if this state times out.
Throws:
if sName is not a valid string.
Type
module:caplin/core/Error

Methods

addTransition(oTransition)

Adds a state transition from this state, to some other state.
Parameters:
Name Type Description
oTransition module:caplin/trading/statemachine/Transition The transition to add — this may not share a trigger event with an already added module:caplin/trading/statemachine/Transition.
Throws:
if the transition is null, or is not a valid instance of module:caplin/trading/statemachine/Transition.
Type
module:caplin/core/Error

getAttributes()

Returns a map of name value pairs associated with this state.

This method provides a simple way for applications to associate attribute information with particular states. How this may be used, or why this might be useful, is dependent on each application, but a concrete example within the reference implementation is to store the disabled state for a text field. If the module:caplin/trading/statemachine/StateMachine is created from an XML file, these attributes will also be specified within the XML configuration.

getName()

Returns the name of this state.

getTimeout()

Returns the number of seconds after which this state will automatically timeout to another state.
See:
Returns:
The timeout in seconds, or null if no timeout has been configured.

getTimeoutState()

Returns the state that will be transitioned to, if this state times out.
See:
Returns:
The configured timeout state, or null if no timeout state has been configured.

getTransition(sEvent)

Returns the transition that will be used should the given event fire.
Parameters:
Name Type Description
sEvent String A trigger event that could fire.
Throws:
if the event trigger is invalid.
Type
module:caplin/core/Error

isFinalState()

Returns true if there are no other states that can be transitioned to from this state.