jmce - 1_02

jmce.util
Class Timer

java.lang.Object
  extended by jmce.util.Timer

public class Timer
extends java.lang.Object

Asyncronous timer.

Every timer require a TimerManager to manage the timer queue.

Static method are provided to access a standard TimerManager for milliseconds based Timer.

Version:
1.01
Author:
Mario Viara
See Also:
TimerManager

Field Summary
static int CANCELLED
           
static int IDLE
           
static int QUEUED
           
static int READY
           
 
Constructor Summary
Timer(int time, boolean repeat, TimerListener run)
          Standard constructor.
Timer(int time, TimerListener run)
          Constructor without the repeat flag.
 
Method Summary
static void addTimer(Timer timer)
          Add the timer to the standard TimerManager
 void cancel()
          Cancel the timer.
static Timer createTimer(int time, boolean repeat, TimerListener run)
          Create a timer and add it to the standard milliseconds based TimerManager
static Timer createTimer(int time, TimerListener run)
          Create a timer and add it to the standard TimerManager
 int getStatus()
          Return the status of the timer
 long getTime()
          Return the time
 boolean isRepeat()
          Return the repeart flag.
 boolean isRunning()
          Return true if the timer is active
static void main(java.lang.String[] argv)
          Main method for simple test
 void setRepeat(boolean mode)
          Set the repeat flag
 void setTime(int t)
          Set the time
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

IDLE

public static final int IDLE
See Also:
Constant Field Values

QUEUED

public static final int QUEUED
See Also:
Constant Field Values

READY

public static final int READY
See Also:
Constant Field Values

CANCELLED

public static final int CANCELLED
See Also:
Constant Field Values
Constructor Detail

Timer

public Timer(int time,
             boolean repeat,
             TimerListener run)
Standard constructor.

Create a new time with specified time and repeat.

Parameters:
time - - Time when it will expire.
repeat - - True if the timer must be repeated
run - - Listener to be called.

Timer

public Timer(int time,
             TimerListener run)
Constructor without the repeat flag.

Method Detail

isRunning

public boolean isRunning()
Return true if the timer is active


isRepeat

public final boolean isRepeat()
Return the repeart flag.


setRepeat

public void setRepeat(boolean mode)
Set the repeat flag


getTime

public long getTime()
Return the time


setTime

public void setTime(int t)
Set the time


cancel

public final void cancel()
Cancel the timer.

Remove the timer from the TimerManager if queude else do nothing.


getStatus

public final int getStatus()
Return the status of the timer


addTimer

public static void addTimer(Timer timer)
Add the timer to the standard TimerManager


createTimer

public static Timer createTimer(int time,
                                boolean repeat,
                                TimerListener run)
Create a timer and add it to the standard milliseconds based TimerManager


createTimer

public static Timer createTimer(int time,
                                TimerListener run)
Create a timer and add it to the standard TimerManager


main

public static void main(java.lang.String[] argv)
Main method for simple test


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

jmce - 1_02