Package org.onemind.commons.java.util
Class Counter
- java.lang.Object
-
- org.onemind.commons.java.util.Counter
-
public class Counter extends java.lang.ObjectFor 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.Mapcountsthe counts
-
Constructor Summary
Constructors Constructor Description Counter()Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcount(java.lang.Object counted)Add count.voidcount(java.lang.Object counted, long countValue)Adjust count by valuevoiddump(java.io.Writer writer)Dump to outputlonggetCount(java.lang.Object counted)Get the countvoidremoveCount(java.lang.Object counted)Remove the count.voidresetAll()Reset all the countersvoidresetCount(java.lang.Object counted)Reset the count for countedjava.lang.StringtoString()
-
-
-
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.IOExceptionDump 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:
toStringin classjava.lang.Object
-
-