WebObjects 5.2.3

com.webobjects.appserver
Class WOTimer

java.lang.Object
  extended bycom.webobjects.appserver.WOTimer

public class WOTimer
extends Object

WOTimer creates timer objects, or more simply, timers. A timer waits until its fireDate is reached and then fires, sending a specified message to a specified object. If you specify that the timer should repeat, it automatically reschedules itself after it fires.

The static method scheduledTimer creates and schedules a timer. The constructors create timers which can later be scheduled by invoking the method schedule. Timers can be unscheduled by invoking invalidate on the timer to be unscheduled.

See Also:
fireDate(), invalidate(), schedule(), scheduledTimer(long ti, Object aTarget, String aSelectorName, Object userInfo, boolean repeats), scheduledTimer(long ti, Object aTarget, String aSelectorName, Object anArgument, Class anArgumentClass, boolean repeats)

Constructor Summary
WOTimer(long ti, Object aTarget, String aSelectorName, Object userInfo, Class userInfoClass, boolean repeats)
          Creates a timer which will fire after ti milliseconds, and at intervals ti thereafter (if repeats is true).
WOTimer(NSTimestamp fireDate, long ti, Object aTarget, String aSelectorName, Object userInfo, Class userInfoClass, boolean repeats)
          Creates a timer which will fire at fireDate, and at intervals ti thereafter (if repeats is true).
 
Method Summary
 boolean equals(Object aTimer)
          Return true if aTimer is an instance of WOTimer with the same selector, target, and userInfo as the receiver.
 void fire()
          Fires the timer, invoking selector on target and passing either the WOTimer -- if userInfoClass was null when the WOTimer was created -- or userInfo.
 NSTimestamp fireDate()
          Return the NSTimestamp at which the WOTimer will first fire.
 int hashCode()
           
 void invalidate()
          Unschedules the timer and marks it as invalid.
 boolean isValid()
          Returns whether or not the timer is valid.
 void schedule()
          Schedule the WOTimer to be fired.
static WOTimer scheduledTimer(long ti, Object aTarget, String aSelectorName, Object userInfo, boolean repeats)
          Creates a timer which will fire after ti milliseconds, and at intervals ti thereafter (if repeats is true).
static WOTimer scheduledTimer(long ti, Object aTarget, String aSelectorName, Object anArgument, Class anArgumentClass, boolean repeats)
          Creates a timer which will fire after ti milliseconds, and at intervals ti thereafter (if repeats is true).
 NSSelector selector()
          Returns the NSSelector which will be invoked when the WOTimer fires.
 Object target()
          Returns the object on which selector will be invoked when the WOTimer fires.
 double timeInterval()
          Return the interval in seconds at which the WOTimer will repeat firing.
 String toString()
           
 Object userInfo()
          Returns the userInfo object that was passed when the timer was created.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WOTimer

public WOTimer(long ti,
               Object aTarget,
               String aSelectorName,
               Object userInfo,
               Class userInfoClass,
               boolean repeats)
Creates a timer which will fire after ti milliseconds, and at intervals ti thereafter (if repeats is true).

If userInfoClass is null, aSelectorName must take an object of class WOTimer as a parameter, and userInfo will be available to the selector invoking userInfo on the parameter timer. Otherwise, aSelectorName must take an object of class userInfoClass and userInfo must be an object of this class.

Parameters:
ti - the interval in milliseconds between successive firings of the timer
aTarget - the method on which aSelectorName will be invoked
aSelectorName - the method to be invoked when the timer fires
userInfo - user information that should be passed on when the timer fires
userInfoClass - the class of userInfo
repeats - whether or not the timer should fire repeatedly
See Also:
WOTimer(NSTimestamp fireDate, long ti, Object aTarget, String aSelectorName, Object userInfo, Class userInfoClass, boolean repeat)

WOTimer

public WOTimer(NSTimestamp fireDate,
               long ti,
               Object aTarget,
               String aSelectorName,
               Object userInfo,
               Class userInfoClass,
               boolean repeats)
Creates a timer which will fire at fireDate, and at intervals ti thereafter (if repeats is true).

If userInfoClass is null, aSelectorName must take an object of class WOTimer as a parameter, and userInfo will be available to the selector invoking userInfo on the parameter timer. Otherwise, aSelectorName must take an object of class userInfoClass and userInfo must be an object of this class.

Parameters:
fireDate - the time at which the timer should first fire
ti - the interval in milliseconds between successive firings of the timer
aTarget - the method on which aSelectorName will be invoked
aSelectorName - the method to be invoked when the timer fires
userInfo - user information that should be passed on when the timer fires
userInfoClass - the class of userInfo
repeats - whether or not the timer should fire repeatedly
See Also:
WOTimer(long ti, Object aTarget, String aSelectorName, Object userInfo, Class userInfoClass, boolean repeat)
Method Detail

equals

public boolean equals(Object aTimer)
Return true if aTimer is an instance of WOTimer with the same selector, target, and userInfo as the receiver.

Parameters:
aTimer - the timer to be compared
Returns:
true if the objects are equal
See Also:
selector(), target(), userInfo()

fire

public void fire()
Fires the timer, invoking selector on target and passing either the WOTimer -- if userInfoClass was null when the WOTimer was created -- or userInfo.

See Also:
selector(), target(), userInfo()

fireDate

public NSTimestamp fireDate()
Return the NSTimestamp at which the WOTimer will first fire.

Returns:
the NSTimestamp at which the WOTimer will first fire

hashCode

public int hashCode()

invalidate

public void invalidate()
Unschedules the timer and marks it as invalid.

See Also:
schedule()

isValid

public boolean isValid()
Returns whether or not the timer is valid.

Returns:
true if the timer is valid

schedule

public void schedule()
Schedule the WOTimer to be fired.

See Also:
invalidate()

scheduledTimer

public static WOTimer scheduledTimer(long ti,
                                     Object aTarget,
                                     String aSelectorName,
                                     Object userInfo,
                                     boolean repeats)
Creates a timer which will fire after ti milliseconds, and at intervals ti thereafter (if repeats is true).

aSelectorName must take an object of class WOTimer as a parameter, and userInfo will be available to the selector invoking userInfo on the parameter timer.

Parameters:
ti - the interval in milliseconds between successive firings of the timer
aTarget - the method on which aSelectorName will be invoked
aSelectorName - the method to be invoked when the timer fires
userInfo - user information that should be passed on when the timer fires
repeats - whether or not the timer should fire repeatedly
Returns:
true if the timer was scheduled successfully, false otherwise
See Also:
WOTimer(long ti, Object aTarget, String aSelectorName, Object userInfo, Class userInfoClass, boolean repeat)

scheduledTimer

public static WOTimer scheduledTimer(long ti,
                                     Object aTarget,
                                     String aSelectorName,
                                     Object anArgument,
                                     Class anArgumentClass,
                                     boolean repeats)
Creates a timer which will fire after ti milliseconds, and at intervals ti thereafter (if repeats is true).

If anArgumentClass is null, aSelectorName must take an object of class WOTimer as a parameter, and userInfo will be available to the selector invoking userInfo on the parameter timer. Otherwise, aSelectorName must take an object of class anArgumentClass and anArgument must be an object of this class.

Parameters:
ti - the interval in milliseconds between successive firings of the timer
aTarget - the method on which aSelectorName will be invoked
aSelectorName - the method to be invoked when the timer fires
anArgument - parmeter that will be passed to aSelectorName when it is invoked
anArgumentClass - the class of anArgument
repeats - whether or not the timer should fire repeatedly
Returns:
true if the timer was scheduled successfully, false otherwise
See Also:
WOTimer(long ti, Object aTarget, String aSelectorName, Object userInfo, Class userInfoClass, boolean repeat)

selector

public NSSelector selector()
Returns the NSSelector which will be invoked when the WOTimer fires.

Returns:
the NSSelector which will be invoked

target

public Object target()
Returns the object on which selector will be invoked when the WOTimer fires.

Returns:
the object on which selector will be invoked
See Also:
selector()

timeInterval

public double timeInterval()
Return the interval in seconds at which the WOTimer will repeat firing.

Returns:
the interval in seconds at which the WOTimer will repeat firing

toString

public String toString()

userInfo

public Object userInfo()
Returns the userInfo object that was passed when the timer was created.

Returns:
the userInfo object that was passed when the timer was created

Last updated Thu Oct 21 15:04:16 PDT 2004.

Copyright © 2004 Apple Computer, Inc.