Package generic.timer

Class GhidraSwinglessTimer

  • All Implemented Interfaces:
    GhidraTimer

    public class GhidraSwinglessTimer
    extends java.lang.Object
    implements GhidraTimer
    The GhidraSwinglessTimer is similar to the javax.swing.Timer class. The big difference is that it does NOT use the swing thread for its callbacks. Similar to the swing timer, only one timer thread is ever used no matter how many GhidraSwinglessTimers are instantiated. It fires one or more TimerCallbacks at specified intervals. Setting up a timer involves creating a GhidraSwinglessTimer object, registering one or more TimerCallbacks on it, and starting the timer using the start method.
    • Constructor Summary

      Constructors 
      Constructor Description
      GhidraSwinglessTimer()
      Creates a new repeating timer with a initial delay of 100ms and a continual delay of 100ms.
      GhidraSwinglessTimer​(int initialDelay, int delay, TimerCallback callback)
      Creates a new repeating timer with an initial and continual delay.
      GhidraSwinglessTimer​(int delay, TimerCallback callback)
      Creates a new repeating timer with a initial and continual delay with the given delay.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getDelay()
      Returns the delay for all callbacks after the first callback.
      int getInitialDelay()
      Returns the delay for the first callback.
      boolean isRepeats()
      Returns true if this timer is set to repeating.
      boolean isRunning()
      Returns true if the timer is running.
      static void main​(java.lang.String[] args)  
      void setDelay​(int delay)
      Sets the delay for all callbacks after the first callback
      void setInitialDelay​(int initialDelay)
      Sets the delay for the first callbacks.
      void setRepeats​(boolean repeats)
      Sets whether this timer repeats.
      void setTimerCallback​(TimerCallback callback)
      Sets the callback to be called when the timer fires.
      void start()
      Starts the timer.
      void stop()
      Stops the timer.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GhidraSwinglessTimer

        public GhidraSwinglessTimer()
        Creates a new repeating timer with a initial delay of 100ms and a continual delay of 100ms.
      • GhidraSwinglessTimer

        public GhidraSwinglessTimer​(int delay,
                                    TimerCallback callback)
        Creates a new repeating timer with a initial and continual delay with the given delay.
        Parameters:
        delay - the delay to use for the first and subsequent timer callbacks.
      • GhidraSwinglessTimer

        public GhidraSwinglessTimer​(int initialDelay,
                                    int delay,
                                    TimerCallback callback)
        Creates a new repeating timer with an initial and continual delay.
        Parameters:
        initialDelay - the delay to use for the first timer callbacks.
        delay - the delay to use for subsequent timer callbacks.
    • Method Detail

      • getDelay

        public int getDelay()
        Returns the delay for all callbacks after the first callback.
        Specified by:
        getDelay in interface GhidraTimer
        Returns:
        the delay for all callbacks after the first callback.
      • getInitialDelay

        public int getInitialDelay()
        Returns the delay for the first callback.
        Specified by:
        getInitialDelay in interface GhidraTimer
        Returns:
        the delay for the first callback.
      • isRepeats

        public boolean isRepeats()
        Returns true if this timer is set to repeating.
        Specified by:
        isRepeats in interface GhidraTimer
        Returns:
        true if this timer is set to repeating.
      • setDelay

        public void setDelay​(int delay)
        Sets the delay for all callbacks after the first callback
        Specified by:
        setDelay in interface GhidraTimer
      • setInitialDelay

        public void setInitialDelay​(int initialDelay)
        Sets the delay for the first callbacks.
        Specified by:
        setInitialDelay in interface GhidraTimer
      • setRepeats

        public void setRepeats​(boolean repeats)
        Sets whether this timer repeats.
        Specified by:
        setRepeats in interface GhidraTimer
        Parameters:
        repeats - if true, the timer will repeat, if false the timer will only fire once.
      • start

        public void start()
        Starts the timer.
        Specified by:
        start in interface GhidraTimer
      • stop

        public void stop()
        Stops the timer.
        Specified by:
        stop in interface GhidraTimer
      • isRunning

        public boolean isRunning()
        Returns true if the timer is running.
        Specified by:
        isRunning in interface GhidraTimer
      • main

        public static void main​(java.lang.String[] args)
                         throws java.lang.InterruptedException
        Throws:
        java.lang.InterruptedException