Package org.eclipse.mat.inspections.collectionextract

## Interface ICollectionExtractor

All Known Subinterfaces:
  `IMapExtractor`

All Known Implementing Classes:
  `ArrayCollectionExtractor`, `ConcurrentHashMapCollectionExtractor`, `ConcurrentSkipListCollectionExtractor`, `ConcurrentSkipListSetCollectionExtractor`, `EmptyCollectionExtractor`, `EmptyMapExtractor`, `FieldArrayCollectionExtractor`, `FieldSizeArrayCollectionExtractor`, `FieldSizeArrayMapExtractor`, `FieldSizedCapacityCollectionExtractor`, `FieldSizedCapacityMapExtractor`, `FieldSizedCollectionExtractor`, `HashedMapCollectionExtractorBase`, `HashMapCollectionExtractor`, `HashSetCollectionExtractor`, `IBM6ArrayListCollectionExtractor`, `IdentityHashMapCollectionExtractor`, `KeySetCollectionExtractor`, `LinkedListCollectionExtractor`, `MapCollectionExtractorBase`, `MATArrayBig`, `MATCollectionExtractor`, `NoContentCollectionExtractor`, `Pair12CollectionExtractor`, `PairCollectionExtractor`, `RegularEnumSetExtractor`, `ReplicatedValueCollectionExtractor`, `SetFromCollectionExtractor`, `SingletonCollectionExtractor`, `SingletonMapExtractor`, `TreeMapArrayCollectionExtractor`, `TreeMapCollectionExtractor`, `TreeSetArrayCollectionExtractor`, `TreeSetCollectionExtractor`, `ValuesCollectionExtractor`, `WrapperCollectionExtractor`, `WrapperFieldCollectionExtractor`, `WrapperFieldMapExtractor`, `WrapperMapExtractor`, `WrapperSetFromMapExtractor`

    public interface ICollectionExtractor

CollectionExtractors are used to extract from the heap dump the contents of an object which represents a collection of a certain type. It knows the internal details of how the collection contents are stored and if the collection has certain properties or not

Since:
  1.5

### Method Summary

All Methods Instance Methods Abstract Methods
`IObjectArray` `extractEntries​(IObject collection)` Extracts the array containing the collection content
`int[]` `extractEntryIds​(IObject collection)` Returns the object ids (int) for all objects which are contained in the collection
`Integer` `getCapacity​(IObject collection)` Return the capacity of the collection, if applicable
`Double` `getFillRatio​(IObject collection)` Calculate the fill ratio of a collection
`Integer` `getNumberOfNotNullElements​(IObject collection)` Returns the number of non-null elements in the collection.
`Integer` `getSize​(IObject collection)` Extract the size of the collection.
`boolean` `hasCapacity()` Check if the collection has capacity, e.g.
`boolean` `hasExtractableArray()` Return true if the collection array based and the array can be extracted from the heap dump
`boolean` `hasExtractableContents()` Check if the collection has extractable contents
`boolean` `hasFillRatio()` Check if fill ratio for the collection can be calculated, i.e.
`boolean` `hasSize()` Check if the size of the collection can be extracted.

### Method Detail

#### hasSize

    boolean hasSize()

Check if the size of the collection can be extracted.

Returns:
  true if `getSize(IObject)` could be called
See Also:
  `getSize(IObject)`

#### getSize

    Integer getSize​(IObject collection)
             throws SnapshotException

Extract the size of the collection.

Parameters:
  `collection` - - the collection to find the size of
Returns:
  the size, or null if not available
Throws:
  `SnapshotException` - if there is a problem retrieving data from the snapshot
See Also:
  `hasSize()`

#### hasCapacity

    boolean hasCapacity()

Check if the collection has capacity, e.g. ArrayList

Returns:
  true if `getCapacity(IObject)` could be called
See Also:
  `getCapacity(IObject)`

#### getCapacity

    Integer getCapacity​(IObject collection)
                 throws SnapshotException

Return the capacity of the collection, if applicable

Parameters:
  `collection` - - the collection to find the capacity of
Returns:
  the capacity in bytes, or null if unavailable
Throws:
  `SnapshotException` - if there is a problem retrieving data from the snapshot
See Also:
  `hasCapacity()`

#### hasFillRatio

    boolean hasFillRatio()

Check if fill ratio for the collection can be calculated, i.e. if it has some predefined capacity and actual size.

Returns:
  true if `getFillRatio(IObject)` could be called
See Also:
  `getFillRatio(IObject)`

#### getFillRatio

    Double getFillRatio​(IObject collection)
                 throws SnapshotException

Calculate the fill ratio of a collection

Parameters:
  `collection` - - the collection to find the fill ratio of
Returns:
  the fill ratio, between 0.0 and 1.0, or null if unavailable
Throws:
  `SnapshotException` - if there is a problem retrieving data from the snapshot
See Also:
  `hasFillRatio()`

#### hasExtractableContents

    boolean hasExtractableContents()

Check if the collection has extractable contents

Returns:
  true if `extractEntryIds(IObject)` could be called
See Also:
  `extractEntryIds(IObject)`

#### extractEntryIds

    int[] extractEntryIds​(IObject collection)
                   throws SnapshotException

Returns the object ids (int) for all objects which are contained in the collection

Parameters:
  `collection` - - the collection to find the objects it holds
Returns:
  an array of ints which are the object ids.
Throws:
  `SnapshotException` - if there is a problem retrieving data from the snapshot
See Also:
  `hasExtractableContents()`

#### hasExtractableArray

    boolean hasExtractableArray()

Return true if the collection array based and the array can be extracted from the heap dump

Returns:
  true if `extractEntries(IObject)` could be called
See Also:
  `extractEntries(IObject)`

#### extractEntries

    IObjectArray extractEntries​(IObject collection)
                         throws SnapshotException

Extracts the array containing the collection content

Parameters:
  `collection` - - the collection to find the object array holding its contents
Returns:
  the backing array for the collection
Throws:
  `SnapshotException` - if there is a problem retrieving data from the snapshot
See Also:
  `hasExtractableArray()`

#### getNumberOfNotNullElements

    Integer getNumberOfNotNullElements​(IObject collection)
                                throws SnapshotException

Returns the number of non-null elements in the collection. Requires hasExtractableContents or hasExtractableArray

Parameters:
  `collection` - - the collection to find the number of non-null content objects
Returns:
  the number of non-null elements, or null if not available
Throws:
  `SnapshotException`
See Also:
  `hasExtractableContents()`, `hasExtractableArray()`