Class
caplin.trading.statemachine

State

A State represents one of the conditions that a caplin.trading.statemachine.StateMachine StateMachine can be in. The complete set of states are held within a 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.

Constructor Summary

Attributes Name and Description
caplin.trading.statemachine.State(String sName, int nTimeout, int sTimeoutState)

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

Method Summary

Attributes Name and Description
void addTransition(caplin.trading.statemachine.Transition oTransition)

Adds a state transition from this state, to some other state.

Map getAttributes()

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

String getName()

Returns the name of this state.

int getTimeout()

Returns the number of seconds after which this state will automatically timeout to another state.

String getTimeoutState()

Returns the state that will be transitioned to, if this state times out.

caplin.trading.statemachine.Transition getTransition(String sEvent)

Returns the transition that will be used should the given event fire.

boolean isFinalState()

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

Constructor Detail

caplin.trading.statemachine.State(String sName, int nTimeout, int sTimeoutState)

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

Parameters
String sName The name of this state.
int nTimeout (Optional) The number of seconds after which this state will automatically timeout to another state.
int sTimeoutState (Optional) The state that will be transitioned to, if this state times out.
Throws
caplin.core.Error
if sName is not a valid string.

Method Detail

void addTransition(caplin.trading.statemachine.Transition oTransition)

Adds a state transition from this state, to some other state.

Parameters
caplin.trading.statemachine.Transition oTransition The transition to add — this may not share a trigger event with an already added caplin.trading.statemachine.Transition.
Throws
caplin.core.Error
if the transition is null, or is not a valid instance of caplin.trading.statemachine.Transition.

Map 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 caplin.trading.statemachine.StateMachine is created from an XML file, these attributes will also be specified within the XML configuration.

String getName()

Returns the name of this state.

int getTimeout()

Returns the number of seconds after which this state will automatically timeout to another state.

Returns
The timeout in seconds, or null if no timeout has been configured.
See
#getTimeoutState

String getTimeoutState()

Returns the state that will be transitioned to, if this state times out.

Returns
The configured timeout state, or null if no timeout state has been configured.
See
#getTimeout

caplin.trading.statemachine.Transition getTransition(String sEvent)

Returns the transition that will be used should the given event fire.

Parameters
String sEvent A trigger event that could fire.
Throws
caplin.core.Error
if the event trigger is invalid.

boolean isFinalState()

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