Class Timer
public class Timer
{
// Constructors
public Timer(long p);
public Timer(long p, int id);
public Timer(long p, boolean r);
public Timer(long p, int id, boolean r);
public Timer(TimerListener defaultListener, long p);
public Timer(TimerListener defaultListener, long p, int id);
public Timer(TimerListener defaultListener, long p, boolean r);
public Timer(TimerListener defaultListener, long p, int id,
boolean r);
public Timer(TaskManager tm, long p);
public Timer(TaskManager tm, long p, int id);
public Timer(TaskManager tm, long p, boolean r);
public Timer(TaskManager tm, long p, int id, boolean r);
public Timer(TaskManager tm, TimerListener defaultListener,
long p);
public Timer(TaskManager tm, TimerListener defaultListener,
long p, int id);
public Timer(TaskManager tm, TimerListener defaultListener,
long p, boolean r);
public Timer(TaskManager tm, TimerListener defaultListener,
long p, int id, boolean r);
// Methods
public void addTimerListener(TimerListener listener);
public long getPeriod();
public boolean getRepeat();
public int getUserID();
public boolean isRunning();
public void removeTimerListener(TimerListener listener);
public void start();
public void stop();
}
This class implements a timer event source.
public Timer(long p);
Constructs a one-shot timer with the specified period (in milliseconds).
Parameter | Description |
p
| The initial period of the timer.
|
public Timer(long p, int id);
Constructs a one-shot timer with a specific period (in milliseconds) and that includes a user-defined identifier.
Parameter | Description |
p
| The initial period of the timer.
|
id
| The user-defined identifier of the timer.
|
public Timer(long p, boolean r);
Constructs a one-shot or repeating timer with the specified period (in milliseconds).
Parameter | Description |
p
| The initial period of the timer.
|
r
| Set to true if the timer is a repeating timer or false if it is a one-shot timer.
|
public Timer(long p, int id, boolean r);
Constructs a one-shot or repeating timer with the specified period (in milliseconds).
Parameter | Description |
p
| The initial period of the timer.
|
id
| The user-defined identifier for the timer.
|
r
| Set to true if the timer is a repeating timer; set to false if it is a one-shot timer.
|
public Timer(TimerListener defaultListener, long p);
Constructs a one-shot timer with the specified period (in milliseconds) and that includes a default listener.
Parameter | Description |
defaultListener
| The initial listener to add to the timer.
|
p
| The initial period of the timer.
|
public Timer(TimerListener defaultListener, long p, int id);
Constructs a one-shot timer with the specified period (in milliseconds) and listener.
Parameter | Description |
defaultListener
| The initial listener to add to the timer.
|
p
| The initial period of the timer.
|
id
| The user-defined identifier of the timer.
|
public Timer(TimerListener defaultListener, long p, boolean r);
Constructs a one-shot or repeating timer with the specified period (in milliseconds) and that includes a default listener.
Parameter | Description |
defaultListener
| The initial listener to add to the timer.
|
p
| The initial period of the timer.
|
r
| Set to true if the timer is a repeating timer; set to false if it is a one-shot timer.
|
public Timer(TimerListener defaultListener, long p, int id, boolean r);
Constructs a one-shot or repeating timer with the specified period (in milliseconds) and a default listener.
Parameter | Description |
defaultListener
| An initial listener to add to the timer.
|
id
| A user-defined identifier for the listener.
|
p
| The initial period of the timer.
|
r
| Set to true if the timer is a repeating timer; set to false if it is a one-shot timer.
|
public Timer(TaskManager tm, long p);
Constructs a one-shot timer with the specified period.
Parameter | Description |
tm
| The TaskManager that is to service this Timer.
|
p
| The initial period of the timer (in milliseconds).
|
public Timer(TaskManager tm, long p, int id);
Constructs a one-shot timer with a specific period and that includes a user-defined identifier.
Parameter | Description |
tm
| The TaskManager that is to service this Timer.
|
p
| The initial period of the timer (in milliseconds).
|
id
| The user-defined identifier of the timer.
|
public Timer(TaskManager tm, long p, boolean r);
Constructs a one-shot or repeating timer with the specified period.
Parameter | Description |
tm
| The task manager that is to service this timer.
|
p
| The initial period of the timer (in milliseconds).
|
r
| Set to true if the timer is a repeating timer or false if it is a one-shot timer.
|
public Timer(TaskManager tm, long p, int id, boolean r);
Constructs a one-shot or repeating timer with the specified period.
Parameter | Description |
tm
| The task manager that is to service this timer.
|
p
| The initial period of the timer (in milliseconds).
|
id
| The user-defined identifier for the timer.
|
r
| Set to true if the timer is a repeating timer; set to false if it is a one-shot timer.
|
public Timer(TaskManager tm, TimerListener defaultListener, long p);
Constructs a one-shot timer with the specified period and that includes a default listener.
Parameter | Description |
tm
| The task manager that is to service this timer.
|
defaultListener
| The initial listener to add to the timer.
|
p
| The initial period of the timer.
|
public Timer(TaskManager tm, TimerListener defaultListener, long p, int id);
Constructs a one-shot timer with the specified period and listener.
Parameter | Description |
tm
| The task manager that is to service this timer.
|
defaultListener
| The initial listener to add to the timer.
|
p
| The initial period of the timer.
|
id
| The user-defined identifier of the timer.
|
public Timer(TaskManager tm, TimerListener defaultListener, long p, boolean
r);
Constructs a one-shot or repeating timer with the specified period and that includes a default listener.
Parameter | Description |
tm
| The task manager that is to service this timer.
|
defaultListener
| The initial listener to add to the timer.
|
p
| The initial period of the timer.
|
r
| Set to true if the timer is a repeating timer; set to false if it is a one-shot timer.
|
public Timer(TaskManager tm, TimerListener defaultListener, long p, int id,
boolean r);
Constructs a one-shot or repeating timer with the specified period and a default listener.
Parameter | Description |
tm
| The task manager that is to service this timer.
|
defaultListener
| An initial listener to add to the timer.
|
id
| A user-defined identifier for the listener.
|
p
| The initial period of the timer.
|
r
| Set to true if the timer is a repeating timer; set to false if it is a one-shot timer.
|
public void addTimerListener(TimerListener listener);
Adds a listener to the timer.
Return Value:
No return value.
Parameter | Description |
listener
| The listener that is added to the timer.
|
public long getPeriod();
Retrieves the timer period.
Return Value:
Returns the number of milliseconds that must elapse before the timer fires.
public boolean getRepeat();
Retrieves the timer repeat flag.
Return Value:
Returns true if the timer is a repeating timer; otherwise, returns false.
public int getUserID();
Retrieves the timer's user-defined identifier.
Return Value:
Returns the integer identifier of the timer.
public boolean isRunning();
Queries the Timer to see if it is running.
Return Value:
Returns true if the timer is running; otherwise, returns false.
public void removeTimerListener(TimerListener listener);
Removes a listener from the timer.
Return Value:
No return value.
Parameter | Description |
listener
| The listener that is removed.
|
Remarks:
This method prevents future listener timer events from being generated. However, timer events that have already been generated can be delivered to listeners.
public void start();
Starts the timer. If the timer is already running, calls to this method are ignored.
Return Value:
No return value.
public void stop();
Stops the timer. If the timer is not running, calls to this method are ignored.
Return Value:
No return value.
Remarks:
This method prevents future listener timer events from being generated. However, timer events that have already been generated can be delivered to listeners.