Intel

Developer Zone

TimerManager.Timer


com.intel.util
Class TimerManager.Timer

java.lang.Object
  extended by com.intel.util.TimerManager.Timer
Enclosing class:
TimerManager

public final class TimerManager.Timer
extends java.lang.Object

This class describes a single timer object and allows to start, stop and destroy the timer. The timer object can be created using the createTimer method of TimerManager. Note that after the applet finishes using a timer object, it should call the destroy method in order to release system resources used by this timer object. Since the system resources required for running a timer are shared between all running applications, it is possible that a call to the start method will fail by throwing UtilOutOfResourcesException. This means that there are no more resources available in the system for starting this timer, and the application should retry to start it at later time.


Method Summary
void destroy()
This method destroys the timer.
boolean isRunning()
This method check for timer running state.
void start(int ticks, byte[] userData, int index, int length, boolean auto)
This method starts the timer created by TimerManager.createTimer method.
void stop()
This method stops the timer.
Methods inherited from class java.lang.Object
equals, hashCode, toString

Method Detail

start

public void start(int ticks,
                  byte[] userData,
                  int index,
                  int length,
                  boolean auto)
           throws UtilException
This method starts the timer created by TimerManager.createTimer method. This method must be called on idle (stopped or new created) timer only, otherwise IllegalUseException will be thrown. Starting timer using destroyed Timer object [after Timer.destroy()] will throw NotInitializedException. Ticks value should be positive (large than zero), otherwise IllegalParameterException is thrown. User data may be 'null'.

Parameters:
ticks - number of milliseconds per timer shot
userData - byte array to be passed to TimerClient.onTimerTick method on timer expiration
index - non-negative index in the userDate buffer which indicates where userData starts
length - non-negative total length of userData
auto - auto restart on expire (periodic timer)
Throws:
UtilException - exception when general failure occurs
IllegalParameterException - exception when method parameters are illegal
NotInitializedException - exception when using Timer object after destroy() method was called
IllegalUseException - exception when trying to start already started timer.
UtilOutOfResourcesException - exception when system is out of resources

stop

public void stop()
          throws UtilException
This method stops the timer. This method can be called on running or already stopped timer, no exception will be thrown. If trying to call this method after the destroy() method was executed, will throw NotInitializedException.

Throws:
UtilException - exception when general failure occurs
NotInitializedException - exception when using Timer object after destroy() method was called

destroy

public void destroy()
             throws UtilException
This method destroys the timer. Timer may be idle (stopped) or running. The running timer will be stopped and then destroyed. This method should be called after the applet finishes using this timer object. (to free native resources) If this method called twice (or more), will throw NotInitializedException. After execution of this method, the Timer object became not-initialized and calling timer methods (start/stop/destroy) will cause NotInitializedException.

Throws:
UtilException - exception when general failure occurs
NotInitializedException - exception Timer object is already destroyed

isRunning

public boolean isRunning()
This method check for timer running state.

Returns:
true - timer is running. false - otherwise.