org.opendoors.util
Class Timer

java.lang.Object
  |
  +--java.util.Observable
        |
        +--org.opendoors.util.Timer
All Implemented Interfaces:
java.lang.Runnable, java.io.Serializable

public class Timer
extends java.util.Observable
implements java.lang.Runnable, java.io.Serializable

This class provides timer and supporting events to client objects by extending the Observable base class. Clients get notifications of changes in the clock.

The interval for firing changes to observers is resetable in the event the observer needs more frequent updates of changes.

The instance may be a one shot timer as well as a recurring timers. This supports a one shot notification in the future.

Observable is thread-safe and supports multiple listeners to a single observable such as an observable which fires every 24 hours.

See Also:
Serialized Form

Constructor Summary
Timer()
          Public constructor to create a timer event source using factory defaults which are 1 second timer, recurring.
Timer(java.lang.String name, int period, boolean oneShot)
          Construct a timer with the certain properties set.
 
Method Summary
 java.lang.String getName()
          Gets the name of the timer.
 int getPeriod()
          Gets the period between timer events.
 boolean isOneShot()
          Interrogates if this is a one-shot operation.
 void run()
          Run the timer.
 void setName(java.lang.String n)
          Sets the name of the timer.
 void setOneShot(boolean os)
          Set this object to be one-shot or not.
 void setPeriod(int p)
          Sets the period in milliseconds.
 void stop()
          Stop the timer
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Timer

public Timer()
Public constructor to create a timer event source using factory defaults which are 1 second timer, recurring.

Timer

public Timer(java.lang.String name,
             int period,
             boolean oneShot)
Construct a timer with the certain properties set.
Parameters:
The - name of the timer.
The - period in milliseconds.
True - if this is a oneShot instance
Method Detail

stop

public void stop()
Stop the timer

getName

public java.lang.String getName()
Gets the name of the timer.
Returns:
The timer name.

setName

public void setName(java.lang.String n)
Sets the name of the timer.
Parameters:
The - textual name.

getPeriod

public int getPeriod()
Gets the period between timer events.
Returns:
The interval in milliseconds

setPeriod

public void setPeriod(int p)
Sets the period in milliseconds.
Parameters:
The - interval.

isOneShot

public boolean isOneShot()
Interrogates if this is a one-shot operation.
Returns:
True, if a one-shot operation.

setOneShot

public void setOneShot(boolean os)
Set this object to be one-shot or not.
Parameters:
True, - if one-shot operation desired

run

public void run()
Run the timer.
Specified by:
run in interface java.lang.Runnable