Use is subject to License Terms. Your use of this web site or any of its content or software indicates your agreement to be bound by these License Terms.

Copyright © 2006 Sun Microsystems, Inc. All rights reserved.

JSR-927 (Maintenance Release)

javax.tv.util
Class TVTimerSpec

java.lang.Object
  extended byjavax.tv.util.TVTimerSpec

public class TVTimerSpec
extends java.lang.Object

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

A TVTimerSpec 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 themselves 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 going off again.

For example, you could create a repeating specification that goes off every 100 milliseconds. Furthermore, imagine that it takes 5 milliseconds to notify the listeners every time it goes off. If the specification is regular, the listeners will be notified after 100 milliseconds, 200 milliseconds, 300 milliseconds, and so on. If the specification is non-regular, the listeners will be notified after 100 milliseconds, 205 milliseconds, 310 milliseconds, and so on.


Constructor Summary
TVTimerSpec()
          Creates a timer specification.
 
Method Summary
 void addTVTimerWentOffListener(TVTimerWentOffListener l)
          Registers a listener with this timer specification.
 long getTime()
          Returns the absolute or delay time when this specification will go off.
 boolean isAbsolute()
          Checks if this specification is absolute.
 boolean isRegular()
          Checks if this specification is regular.
 boolean isRepeat()
          Checks if this specification is repeating.
 void notifyListeners(TVTimer source)
          Calls all listeners registered on this timer specification.
 void removeTVTimerWentOffListener(TVTimerWentOffListener l)
          Removes a listener to this timer specification.
 void setAbsolute(boolean absolute)
          Sets this specification to be absolute or delayed.
 void setAbsoluteTime(long when)
          Sets this specification to go off at the given absolute time.
 void setDelayTime(long delay)
          Sets this specification to go off after the given delay time.
 void setRegular(boolean regular)
          Sets this specification to be regular or non-regular.
 void setRepeat(boolean repeat)
          Sets this specification to be repeating or non-repeating.
 void setTime(long time)
          Sets when this specification should go off.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TVTimerSpec

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

Method Detail

setAbsolute

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

Parameters:
absolute - Flag to indicate that this specification is either absolute or delayed. If true, the specification is absolute; otherwise, it is delayed.

isAbsolute

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

Returns:
true if this specification is absolute; false if it is delayed.

setRepeat

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

Parameters:
repeat - Flag to indicate that this specification is either repeating or non-repeating. If true, the specification is repeating; otherwise, it is non-repeating.

isRepeat

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

Returns:
true if this specification is repeating; false if it is non-repeating.

setRegular

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

Parameters:
regular - Flag to indicate that this specification is either regular or non-regular. If true, the specification is regular; otherwise, it is non-regular.

isRegular

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

Returns:
true if this specification is regular; false if it is non-regular.

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.

Parameters:
time - The time when this specification should go off.
Throws:
java.lang.IllegalArgumentException - If the specified time value is negative.

getTime

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

Returns:
The time when this specification will go off.

addTVTimerWentOffListener

public void addTVTimerWentOffListener(TVTimerWentOffListener l)
Registers a listener with this timer specification.

Parameters:
l - The listener to add.

removeTVTimerWentOffListener

public void removeTVTimerWentOffListener(TVTimerWentOffListener 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.

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.
Throws:
java.lang.IllegalArgumentException - If the specified time value is negative.

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.
Throws:
java.lang.IllegalArgumentException - If the specified time value is negative.

notifyListeners

public void notifyListeners(TVTimer source)
Calls all listeners registered on this timer specification. When this method returns, all listeners will have been notified.

This function is primarily for the benefit of those writing implementations of TVTimers.

Parameters:
source - The TVTimer that decided that this specification should go off.

JSR-927 (Maintenance Release)

Copyright © 2006 Sun Microsystems, Inc. All rights reserved. Use is subject to License Terms. Your use of this web site or any of its content or software indicates your agreement to be bound by these License Terms.

For more information, please consult the JSR 927 specification.