ariba.util.core
Class Timer

java.lang.Object
  extended by ariba.util.core.Timer
All Implemented Interfaces:
EventProcessor

public class Timer
extends java.lang.Object
implements EventProcessor

Object subclass that causes an action to occur at a predefined rate. For example, an animation object can use a Timer as the trigger for drawing its next frame. Each Timer has a Target that receives a performCommand() message; the command the Timer sends to its Target; and a delay (the time between performCommand() calls). When delay milliseconds have passed, a Timer sends the performCommand() message to its Target, passing as parameters the command and the object set using the Timer's setData() method. This cycle repeats until stop() is called, or halts immediately if the Timer is configured to send its message just once.

Using a Timer involves first creating it, then starting it using the start() method.

See Also:
Target
Note:
1.0 changes to detect and stop dealocking better, 1.0 calling setDelay() on already running Timer works correctly, 1.1 Timer will get the TimerQueue from the most proper application

Constructor Summary
Timer(EventLoop eventLoop, Target target, java.lang.String command, int delay)
          Constructs a Timer associated with the EventLoop eventLoop that sends performCommand() to target every delay milliseconds.
 
Method Summary
 java.lang.String getCommand()
          Returns the command the Timer sends to its target in the performCommand() message.
 java.lang.Object getData()
          Returns the Timer's data.
 int getDelay()
          Returns the Timer's delay.
 EventLoop getEventLoop()
          Returns the EventLoop associated with this Timer.
 int getInitialDelay()
          Returns the Timer's initial delay.
 boolean getRepeats()
          Returns true if the Timer will send a performCommand() message to its target multiple times.
 Target getTarget()
          Returns the Target that will receive performCommand() messages from the Timer.
 boolean isRunning()
          Returns true if the Timer is running.
 void processEvent()
          EventProcessor interface method implemented to perform the Timer's event processing behavior, which is to send the performCommand() message to its Target.
 void setCommand(java.lang.String command)
          Sets the command the Timer sends to its target in the performCommand() method.
 void setData(java.lang.Object data)
          Sets the Timer's data.
 void setDelay(int delay)
          Sets the Timer's delay, the number of milliseconds between successive performCommand() messages to its Target.
 void setInitialDelay(int initialDelay)
          Sets the Timer's initial delay.
 void setRepeats(boolean flag)
          If flag is false, instructs the Timer to send a performCommand() message to its Target only once, and then stop.
 void setTarget(Target target)
          Sets the Target that will receive performCommand() messages from the Timer.
 void start()
          Starts the Timer, causing it to send performCommand() messages to its Target.
 void stop()
          Stops a Timer, causing it to stop sending performCommand() messages to its Target.
 java.lang.String toString()
          Returns the Timer's string representation.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Timer

public Timer(EventLoop eventLoop,
             Target target,
             java.lang.String command,
             int delay)
Constructs a Timer associated with the EventLoop eventLoop that sends performCommand() to target every delay milliseconds. You only call this constructor if you need to associate a Timer with an EventLoop other than the application's EventLoop.

Method Detail

getEventLoop

public EventLoop getEventLoop()
Returns the EventLoop associated with this Timer.


setTarget

public void setTarget(Target target)
Sets the Target that will receive performCommand() messages from the Timer.


getTarget

public Target getTarget()
Returns the Target that will receive performCommand() messages from the Timer.

See Also:
setTarget(ariba.util.core.Target)

setCommand

public void setCommand(java.lang.String command)
Sets the command the Timer sends to its target in the performCommand() method.

See Also:
setTarget(ariba.util.core.Target)

getCommand

public java.lang.String getCommand()
Returns the command the Timer sends to its target in the performCommand() message.

See Also:
setCommand(java.lang.String)

setDelay

public void setDelay(int delay)
Sets the Timer's delay, the number of milliseconds between successive performCommand() messages to its Target.

See Also:
setTarget(ariba.util.core.Target), setInitialDelay(int)

getDelay

public int getDelay()
Returns the Timer's delay.

See Also:
setDelay(int)

setData

public void setData(java.lang.Object data)
Sets the Timer's data.


getData

public java.lang.Object getData()
Returns the Timer's data.


setInitialDelay

public void setInitialDelay(int initialDelay)
Sets the Timer's initial delay. This is the number of milliseconds the Timer will wait before sending its first performCommand() message to its Target. This setting has no effect if the Timer is already running.

See Also:
setTarget(ariba.util.core.Target), setDelay(int)

getInitialDelay

public int getInitialDelay()
Returns the Timer's initial delay.

See Also:
setDelay(int)

setRepeats

public void setRepeats(boolean flag)
If flag is false, instructs the Timer to send a performCommand() message to its Target only once, and then stop.


getRepeats

public boolean getRepeats()
Returns true if the Timer will send a performCommand() message to its target multiple times.

See Also:
setRepeats(boolean)

start

public void start()
Starts the Timer, causing it to send performCommand() messages to its Target.

See Also:
stop()

isRunning

public boolean isRunning()
Returns true if the Timer is running.

See Also:
start()

stop

public void stop()
Stops a Timer, causing it to stop sending performCommand() messages to its Target.

See Also:
start()

processEvent

public void processEvent()
EventProcessor interface method implemented to perform the Timer's event processing behavior, which is to send the performCommand() message to its Target. You never call this method.

Specified by:
processEvent in interface EventProcessor
See Also:
EventProcessor

toString

public java.lang.String toString()
Returns the Timer's string representation.

Overrides:
toString in class java.lang.Object


AribaWeb User Interface Development Framework
Copyright © 2000-2014 Ariba, Inc. All Rights Reserved.