Package org.onemind.commons.java.util
Class Counter
- java.lang.Object
-
- org.onemind.commons.java.util.Counter
-
public class Counter extends java.lang.Object
For counting things- Version:
- $Id: Counter.java,v 1.2 2005/06/22 22:58:25 thlee Exp $ $Name: $
- Author:
- TiongHiang Lee (thlee@onemindsoft.org)
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map
counts
the counts
-
Constructor Summary
Constructors Constructor Description Counter()
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
count(java.lang.Object counted)
Add count.void
count(java.lang.Object counted, long countValue)
Adjust count by valuevoid
dump(java.io.Writer writer)
Dump to outputlong
getCount(java.lang.Object counted)
Get the countvoid
removeCount(java.lang.Object counted)
Remove the count.void
resetAll()
Reset all the countersvoid
resetCount(java.lang.Object counted)
Reset the count for countedjava.lang.String
toString()
-
-
-
Method Detail
-
count
public void count(java.lang.Object counted)
Add count. Count as 1 if it is not counted before- Parameters:
counted
-
-
count
public void count(java.lang.Object counted, long countValue)
Adjust count by value- Parameters:
counted
- the countedcountValue
- the count value
-
removeCount
public void removeCount(java.lang.Object counted)
Remove the count. Count as -1 if it is not counted before- Parameters:
counted
- the counted
-
getCount
public long getCount(java.lang.Object counted)
Get the count- Parameters:
counted
- the counted- Returns:
- the count
-
dump
public void dump(java.io.Writer writer) throws java.io.IOException
Dump to output- Parameters:
writer
- the writer- Throws:
java.io.IOException
-
resetCount
public void resetCount(java.lang.Object counted)
Reset the count for counted- Parameters:
counted
- the counted
-
resetAll
public void resetAll()
Reset all the counters
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-