Package org.github.jamm.listeners

# Class TreePrinter

java.lang.Object
org.github.jamm.listeners.TreePrinter

All Implemented Interfaces:
  `MemoryMeterListener`

public final class TreePrinter extends Object implements MemoryMeterListener
A memory listener that print to the `System.out` the class tree with the size information.

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static class`
`TreePrinter.Factory`
Factory for `TreePrinter` instances.

## Constructor Summary

Constructors
Constructor
Description
`TreePrinter(int maxDepth)`

## Method Summary

Modifier and Type
Method
Description
`void`
`arrayElementAdded(Object[] array, int index, Object elementValue)`
Notification that the element from the specified array has been added.
`void`
`byteBufferRemainingMeasured(ByteBuffer buffer, long size)`
Notification that the size of the remaining bytes of a `ByteBuffer` have been measured.
`void`
`done(long size)`
Notification that the entire graph has been measured.
`void`
`failedToAccessField(Object obj, String fieldName, Class<?> fieldType)`
Notification that the graph could not be fully measured has it failed to access a field.
`void`
`fieldAdded(Object obj, String fieldName, Object fieldValue)`
Notification that the field from the specified object has been added.
`void`
`objectMeasured(Object current, long size)`
Notification that the size of the specified object has been measured.
`void`
`started(Object obj)`
Notification that `MemoryMeter` as started analyzing the specified object.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### TreePrinter

public TreePrinter(int maxDepth)

## Method Details

### started

public void started(Object obj)
Description copied from interface: `MemoryMeterListener`
Notification that `MemoryMeter` as started analyzing the specified object.

Specified by:
  `started` in interface `MemoryMeterListener`
Parameters:
  `obj` - the object being analyzed

### fieldAdded

public void fieldAdded(Object obj, String fieldName, Object fieldValue)
Description copied from interface: `MemoryMeterListener`
Notification that the field from the specified object has been added.

Specified by:
  `fieldAdded` in interface `MemoryMeterListener`
Parameters:
  `obj` - the object for which a field has been added
  `fieldName` - the field name
  `fieldValue` - the field value

### arrayElementAdded

public void arrayElementAdded(Object[] array, int index, Object elementValue)
Description copied from interface: `MemoryMeterListener`
Notification that the element from the specified array has been added.

Specified by:
  `arrayElementAdded` in interface `MemoryMeterListener`
Parameters:
  `array` - the array for which an element has been added
  `index` - the element index
  `elementValue` - the element value

### objectMeasured

public void objectMeasured(Object current, long size)
Description copied from interface: `MemoryMeterListener`
Notification that the size of the specified object has been measured.

Specified by:
  `objectMeasured` in interface `MemoryMeterListener`
Parameters:
  `current` - the object that has been measured
  `size` - the object size in bytes

### byteBufferRemainingMeasured

public void byteBufferRemainingMeasured(ByteBuffer buffer, long size)
Description copied from interface: `MemoryMeterListener`
Notification that the size of the remaining bytes of a `ByteBuffer` have been measured.

Specified by:
  `byteBufferRemainingMeasured` in interface `MemoryMeterListener`
Parameters:
  `buffer` - the `ByteBuffer`
  `size` - the remaining bytes

### done

public void done(long size)
Description copied from interface: `MemoryMeterListener`
Notification that the entire graph has been measured.

Specified by:
  `done` in interface `MemoryMeterListener`
Parameters:
  `size` - the size of the entire graph.

### failedToAccessField

public void failedToAccessField(Object obj, String fieldName, Class<?> fieldType)
Description copied from interface: `MemoryMeterListener`
Notification that the graph could not be fully measured has it failed to access a field.

Specified by:
  `failedToAccessField` in interface `MemoryMeterListener`
Parameters:
  `obj` - the object owning the field that could not be accessed
  `fieldName` - the field name
  `fieldType` - the field type