From 227a8fa44799b0785f2df75ef048536ac0532f4c Mon Sep 17 00:00:00 2001 From: "andrzej@threerings.net" Date: Tue, 22 Mar 2011 22:01:47 +0000 Subject: [PATCH] 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 --- src/main/java/com/samskivert/util/Interval.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/com/samskivert/util/Interval.java b/src/main/java/com/samskivert/util/Interval.java index b9e6044c..c9b8a911 100644 --- a/src/main/java/com/samskivert/util/Interval.java +++ b/src/main/java/com/samskivert/util/Interval.java @@ -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. */