org.jcoderz.commons.statistics
Class Counter

java.lang.Object
  extended by org.jcoderz.commons.statistics.Counter
All Implemented Interfaces:
Resettable
Direct Known Subclasses:
TimedCounter

public class Counter
extends Object
implements Resettable

This class implements a simple counter that can be incremented and decremented. The class is thread-safe.

Author:
Albrecht Messner

Constructor Summary
Counter(String name)
          Constructor.
 
Method Summary
 long decrement()
          Decrement the counter by one.
 long getCount()
          Returns the current value of the counter.
 String getName()
           
 long increment()
          Increment the counter by one.
 void reset()
          Resets the statistical entity that implements this interface.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Counter

public Counter(String name)
Constructor.

Parameters:
name - the counter's name
Method Detail

increment

public long increment()
Increment the counter by one.

Returns:
the incremented counter value

decrement

public long decrement()
Decrement the counter by one.

Returns:
the decremented counter value

getCount

public long getCount()
Returns the current value of the counter.

Returns:
the current value of the counter.

reset

public void reset()
Resets the statistical entity that implements this interface.

Specified by:
reset in interface Resettable

getName

public String getName()
Returns:
Returns the name.

toString

public String toString()

Overrides:
toString in class Object


Copyright 2007 The jCoderZ Project.