com.ihr.xbrl.util

## Class Timer

- java.lang.Object
- - com.ihr.xbrl.util.Timer

- All Implemented Interfaces:
    java.io.Serializable, java.lang.Runnable

      public class Timer
      extends java.lang.Object
      implements java.lang.Runnable, java.io.Serializable

  A Timer will invoke a method in another class at regular intervals of time indicated by the timer.

  The timer (and the calls to the method) will be running in another thread that is not the application thread.

  Author:
    Ignacio
  See Also:
    Serialized Form

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static interface` | `Timer.TimerTick` This is the interface that must be implemented by classes that will receive events at the intervals indicated by the Timer class when the timer is running.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Timer(Timer.TimerTick target, long waitTime, float position, boolean bInSeparateThread)` Creates a Timer that will be in not running status until `start()` is called.
    `Timer(Timer.TimerTick target, long waitTime1, long waitTime2, java.lang.String timerName, boolean bInSeparateThread)` Creates a Timer that will be in not running status until `start()` is called.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `isRunning()` Checks if is running.
    `void` | `processEvents(boolean value)` Under normal operations, a Timer always process timing events.
    `void` | `run()`
    `void` | `start()` Starts the execution of the timer.
    `void` | `stop()` Stops the timer exection.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Timer

          public Timer(Timer.TimerTick target,
               long waitTime,
               float position,
               boolean bInSeparateThread)

      Creates a Timer that will be in not running status until `start()` is called.
      Parameters:
        `target` - the instance of the class implementing the TimerTick interface.
        `waitTime` - the duration of the wait interval
        `position` - the relative position in the wait interval when the timerEvent method will be called. This is a number between 0 and 1. If 0, the initial time does not exists. When the timer is started, the timerEvent will be immediately called. if it is 1, the initial time must completely pass until the timerEvent is called for the first time
        `bInSeparateThread` - if this is true, timerEvent will be called in a separate thread. If this is false, timerEvent will be called in the same thread the timer is running

    - #### Timer

          public Timer(Timer.TimerTick target,
               long waitTime1,
               long waitTime2,
               java.lang.String timerName,
               boolean bInSeparateThread)

      Creates a Timer that will be in not running status until `start()` is called.
      Parameters:
        `target` - the instance of the class implementing the TimerTick interface.
        `waitTime1` - the duration of the wait interval from the moment the timer is started till the moment the timerEvent is called.
        `waitTime2` - the duration of the wait interval from the moment the timerEvent is called till the next execution is restarted.
        `timerName` - this is the name assigned to the timer thread.
        `bInSeparateThread` - if this is true, timerEvent will be called in a separate thread. If this is false, timerEvent will be called in the same thread the timer is running

  - ### Method Detail

    - #### run

          public void run()

      Specified by:
        `run` in interface `java.lang.Runnable`

    - #### start

          public void start()
                     throws java.lang.IllegalThreadStateException

      Starts the execution of the timer.
      Throws:
        `java.lang.IllegalThreadStateException` - the illegal thread state exception

    - #### stop

          public void stop()

      Stops the timer exection.

    - #### isRunning

          public boolean isRunning()

      Checks if is running.
      Returns:
        true if the timer is running, false if it is stopped

    - #### processEvents

          public void processEvents(boolean value)

      Under normal operations, a Timer always process timing events. this method sets a flag that allows the timer to produce ticks but ignore the ticks (by not calling the callback function on the target class).
      Parameters:
        `value` - the value