com.ibm.dtfj.analyzer.util
Class CountedName

java.lang.Object
  extended by com.ibm.dtfj.analyzer.util.CountedName
All Implemented Interfaces:
java.lang.Comparable
Direct Known Subclasses:
ArrayCount

public class CountedName
extends java.lang.Object
implements java.lang.Comparable

A simple mutable Integer with attached name. Note that it is arranged for sorting into increasing count order not into name order. The original aim was to keep track of the number of instances of a given class. The ArrayCount subclass keeps track of the number of array instances and in addition records the max and min element count. See ArrayCount


Constructor Summary
CountedName(java.lang.String name)
          Typically the name of the class we're counting
 
Method Summary
 void addBytes(long b)
          Add the given number of bytes to the current total
 int compareTo(java.lang.Object other)
          Compare based on the counts so we can sort the most frequent
 long getBytes()
          How many bytes do these occupy
 int getCount()
          How many of these have we seen ?
 java.lang.String getName()
          Return the name of this count
 void increment()
          Add one more to the count
 java.lang.String toString()
          The default is the name and the count value - not the bytes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CountedName

public CountedName(java.lang.String name)
Typically the name of the class we're counting

Parameters:
name -
Method Detail

increment

public void increment()
Add one more to the count


addBytes

public void addBytes(long b)
Add the given number of bytes to the current total

Parameters:
b -

getCount

public int getCount()
How many of these have we seen ?

Returns:
number of instances

getBytes

public long getBytes()
How many bytes do these occupy

Returns:
total bytes for the instances

getName

public java.lang.String getName()
Return the name of this count

Returns:
name

toString

public java.lang.String toString()
The default is the name and the count value - not the bytes

Overrides:
toString in class java.lang.Object

compareTo

public int compareTo(java.lang.Object other)
Compare based on the counts so we can sort the most frequent

Specified by:
compareTo in interface java.lang.Comparable


© Copyright IBM Corp. 2007, 2008 All Rights Reserved. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.