Package com.oorian.html
Class Timer
java.lang.Object
com.oorian.html.Timer
Represents a client-side timer that can execute code at specified intervals.
Timers can be either one-shot (execute once after a delay) or periodic (execute repeatedly). This class manages timer state and notifies registered listeners when the timer expires.
Timers are associated with an HtmlPage and communicate with the client browser through the messaging command system. Listeners are held as weak references to prevent memory leaks.
- Since:
- 1.0
- Version:
- 1.0
- Author:
- Marvin P. Warble Jr.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(TimerListener listener) Adds a listener to be notified when this timer expires.getId()Gets the unique identifier for this timer.intGets the interval between timer executions.booleanChecks if this timer executes periodically.voidstart()Starts the timer by sending a CreateTimer command to the client.voidstop()Stops the timer.
-
Method Details
-
getId
Gets the unique identifier for this timer.- Returns:
- The timer ID.
-
isPeriodic
public boolean isPeriodic()Checks if this timer executes periodically.- Returns:
trueif this timer repeats,falseif it is a one-shot timer.
-
getInterval
public int getInterval()Gets the interval between timer executions.- Returns:
- The interval in milliseconds.
-
start
public void start()Starts the timer by sending a CreateTimer command to the client.The timer will begin counting down and notify listeners when it expires.
-
stop
public void stop()Stops the timer.Note: Currently not implemented.
-
addListener
Adds a listener to be notified when this timer expires.The listener is held as a weak reference to prevent memory leaks.
- Parameters:
listener- The TimerListener to add.
-