IDebug
© 1997-2001 Joseph Kiniry
© 2000-2001 KindSoftware
© 1997-1999 Caltech
All Rights Reserved

idebug
Class Collect

java.lang.Object
  |
  +--idebug.Collect
Direct Known Subclasses:
SimpleCollect, SimpleCollect

public abstract class Collect
extends java.lang.Object

The core interface to gathering statistics.

Users of IDebug wishing to keep statistics on their system need to inherit from this abstract class and implement the protected methods. The simplest means to collect statistics are to use a hashtable keyed on statistic (since their hashCode is valid) and store Double objects corresponding to the current value of that statistic. See idebug.SimpleCollect for an example of this implementation which you can reuse.

Version:
$Revision: 2146 $ $Date: 2005-02-13 16:54:27 +0000 (Sun, 13 Feb 2005) $
Author:
Joseph R. Kiniry
See Also:
Statistic, SimpleCollect

Constructor Summary
Collect()
           Construct a new Collect class.
 
Method Summary
 boolean checkDebugCollectRef(Debug d)
           Checks a debug instance to make sure its collect attribute references this Collect object.
 boolean checkStatisticID(Statistic statistic)
           Check the ID of a statistic and make sure that it hasn't changed since it was registered.
abstract  double currentValue(Statistic statistic)
           What is the current value for specific statistic?
abstract  double decrement(Statistic statistic)
           Decrement a statistic by the default value.
abstract  double decrement(Statistic statistic, double value)
           Decrement a statistic by a specified value.
abstract  double increment(Statistic statistic)
           Increment a statistic by the default value.
abstract  double increment(Statistic statistic, double value)
           Increment a statistic by a specified value.
 boolean isRegistered(Statistic statistic)
           Check to see if a statistic is registered yet.
protected  boolean isValidCategory(java.lang.String category)
           Tests to see if the current debug context is interested in a given category.
protected  boolean isValidLevel(int level)
           Tests to see if the current debug context is interested in a given level.
 void register(Statistic statistic)
           Register a statistic with the collector.
abstract  java.lang.Object report(Statistic statistic)
           Report on a particular statistic.
abstract  java.lang.Object reportAll()
           Report on all statistics.
abstract  double reset(Statistic statistic)
           Reset a statistic to the default start value.
abstract  double set(Statistic statistic, double value)
           Set a statistic to a specific value.
 void setDebug(Debug d)
           Set the debug instance associated with this collect instance.
 void unregister(Statistic statistic)
           Unregister a statistic with the collector.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Collect

public Collect()

Construct a new Collect class.

Method Detail

checkDebugCollectRef

public boolean checkDebugCollectRef(Debug d)

Checks a debug instance to make sure its collect attribute references this Collect object.

Parameters:
d - the debug instance to check.

setDebug

public final void setDebug(Debug d)

Set the debug instance associated with this collect instance. This method must be called with the correct debug instance prior to using any of the methods of this Collect instance.

Parameters:
d - the debug object associated with this Collect object.

register

public void register(Statistic statistic)

Register a statistic with the collector.

Parameters:
statistic - the statistic to register.

checkStatisticID

public boolean checkStatisticID(Statistic statistic)

Check the ID of a statistic and make sure that it hasn't changed since it was registered.

Parameters:
statistic - the statistic to check.

unregister

public void unregister(Statistic statistic)

Unregister a statistic with the collector.

Parameters:
statistic - the statistic to unregister.

isRegistered

public boolean isRegistered(Statistic statistic)

Check to see if a statistic is registered yet.

Parameters:
statistic - the statistic to check.

currentValue

public abstract double currentValue(Statistic statistic)

What is the current value for specific statistic?

Parameters:
statistic - the statistic being modified.
Returns:
the old value of the statistic.

report

public abstract java.lang.Object report(Statistic statistic)

Report on a particular statistic.

Parameters:
statistic - the statistic being reported on.
Returns:
a report on the statistic, typically encapsulated in some type of Report object or just a simple String textual report.

reportAll

public abstract java.lang.Object reportAll()

Report on all statistics.

Returns:
a report on all statistics, typically encapsulated in some type of Report object or just a simple String textual report.

increment

public abstract double increment(Statistic statistic,
                                 double value)

Increment a statistic by a specified value.

Parameters:
statistic - the statistic being modified.
value - the amount to increment the statistic.
Returns:
the old value of the statistic.

increment

public abstract double increment(Statistic statistic)

Increment a statistic by the default value.

Parameters:
statistic - the statistic being modified.
Returns:
the old value of the statistic.

decrement

public abstract double decrement(Statistic statistic,
                                 double value)

Decrement a statistic by a specified value.

Parameters:
statistic - the statistic being modified.
value - the amount to decrement the statistic.
Returns:
the old value of the statistic.

decrement

public abstract double decrement(Statistic statistic)

Decrement a statistic by the default value.

Parameters:
statistic - the statistic being modified.
Returns:
the old value of the statistic.

reset

public abstract double reset(Statistic statistic)

Reset a statistic to the default start value.

Parameters:
statistic - the statistic to reset.
Returns:
the old value of the statistic.

set

public abstract double set(Statistic statistic,
                           double value)

Set a statistic to a specific value.

Parameters:
statistic - the statistic being modified.
value - the new value of the statistic.
Returns:
the old value of the statistic.

isValidCategory

protected final boolean isValidCategory(java.lang.String category)

Tests to see if the current debug context is interested in a given category.

Parameters:
category - the category to inspect.
Returns:
a boolean indicating if the category in question is valid at this time for this context (i.e. debugging framework state, thread, class invoking the method, etc.)
See Also:
Context

isValidLevel

protected final boolean isValidLevel(int level)

Tests to see if the current debug context is interested in a given level.

Parameters:
level - the level to inspect.
Returns:
a boolean indicating if the level in question is valid at this time for this context (i.e. debugging framework state, thread, class invoking the method, etc.)
See Also:
Context

IDebug
© 1997-2001 Joseph Kiniry
© 2000-2001 KindSoftware
© 1997-1999 Caltech
All Rights Reserved