jegg.timer
Class Timer

java.lang.Object
  extended byjegg.timer.Timer

public final class Timer
extends java.lang.Object

A timer that can be used to periodically deliver timeout messages to a listener.


Method Summary
 void cancel()
          Stop the timer.
static Timer createRepeatingTimer(TimeoutListener l, long period)
          Create a timer that will deliver timeout messages periodically.
static Timer createRepeatingTimer(TimeoutListener l, long period, long delay)
          Create a timer that will deliver timeout messages periodically following the initial specified delay.
static Timer createSingleShotTimer(TimeoutListener l, long delay)
          Create a timer that will deliver a single timeout message.
 long getDelay()
          Return the initial delay before the timeouts start.
 long getInterval()
          Return the delivery period of this timer, which is the number of milliseconds between timeouts.
 boolean isRepeating()
          Return whether or not this timer will deliver multiple timeouts or just a single timeout.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createRepeatingTimer

public static final Timer createRepeatingTimer(TimeoutListener l,
                                               long period)
Create a timer that will deliver timeout messages periodically.

Parameters:
l - the listener for the timeout messages.
period - the interval, in milliseconds, between timeout messages.
Returns:
new timer.

createRepeatingTimer

public static final Timer createRepeatingTimer(TimeoutListener l,
                                               long period,
                                               long delay)
Create a timer that will deliver timeout messages periodically following the initial specified delay.

Parameters:
l - the listener for the timeout messages.
period - the interval, in milliseconds, between timeout messages.
delay - the initial delay before the first timeout message is delivered to the listener.
Returns:
new timer.

createSingleShotTimer

public static final Timer createSingleShotTimer(TimeoutListener l,
                                                long delay)
Create a timer that will deliver a single timeout message.

Parameters:
l - the listener for the timeout message.
delay - the number of milliseconds to wait before the timeout message is sent.
Returns:
new timer.

getInterval

public final long getInterval()
Return the delivery period of this timer, which is the number of milliseconds between timeouts.

Returns:
number of milliseconds between timeouts.

getDelay

public final long getDelay()
Return the initial delay before the timeouts start.

Returns:
number of milliseconds to wait before sending the first timeout.

isRepeating

public final boolean isRepeating()
Return whether or not this timer will deliver multiple timeouts or just a single timeout.

Returns:
true if the timer will deliver multiple timeouts.

cancel

public final void cancel()
Stop the timer.



Copyright © 2004 . All Rights Reserved.