Copyright 2011-01-06 Werner Randelshofer

ch.randelshofer.util
Class StateTracker

java.lang.Object
  extended by ch.randelshofer.util.StateTracker
All Implemented Interfaces:
StateListener, java.util.EventListener

public class StateTracker
extends java.lang.Object
implements StateListener

Tracks state changes in a StateModel.

Version:
1.0.1 2005-06-19 Method waitForState sometimes waited forever.
1.0 1999-10-19
Author:
Werner Randelshofer, Hausmatt 10, CH-6405 Immensee, Switzerland

Constructor Summary
StateTracker(StateModel model)
          Creates a StateTracker for the indicated StateModel.
 
Method Summary
 void setStateModel(StateModel model)
          Sets the StateModel.
 void stateChanged(StateEvent event)
          XXX This method is public as an implementation side effect.
 void waitForState(int state)
          Waits until the StateModel reaches the indicated state.
 int waitForState(int[] states)
          Waits until the StateModel reaches one of the indicated states.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StateTracker

public StateTracker(StateModel model)
Creates a StateTracker for the indicated StateModel.

Parameters:
model - The model to be tracked.
Method Detail

setStateModel

public void setStateModel(StateModel model)
Sets the StateModel. Note: This method must not be called while one of the waitForState methods is working.

Parameters:
model - StateModel to be tracked.

waitForState

public void waitForState(int state)
Waits until the StateModel reaches the indicated state. Note: waitForState methods may not be called from multiple threads simoultaneously.

Parameters:
state - to wait for.

waitForState

public int waitForState(int[] states)
Waits until the StateModel reaches one of the indicated states. Note: waitForState methods may not be called from multiple threads simoultaneously.

Parameters:
states - choice of states to wait for.

stateChanged

public void stateChanged(StateEvent event)
XXX This method is public as an implementation side effect. " Do not call or override.

Specified by:
stateChanged in interface StateListener

Copyright 2011-01-06 Werner Randelshofer