Store the class name of the interval so that we can identify it after

cancellation.  It's tempting to store the string representation as
well when the reference is cleared, but that could be anything, so
avoid the expense.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2992 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
andrzej@threerings.net
2011-03-22 22:01:47 +00:00
parent c994b9cde1
commit 227a8fa447
@@ -44,6 +44,12 @@ public abstract class Interval
* likely used to call toString() on the Interval for logging purposes.
*/
public Interval getInterval ();
/**
* Returns the class name of the interval (valid even if the interval has been cancelled
* and its reference cleared).
*/
public String getIntervalClassName ();
}
/**
@@ -285,6 +291,7 @@ public abstract class Interval
public IntervalTask (Interval interval)
{
_interval = interval;
_intervalClassName = interval.getClass().getName();
}
@Override public boolean cancel ()
@@ -316,6 +323,9 @@ public abstract class Interval
public Interval getInterval () {
return _interval;
}
public String getIntervalClassName () {
return _intervalClassName;
}
@Override public String toString () {
Interval ival = _interval;
return (ival != null) ? ival.toString() : "(Interval was cancelled)";
@@ -347,6 +357,9 @@ public abstract class Interval
* cancel removes the reference back to the Interval. */
protected Interval _interval;
/** The class name of the interval (so that we can identify it after cancellation). */
protected String _intervalClassName;
} // end: static class IntervalTask
/** If non-null, the RunQueue used to run the expired() method for each Interval. */