|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--xbn.XBNObject | +--xbn.util.TimerUnits
For keeping track of things that have a delay, or expire within a given number of units.
Source code: TimerUnits.java. Example code See the example code for TimerSeconds.
Fields inherited from class xbn.XBNObject |
bFALSE_IN_PRODUCTION, bTRUE_IN_PRODUCTION, sCNSTR, sES, sLINE_SEP |
Constructor Summary | |
TimerUnits()
Create a TimerUnits that does not expire. |
|
TimerUnits(long l_millsMultiplier,
int i_unitsToExpire)
Create a TimerUnits. |
|
TimerUnits(long l_millsMultiplier,
int i_unitsToExpire,
boolean b_crashIfMidStartOrStop)
Create a TimerUnits. |
|
TimerUnits(long l_millsMultiplier,
int i_unitsToExpire,
boolean b_crashIfStartStart,
boolean b_crashIfStopStop)
Create a TimerUnits. |
Method Summary | |
boolean |
doCrashIfStartStart()
When the timer is already started, is it legal to start it again? |
boolean |
doCrashIfStopStop()
When the timer is already stopped, is it legal to stop it again? |
boolean |
doesExpire()
Does this timer ever expire? |
Date |
getDateStarted()
Get the date representing the moment the timer was started. |
long |
getMillsMultiplier()
Get the millesecond multiplier for this TimerUnits. |
long |
getMillsToExpire()
Get the number of milleseconds until expiration. |
int |
getUnitsToExpire()
Get the total number of units until expiration. |
boolean |
hasExpired()
Have the number of units to expiration gone a went? |
boolean |
isStarted()
Has the timer been started? |
boolean |
isStopped()
Has the timer been stopped? |
void |
start()
Start the timer. |
void |
stop()
Stop the timer. |
String |
toString()
Get some information about this TimerUnits. |
Methods inherited from class xbn.XBNObject |
getXMsgPrefix, sop, sopl, sopl, throwAX, throwAXIfBadStr, throwAXIfNull, throwAXSpoof |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public TimerUnits()
Create a TimerUnits that does not expire.
Equal to TimerUnits(0, -1)
public TimerUnits(long l_millsMultiplier, int i_unitsToExpire)
Create a TimerUnits.
Equal to TimerUnits(l_millsMultiplier, i_unitsToExpire, false)
public TimerUnits(long l_millsMultiplier, int i_unitsToExpire, boolean b_crashIfMidStartOrStop)
Create a TimerUnits.
Equal to TimerUnits(l_millsMultiplier, i_unitsToExpire, b_crashIfMidStartOrStop, b_crashIfMidStartOrStop)
public TimerUnits(long l_millsMultiplier, int i_unitsToExpire, boolean b_crashIfStartStart, boolean b_crashIfStopStop)
Create a TimerUnits.
l_millsMultiplier
- This number times i_unitsToExpire is the number of milleseconds until expiration. See getMillsMultiplier.i_unitsToExpire
- The number of units for the delay/until expiration. If -1, then there is no delay (expiration never occurs). Otherwise, must be greater than or equal to one. See getSeconds.b_crashIfStartStart
- Is it legal to start the timer when already started? See doCrashIfStartStart.b_crashIfStopStop
- Is it legal to stop the timer when already stopped? See doCrashIfStopStop.Method Detail |
public void start()
Start the timer. getSeconds, from the moment when this function is called, is when isReady will return true.
See stop.
AssertException
- If already started and doCrashIfStartStart equals true.public void stop()
Stop the timer.
See start.
AssertException
- If already stopped and doCrashIfStopStop equals true.public boolean doCrashIfStartStart()
When the timer is already started, is it legal to start it again?
public boolean doCrashIfStopStop()
When the timer is already stopped, is it legal to stop it again?
public int getUnitsToExpire()
Get the total number of units until expiration. This number, multiplied by getMillsMultiplier, is the number of milliseconds until expiration.
This number represents the units from the moment this TimerUnits is started, to the moment it expires. It does not change during the life of this object.
public long getMillsMultiplier()
Get the millesecond multiplier for this TimerUnits. This number, multiplied by getUnitsToExpire, is the number of milliseconds until expiration.
public long getMillsToExpire()
Get the number of milleseconds until expiration.
(getUnitsToExpire() * getMillsMultiplier())
public boolean doesExpire()
Does this timer ever expire?
(getUnitsToExpire() != -1)
public boolean isStarted()
Has the timer been started?
(getDateStarted() != null)
public boolean isStopped()
Has the timer been stopped?
!isStarted()
public Date getDateStarted()
Get the date representing the moment the timer was started.
public boolean hasExpired()
Have the number of units to expiration gone a went?
When this function returns true, the timer is stopped.
[UtilDate].getNowMinusYUnits(getDateStarted(), getMillsMultiplier()) >= getUnitsToExpire())
public String toString()
Get some information about this TimerUnits.
toString
in class Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 1997-2003, Jeff Epstein, All Rights Reserved. See top of source code files for copyright notice.
http://sourceforge.net/projects/xbnjava