## com.bbn.openmap.layer.util.stateMachine
Class StateMachine

    java.lang.Object
      com.bbn.openmap.layer.util.stateMachine.StateMachine

Direct Known Subclasses:
  EOMGStateMachine

public class StateMachine
extends java.lang.Object

The StateMachine lets you organize event handling, if the order of the events are important to you. You can use the setState commands with the state you want, if you are holding on a copy of it. Otherwise, the state machine assumes you know the index of the state you want.

Field Summary
`protected State` `currentState` The current state that will receive the next event.
`protected State` `resetState` The state to go to whan all is bad.
`protected java.util.Vector` `states` The states to track.

Constructor Summary
`StateMachine()`
`StateMachine(State[] s)` Define the state machine using the array of states.

Method Summary
`void` `addStates(State[] s)` Append States to the state Vector.
`State` `getResetState()` Return the reset state.
`State` `getState()` Return the current State.
`State` `getState(int stateIndex)` Return the state at the given index.
`java.util.Vector` `getStates()` Get the Vector of States.
`void` `reset()` Sets the current state to the reset state.
`void` `setMapMouseListenerResponses(boolean value)` Set the MapMouseListenerResponse for all the states.
`void` `setResetState(int stateIndex)` Set the reset state to be used by the state machine.
`void` `setResetState(State state)` Set the state to be gone to if the state machine is reset.
`void` `setState(int stateIndex)` Set the current state to the state residing in the vector at the given index.
`void` `setState(State state)` Set the current state to the given state.
`void` `setStateAt(int stateIndex, State state)` Set the state at an index to new State Object.
`void` `setStates(State[] s)` Set the states to the new array.
`void` `setStates(java.util.Vector s)` Set the states to the vector of States.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### states

    protected java.util.Vector states

  The states to track.

### currentState

    protected State currentState

  The current state that will receive the next event.

### resetState

    protected State resetState

  The state to go to whan all is bad.

Constructor Detail

### StateMachine

    public StateMachine()

### StateMachine

    public StateMachine(State[] s)

  Define the state machine using the array of states. Order is maintained.

Parameters:
  `s` - array of states.

Method Detail

### reset

    public void reset()

  Sets the current state to the reset state.

### setStates

    public void setStates(State[] s)

  Set the states to the new array.

  Parameters:
    `s` - array of states.

### setStates

    public void setStates(java.util.Vector s)

  Set the states to the vector of States.

  Parameters:
    `s` -

### getStates

    public java.util.Vector getStates()

  Get the Vector of States.

  Returns:
    Vector

### addStates

    public void addStates(State[] s)

  Append States to the state Vector.

  Parameters:
    `s` - an Array of States.

### setState

    public void setState(State state)

  Set the current state to the given state. If the state is not in the state machine, then the state is added to the end to the state vector.

  Parameters:
    `state` - the state to set to the current one.

### setState

    public void setState(int stateIndex)

  Set the current state to the state residing in the vector at the given index. If the index is larger than the number of states in the machine, the statemachine is reset.

  Parameters:
    `stateIndex` - the index of the current state.

### setStateAt

    public void setStateAt(int stateIndex,
                           State state)

  Set the state at an index to new State Object. If the index isn't currently being used, the StateMachine is reset.

  Parameters:
    `stateIndex` -
    `state` -

### getState

    public State getState()

  Return the current State.

### getState

    public State getState(int stateIndex)

  Return the state at the given index. If the index is larger that the number of states, null is returned.

### setResetState

    public void setResetState(State state)

  Set the state to be gone to if the state machine is reset. If the state does not exist in the state machine already, it will be added to the end of the state vector.

### setResetState

    public void setResetState(int stateIndex)

  Set the reset state to be used by the state machine. If a bad integer value is given, the first state in the state vector is made the reset state.

### getResetState

    public State getResetState()

  Return the reset state.

### setMapMouseListenerResponses

    public void setMapMouseListenerResponses(boolean value)

  Set the MapMouseListenerResponse for all the states.

Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details