Package org.eclipse.mat.internal.collectionextract

# Class SetFromCollectionExtractor

java.lang.Object
org.eclipse.mat.internal.collectionextract.SetFromCollectionExtractor

All Implemented Interfaces:
  `ICollectionExtractor`, `IMapExtractor`

public class SetFromCollectionExtractor extends Object implements IMapExtractor
Give a set-like extractor from a collection extractor

## Nested Class Summary

## Nested classes/interfaces inherited from interface org.eclipse.mat.inspections.collectionextract.IMapExtractor

`IMapExtractor.EntryObject`

## Constructor Summary

Constructors
Constructor
Description
`SetFromCollectionExtractor(ICollectionExtractor ex)`
`SetFromCollectionExtractor(ICollectionExtractor ex, double collisionRatio)`

## Method Summary

Modifier and Type
Method
Description
`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
`Iterator<Map.Entry<IObject,IObject>>`
`extractMapEntries(IObject collection)`
Extracts the contents of a map (i.e.
`Integer`
`getCapacity(IObject collection)`
Return the capacity of the collection, if applicable
`Double`
`getCollisionRatio(IObject coll)`
Calculates the collision ratio in the collection.
`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`
`hasCollisionRatio()`
Check if the extractor can calculate collision ratio
`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.

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

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

## Constructor Details

### SetFromCollectionExtractor

public SetFromCollectionExtractor(ICollectionExtractor ex)

### SetFromCollectionExtractor

public SetFromCollectionExtractor(ICollectionExtractor ex, double collisionRatio)

## Method Details

### hasCollisionRatio

public boolean hasCollisionRatio()
Description copied from interface: `IMapExtractor`
Check if the extractor can calculate collision ratio

Specified by:
  `hasCollisionRatio` in interface `IMapExtractor`
Returns:
  true if @`IMapExtractor.getCollisionRatio(IObject)` could be called
See Also:
  - `IMapExtractor.getCollisionRatio(IObject)`

### getCollisionRatio

public Double getCollisionRatio(IObject coll) throws SnapshotException
Description copied from interface: `IMapExtractor`
Calculates the collision ratio in the collection. Could be an estimate.

Specified by:
  `getCollisionRatio` in interface `IMapExtractor`
Parameters:
  `coll` - - the collection to calculate the collision ratio of
Returns:
  Double number of elements with colliding keys / size
Throws:
  `SnapshotException`
See Also:
  - `IMapExtractor.hasCollisionRatio()`

### extractMapEntries

public Iterator<Map.Entry<IObject,IObject>> extractMapEntries(IObject collection) throws SnapshotException
Description copied from interface: `IMapExtractor`
Extracts the contents of a map (i.e. an IObject representing a Map) and provides an Iterator over them

Specified by:
  `extractMapEntries` in interface `IMapExtractor`
Parameters:
  `collection` - - the map to extract contents from
Returns:
  an Iterator over the entries. If the original Map had an Entry object, the content of the iterator would usually be EntryObject
Throws:
  `SnapshotException`

### hasSize

public boolean hasSize()
Description copied from interface: `ICollectionExtractor`
Check if the size of the collection can be extracted.

Specified by:
  `hasSize` in interface `ICollectionExtractor`
Returns:
  true if `ICollectionExtractor.getSize(IObject)` could be called
See Also:
  - `ICollectionExtractor.getSize(IObject)`

### getSize

public Integer getSize(IObject collection) throws SnapshotException
Description copied from interface: `ICollectionExtractor`
Extract the size of the collection.

Specified by:
  `getSize` in interface `ICollectionExtractor`
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:
  - `ICollectionExtractor.hasSize()`

### hasCapacity

public boolean hasCapacity()
Description copied from interface: `ICollectionExtractor`
Check if the collection has capacity, e.g. ArrayList

Specified by:
  `hasCapacity` in interface `ICollectionExtractor`
Returns:
  true if `ICollectionExtractor.getCapacity(IObject)` could be called
See Also:
  - `ICollectionExtractor.getCapacity(IObject)`

### getCapacity

public Integer getCapacity(IObject collection) throws SnapshotException
Description copied from interface: `ICollectionExtractor`
Return the capacity of the collection, if applicable

Specified by:
  `getCapacity` in interface `ICollectionExtractor`
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:
  - `ICollectionExtractor.hasCapacity()`

### hasFillRatio

public boolean hasFillRatio()
Description copied from interface: `ICollectionExtractor`
Check if fill ratio for the collection can be calculated, i.e. if it has some predefined capacity and actual size.

Specified by:
  `hasFillRatio` in interface `ICollectionExtractor`
Returns:
  true if `ICollectionExtractor.getFillRatio(IObject)` could be called
See Also:
  - `ICollectionExtractor.getFillRatio(IObject)`

### getFillRatio

public Double getFillRatio(IObject collection) throws SnapshotException
Description copied from interface: `ICollectionExtractor`
Calculate the fill ratio of a collection

Specified by:
  `getFillRatio` in interface `ICollectionExtractor`
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:
  - `ICollectionExtractor.hasFillRatio()`

### hasExtractableContents

public boolean hasExtractableContents()
Description copied from interface: `ICollectionExtractor`
Check if the collection has extractable contents

Specified by:
  `hasExtractableContents` in interface `ICollectionExtractor`
Returns:
  true if `ICollectionExtractor.extractEntryIds(IObject)` could be called
See Also:
  - `ICollectionExtractor.extractEntryIds(IObject)`

### extractEntryIds

public int[] extractEntryIds(IObject collection) throws SnapshotException
Description copied from interface: `ICollectionExtractor`
Returns the object ids (int) for all objects which are contained in the collection

Specified by:
  `extractEntryIds` in interface `ICollectionExtractor`
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:
  - `ICollectionExtractor.hasExtractableContents()`

### hasExtractableArray

public boolean hasExtractableArray()
Description copied from interface: `ICollectionExtractor`
Return true if the collection array based and the array can be extracted from the heap dump

Specified by:
  `hasExtractableArray` in interface `ICollectionExtractor`
Returns:
  true if `ICollectionExtractor.extractEntries(IObject)` could be called
See Also:
  - `ICollectionExtractor.extractEntries(IObject)`

### extractEntries

public IObjectArray extractEntries(IObject collection) throws SnapshotException
Description copied from interface: `ICollectionExtractor`
Extracts the array containing the collection content

Specified by:
  `extractEntries` in interface `ICollectionExtractor`
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:
  - `ICollectionExtractor.hasExtractableArray()`

### getNumberOfNotNullElements

public Integer getNumberOfNotNullElements(IObject collection) throws SnapshotException
Description copied from interface: `ICollectionExtractor`
Returns the number of non-null elements in the collection. Requires hasExtractableContents or hasExtractableArray

Specified by:
  `getNumberOfNotNullElements` in interface `ICollectionExtractor`
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:
  - `ICollectionExtractor.hasExtractableContents()`
  - `ICollectionExtractor.hasExtractableArray()`