Class 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 value
      void dump​(java.io.Writer writer)
      Dump to output
      long getCount​(java.lang.Object counted)
      Get the count
      void removeCount​(java.lang.Object counted)
      Remove the count.
      void resetAll()
      Reset all the counters
      void resetCount​(java.lang.Object counted)
      Reset the count for counted
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • counts

        private final java.util.Map counts
        the counts
    • Constructor Detail

      • Counter

        public Counter()
        Constructor
    • 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 counted
        countValue - 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 class java.lang.Object