org.eclipse.mat.snapshot
Class HistogramRecord

java.lang.Object
  extended by org.eclipse.mat.snapshot.HistogramRecord
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
ClassHistogramRecord, ClassHistogramRecordBuilder, ClassLoaderHistogramRecord, ClassLoaderHistogramRecordBuilder, Histogram, HistogramBuilder

public class HistogramRecord
extends java.lang.Object
implements java.io.Serializable

This class holds all basic data for a histogram record. Other classes inherit from it. It offers comparators to sort histogram records by their basic data. This pattern should be implemented by the classes inheriting from it as well.

See Also:
Serialized Form

Field Summary
static java.util.Comparator<HistogramRecord> COMPARATOR_FOR_LABEL
           
static java.util.Comparator<HistogramRecord> COMPARATOR_FOR_NUMBEROFOBJECTS
           
static java.util.Comparator<HistogramRecord> COMPARATOR_FOR_RETAINEDHEAPSIZE
           
static java.util.Comparator<HistogramRecord> COMPARATOR_FOR_USEDHEAPSIZE
           
 
Constructor Summary
HistogramRecord(java.lang.String label)
          Create histogram record just with a label identifying it.
HistogramRecord(java.lang.String label, long numberOfObjects, long usedHeapSize, long retainedHeapSize)
          Create histogram record with a label identifying it and its basic data.
 
Method Summary
 java.lang.String getLabel()
          Get label identifying the histogram record.
 long getNumberOfObjects()
          Get number of objects this histogram record stands for.
 long getRetainedHeapSize()
          Get number of retained bytes in heap area this histogram record stands for.
 long getUsedHeapSize()
          Get number of bytes in heap area this histogram record stands for.
 void incNumberOfObjects()
          Increment number of objects this histogram record stands for by 1.
 void incNumberOfObjects(long inc)
          Increment number of objects this histogram record stands for.
 void incRetainedHeapSize(long inc)
           
 void incUsedHeapSize(long inc)
          Increment number of bytes in heap area this histogram record stands for.
static java.util.Comparator<HistogramRecord> reverseComparator(java.util.Comparator<HistogramRecord> comparator)
          Convenience method reversing the order of the given comparator.
 void setLabel(java.lang.String label)
          Set label identifying the histogram record.
 void setNumberOfObjects(long numberOfObjects)
          Set number of objects this histogram record stands for.
 void setRetainedHeapSize(long retainedHeapSize)
          Set number of retained bytes in heap area this histogram record stands for.
 void setUsedHeapSize(long usedHeapSize)
          Set number of bytes in heap area this histogram record stands for.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMPARATOR_FOR_LABEL

public static final java.util.Comparator<HistogramRecord> COMPARATOR_FOR_LABEL

COMPARATOR_FOR_NUMBEROFOBJECTS

public static final java.util.Comparator<HistogramRecord> COMPARATOR_FOR_NUMBEROFOBJECTS

COMPARATOR_FOR_USEDHEAPSIZE

public static final java.util.Comparator<HistogramRecord> COMPARATOR_FOR_USEDHEAPSIZE

COMPARATOR_FOR_RETAINEDHEAPSIZE

public static final java.util.Comparator<HistogramRecord> COMPARATOR_FOR_RETAINEDHEAPSIZE
Constructor Detail

HistogramRecord

public HistogramRecord(java.lang.String label)
Create histogram record just with a label identifying it.

Parameters:
label - label identifying the histogram record

HistogramRecord

public HistogramRecord(java.lang.String label,
                       long numberOfObjects,
                       long usedHeapSize,
                       long retainedHeapSize)
Create histogram record with a label identifying it and its basic data.

Parameters:
label - label identifying the histogram record
numberOfObjects - number of objects this histogram record stands for
usedHeapSize - number of bytes in heap area this histogram record stands for
Method Detail

getLabel

public java.lang.String getLabel()
Get label identifying the histogram record.

Returns:
label identifying the histogram record

setLabel

public void setLabel(java.lang.String label)
Set label identifying the histogram record.

Parameters:
label - label identifying the histogram record

getNumberOfObjects

public long getNumberOfObjects()
Get number of objects this histogram record stands for.

Returns:
number of objects this histogram record stands for

setNumberOfObjects

public void setNumberOfObjects(long numberOfObjects)
Set number of objects this histogram record stands for.

Parameters:
numberOfObjects - number of objects this histogram record stands for

incNumberOfObjects

public void incNumberOfObjects()
Increment number of objects this histogram record stands for by 1.


incNumberOfObjects

public void incNumberOfObjects(long inc)
Increment number of objects this histogram record stands for.

Parameters:
inc - number of objects by which the number of objects should be incremented

getUsedHeapSize

public long getUsedHeapSize()
Get number of bytes in heap area this histogram record stands for.

Returns:
number of bytes in heap area this histogram record stands for

setUsedHeapSize

public void setUsedHeapSize(long usedHeapSize)
Set number of bytes in heap area this histogram record stands for.

Parameters:
usedHeapSize - number of bytes in heap area this histogram record stands for

incUsedHeapSize

public void incUsedHeapSize(long inc)
Increment number of bytes in heap area this histogram record stands for.

Parameters:
inc - number of bytes by which the number of bytes in heap area should be incremented

getRetainedHeapSize

public long getRetainedHeapSize()
Get number of retained bytes in heap area this histogram record stands for.

Retained bytes means how much memory would be garbage collected if the references to the objects this histogram record stands for would be lost and the objects garbage collected.

Returns:
number of retained bytes in heap area this histogram record stands for

setRetainedHeapSize

public void setRetainedHeapSize(long retainedHeapSize)
Set number of retained bytes in heap area this histogram record stands for.

Retained bytes means how much memory would be garbage collected if the references to the objects this histogram record stands for would be lost and the objects garbage collected.

Parameters:
retainedHeapSize - number of retained bytes in heap area this histogram record stands for

incRetainedHeapSize

public void incRetainedHeapSize(long inc)

reverseComparator

public static java.util.Comparator<HistogramRecord> reverseComparator(java.util.Comparator<HistogramRecord> comparator)
Convenience method reversing the order of the given comparator. Be aware that each time you call this method a new comparator is returned and that this comparator delegates the call to the given comparator, but just switches the parameters. You can get the same result with the given comparator, by iterating from the last to the first element instead. From performance perspective using e.g. List.get(int) is anyhow faster compared to an Iterator.

Parameters:
comparator - comparator for which a reversed comparator should be returned
Returns:
comparator comparing in reverse order than the given comparator