All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.sun.util.PTimerSpec

java.lang.Object
   |
   +----com.sun.util.PTimerSpec

public class PTimerSpec
extends Object

A class representing a timer specification. A timer specification declares when a PTimerWentOffEvent should be sent. These events are sent to the listeners registered on the specification.

PTimer specifications may be absolute or delayed. Absolute specifications go off at the specified time. Delayed specifications go off after waiting the specified amount of time.

Delayed specifications may be repeating or non-repeating. Repeating specifications automatically reschedule theselves after going off.

Repeating specifications may be regular or non-regular. Regular specifications attempt to go off at fixed intervals of time, irrespective of system load or how long it takes to notify the listeners. Non-regular specifications wait the specified amount of time after all listeners have been called before firing again.

For example, create a repeating specification going off every 100ms. Imagine that it takes 5ms to notify the listeners. If the specification is regular, the listeners will be notified after 100ms, 200ms, 300ms, and so on. If the specification is non-regular, the listeners will be notified after 100ms, 205ms, 310ms, and so on.


Variable Index

 o listeners

Constructor Index

 o PTimerSpec()
Creates a timer specification.

Method Index

 o addPTimerWentOffListener(PTimerWentOffListener)
Adds a listener to this timer specification.
 o getTime()
Returns the absolute or delay time when this specification will go off.
 o isAbsolute()
Checks if this specification is absolute.
 o isRegular()
Checks if this specification is regular
 o isRepeat()
Checks if this specification is repeating
 o notifyListeners(PTimer)
Calls all listeners registered on this timer specification.
 o removePTimerWentOffListener(PTimerWentOffListener)
Removes a listener to this timer specification.
 o setAbsolute(boolean)
Sets this specification to be absolute or delayed.
 o setAbsoluteTime(long)
Sets this specification to go off at the given absolute time.
 o setDelayTime(long)
Sets this specification to go off after the given delay time.
 o setRegular(boolean)
Sets this specification to be regular or non-regular
 o setRepeat(boolean)
Sets this specification to be repeating or non-repeating
 o setTime(long)
Sets when this specification should go off.

Variables

 o listeners
 protected Object listeners

Constructors

 o PTimerSpec
 public PTimerSpec()
Creates a timer specification. It initially is absolute, non-repeating, regular specification set to go off at time 0.

Methods

 o setAbsolute
 public void setAbsolute(boolean absolute)
Sets this specification to be absolute or delayed.

 o isAbsolute
 public boolean isAbsolute()
Checks if this specification is absolute.

 o setRepeat
 public void setRepeat(boolean repeat)
Sets this specification to be repeating or non-repeating

 o isRepeat
 public boolean isRepeat()
Checks if this specification is repeating

 o setRegular
 public void setRegular(boolean regular)
Sets this specification to be regular or non-regular

 o isRegular
 public boolean isRegular()
Checks if this specification is regular

 o setTime
 public void setTime(long time)
Sets when this specification should go off. For absolute specifications, this is a time in milliseconds since midnight, January 1, 1970 UTC. For delayed specifications, this is a delay time in milliseconds.

 o getTime
 public long getTime()
Returns the absolute or delay time when this specification will go off.

 o addPTimerWentOffListener
 public void addPTimerWentOffListener(PTimerWentOffListener l)
Adds a listener to this timer specification.

Parameters:
l - the listener to add
 o removePTimerWentOffListener
 public void removePTimerWentOffListener(PTimerWentOffListener l)
Removes a listener to this timer specification. Silently does nothing if the listener was not listening on this specification.

Parameters:
l - the listener to remove
 o setAbsoluteTime
 public void setAbsoluteTime(long when)
Sets this specification to go off at the given absolute time. This is a convenience function equivalent to setAbsolute(true), setTime(when), setRepeat(false).

Parameters:
when - the absolute time for the specification to go off
 o setDelayTime
 public void setDelayTime(long delay)
Sets this specification to go off after the given delay time. This is a convenience function equivalent to setAbsolute(false), setTime(delay), setRepeat(false).

Parameters:
delay - the relative time for the specification to go off
 o notifyListeners
 public void notifyListeners(PTimer source)
Calls all listeners registered on this timer specification. This function is primarily for the benefit of those writing implementations of PTimers.

Parameters:
source - the PTimer that decided that this specification should go off

All Packages  Class Hierarchy  This Package  Previous  Next  Index