Class Timer

java.lang.Object
com.oorian.html.Timer

public final class Timer extends Object
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 Details

    • getId

      public String getId()
      Gets the unique identifier for this timer.
      Returns:
      The timer ID.
    • isPeriodic

      public boolean isPeriodic()
      Checks if this timer executes periodically.
      Returns:
      true if this timer repeats, false if 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

      public void addListener(TimerListener listener)
      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.