|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.sensor.counter.Counter
Implements a simple labeled counter that supports incrementing and
decrementing operations. Counters usually keep track of a countable
piece of business information, like the number of orders processed,
the number of active sessions, the number of logged in users, etc.
The minimum value of a counter is zero. It is not possible to
decrement a counter past zero. The maximum value of a counter is
Long.MAX_VALUE
. It is not possible to increment
a counter past Long.MAX_VALUE
.
todo: should all the value-related methods be synchronized or only the methods with a conditional ?
Constructor Summary | |
Counter(String label)
Constructor that sets the label that identifies one instance of Counter from another. |
Method Summary | |
void |
decrement()
Decrements this counter by one if the current value is greater than zero. |
String |
getLabel()
Returns the label. |
long |
getValue()
Returns the value. |
void |
increment()
Increments this counter by one. |
void |
reset()
Resets this counter back to zero. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Counter(String label)
label
- the label that identifies one instance of Counter from another.Method Detail |
public void increment()
public void decrement()
public void reset()
public String getLabel()
public long getValue()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |