SK.gnome.dwarf.utils
Class Counter

java.lang.Object
  extended bySK.gnome.dwarf.utils.Counter

public final class Counter
extends java.lang.Object

Provides basic counter statistics.

The Counter class counts the current, peak and total number of simultaneous events.

This class is synchronized and the numbers returned by the getter methods are always consistent with the actual counter's internal state.


Constructor Summary
Counter()
           
 
Method Summary
 void dec()
          Decrements the counter.
 int getCurrent()
          Returns the current number of events.
 int getPeak()
          Returns the peak number of events.
 long getTotal()
          Returns the total number of events.
 void inc()
          Increments the counter.
 void reset()
          Resets the counter.
 void resetCurrent()
          Resets the counter.
 java.lang.String toString()
          Returns the current/peak/total number of the events.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Counter

public Counter()
Method Detail

inc

public void inc()
Increments the counter.

Should be called when the particular counted event starts.


dec

public void dec()
Decrements the counter.

Should be called when the particular counted event ends.


resetCurrent

public void resetCurrent()
Resets the counter.

Sets the current number of events to zero.


reset

public void reset()
Resets the counter.

Sets the current/peak/total number of events to zero.


getCurrent

public int getCurrent()
Returns the current number of events.

Returns:
the current number

getPeak

public int getPeak()
Returns the peak number of events.

Returns:
the peak number

getTotal

public long getTotal()
Returns the total number of events.

Returns:
the total number

toString

public java.lang.String toString()
Returns the current/peak/total number of the events.

If the total number ends with asterisk, it means that it reached the maximum possible value and the counter started from zero again.

Returns:
the counter statistics


Copyright (c) 1999-2005, Gnome Ltd. All rights reserved.