Class
caplin.trading.statemachine

StateModel

The StateModel represents the network of caplin.trading.statemachine.States that a caplin.trading.statemachine.StateMachine operates on. It contains a group of related states, and the start state. As used in the trade model code, there would be a single StateModel for each protocol trade flow (e.g. ESP). The StateModel is simply a convenient place to store related states. It has two phases, configuration and use. During configuration, the various adding and setting methods should be called. During use, only the getInitialState method is expected to be called.

Constructor Summary

Attributes Name and Description
caplin.trading.statemachine.StateModel(String sModelName)

Constructs a StateModel.

Method Summary

Attributes Name and Description
void addState(caplin.trading.statemachine.State oState)

Add a state object to this group of related States.

void getAllStates()

Returns all the states contained within this StateModel.

caplin.trading.statemachine.State getInitialState()

Get the State that a StateMachine operating on this group of States should start with.

String getName()

Returns the model name that this StateModel represents.

void setInitialState(caplin.trading.statemachine.State oState)

Set the State that a StateMachine operating on this group of States should start with.

Constructor Detail

caplin.trading.statemachine.StateModel(String sModelName)

Constructs a StateModel.

Parameters
String sModelName The name the model represents.

Method Detail

void addState(caplin.trading.statemachine.State oState)

Add a state object to this group of related States. It is expected that this method will only be called during the configuration phase of the StateModel.

Parameters
caplin.trading.statemachine.State oState The state object to add to this StateModel
Throws
caplin.core.Error
if the caplin.trading.statemachine.State has already been added, or if it is not an instance of caplin.trading.statemachine.State

void getAllStates()

Returns all the states contained within this StateModel.

caplin.trading.statemachine.State getInitialState()

Get the State that a StateMachine operating on this group of States should start with.

Throws
caplin.core.Error
if the initial state has not already been set.
Returns
The initial state object of a model

String getName()

Returns the model name that this StateModel represents.

Returns
The name of the model.

void setInitialState(caplin.trading.statemachine.State oState)

Set the State that a StateMachine operating on this group of States should start with. It is expected that this will be called only once, when the StateModel is being configured.

Parameters
caplin.trading.statemachine.State oState The initial state object for a model.
Throws
caplin.core.Error
if the initial state has already been set, or the caller tries to set it to null or something that is not an instance of caplin.trading.statemachine.State.