Class AbstractExtractedCollection<E,X extends ICollectionExtractor>
- java.lang.Object
-
- org.eclipse.mat.inspections.collectionextract.AbstractExtractedCollection<E,X>
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Iterable<E>,IObject
- Direct Known Subclasses:
ExtractedCollection,ExtractedMap
public abstract class AbstractExtractedCollection<E,X extends ICollectionExtractor> extends java.lang.Object implements java.lang.Iterable<E>, IObject
An abstract class representing a collection extracted from the heap. It provides convenience methods for querying certain properties of the collection (e.g. size) and for extracting the elements of the collection- Since:
- 1.5
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.eclipse.mat.snapshot.model.IObject
IObject.Type
-
-
Constructor Summary
Constructors Constructor Description AbstractExtractedCollection(IObject collection, X extractor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IObjectArrayextractEntries()Get the array with contents of the collectionint[]extractEntryIds()Get the object Ids (int) of the contents of the collectionjava.lang.IntegergetCapacity()Get the capacity of the collectionjava.lang.StringgetClassSpecificName()Get class specific name of this object which depends on the availability of the appropriate name resolver, e.g.IClassgetClazz()Get class snapshot object this object is an instance of.java.lang.StringgetDisplayName()Get concatenation ofIObject.getTechnicalName()andIObject.getClassSpecificName().java.lang.DoublegetFillRatio()Get the ratio to which the collection is filled (for collections which preallocates a certain capacity)GCRootInfo[]getGCRootInfo()GetGCRootInfoif the object is a garbage collection root or null otherwise.longgetObjectAddress()Get address for the snapshot object.intgetObjectId()Get id for the snapshot object.java.util.List<NamedReference>getOutboundReferences()Get list of snapshot objects referenced from this snapshot object with the name of the field over which it was referenced.longgetRetainedHeapSize()Get retained heap size of this object.ISnapshotgetSnapshot()Returns the snapshot from which this object has been read.java.lang.StringgetTechnicalName()Get technical name of this object which is something like class@address.longgetUsedHeapSize()Get used heap size of just this object.booleanhasCapacity()Check if the collection has a capacity property, i.e.booleanhasExtractableArray()Check if the contents of the collection can be extracted as an array (e.g.booleanhasExtractableContents()Check if the the contents of the collection can be extractedbooleanhasFillRatio()Check if the collision ration can be calculated for the collectionbooleanhasSize()Check if the collection has a size propertyjava.lang.BooleanisEmpty()Check if the collection is emptyjava.lang.ObjectresolveValue(java.lang.String field)Resolves and returns the value of a field specified by a dot notation.java.lang.Integersize()Get the size of the collection.java.lang.StringtoString()
-
-
-
Method Detail
-
hasSize
public boolean hasSize()
Check if the collection has a size property
-
hasExtractableContents
public boolean hasExtractableContents()
Check if the the contents of the collection can be extracted- Returns:
- true if the collection has an extractable ids
- See Also:
extractEntryIds()
-
hasExtractableArray
public boolean hasExtractableArray()
Check if the contents of the collection can be extracted as an array (e.g. for ArrayList)- Returns:
- true if the collection has an extractable contents as an
IObjectArray - See Also:
extractEntries()
-
hasCapacity
public boolean hasCapacity()
Check if the collection has a capacity property, i.e. if it preallocates space for its content- Returns:
- true if the collection has a valid
getCapacity() - See Also:
getCapacity()
-
hasFillRatio
public boolean hasFillRatio()
Check if the collision ration can be calculated for the collection- Returns:
- true if the collection has a valid fill ratio
- See Also:
size()
-
getCapacity
public java.lang.Integer getCapacity()
Get the capacity of the collection- Returns:
- the capacity of the collection as an Integer
- See Also:
hasCapacity()
-
size
public java.lang.Integer size()
Get the size of the collection. This is the number of entries it holds.- Returns:
- the size of the collection as an
Integer - See Also:
hasSize()
-
getFillRatio
public java.lang.Double getFillRatio()
Get the ratio to which the collection is filled (for collections which preallocates a certain capacity)- Returns:
- a
Doublebetween 0.0 and 1.0 inclusive - See Also:
hasFillRatio()
-
isEmpty
public java.lang.Boolean isEmpty()
Check if the collection is empty- Returns:
- true if the collection is empty, either
size()is zero or there are no entry ids.
-
extractEntryIds
public int[] extractEntryIds()
Get the object Ids (int) of the contents of the collection- Returns:
- an int[] array of object identifiers
- See Also:
hasExtractableContents()
-
extractEntries
public IObjectArray extractEntries()
Get the array with contents of the collection- Returns:
- an
IObjectArrayholding the objects in the collection - See Also:
hasExtractableContents()
-
getRetainedHeapSize
public long getRetainedHeapSize()
Description copied from interface:IObjectGet retained heap size of this object.- Specified by:
getRetainedHeapSizein interfaceIObject- Returns:
- retained heap size of this object (returns 0 if the dominator tree wasn't calculated for the corresponding snapshot)
-
getUsedHeapSize
public long getUsedHeapSize()
Description copied from interface:IObjectGet used heap size of just this object.- Specified by:
getUsedHeapSizein interfaceIObject- Returns:
- used heap size of this object
-
getObjectId
public int getObjectId()
Description copied from interface:IObjectGet id for the snapshot object. The id is not the address, but an internally assigned number fitting into anint(this helps reducing the memory footprint of the snapshot considerably - addresses are only used for visualization purposes).- Specified by:
getObjectIdin interfaceIObject- Returns:
- id for the snapshot object
-
getObjectAddress
public long getObjectAddress()
Description copied from interface:IObjectGet address for the snapshot object. This is the address at which the object was stored in memory. Use the address only for visualization purposes and try to use the id wherever possible as the snapshot API is optimized to handle ids and not addresses. Addresses are bigger (long), have no consecutive order (with gaps), and are not used for hashing.- Specified by:
getObjectAddressin interfaceIObject- Returns:
- address for the snapshot object
-
getClazz
public IClass getClazz()
Description copied from interface:IObjectGet class snapshot object this object is an instance of.
-
getTechnicalName
public java.lang.String getTechnicalName()
Description copied from interface:IObjectGet technical name of this object which is something like class@address.- Specified by:
getTechnicalNamein interfaceIObject- Returns:
- technical name of this object which is something like class@address
-
getClassSpecificName
public java.lang.String getClassSpecificName()
Description copied from interface:IObjectGet class specific name of this object which depends on the availability of the appropriate name resolver, e.g. for a String the value of the char[].- Specified by:
getClassSpecificNamein interfaceIObject- Returns:
- class specific name of the given snapshot object or null if it can't be resolved
-
getDisplayName
public java.lang.String getDisplayName()
Description copied from interface:IObjectGet concatenation ofIObject.getTechnicalName()andIObject.getClassSpecificName().- Specified by:
getDisplayNamein interfaceIObject- Returns:
- concatenation of
IObject.getTechnicalName()andIObject.getClassSpecificName()
-
getOutboundReferences
public java.util.List<NamedReference> getOutboundReferences()
Description copied from interface:IObjectGet list of snapshot objects referenced from this snapshot object with the name of the field over which it was referenced.- Specified by:
getOutboundReferencesin interfaceIObject- Returns:
- list of snapshot objects referenced from this snapshot object with the name of the field over which it was referenced
-
resolveValue
public java.lang.Object resolveValue(java.lang.String field) throws SnapshotExceptionDescription copied from interface:IObjectResolves and returns the value of a field specified by a dot notation. If the field is a primitive type, the value the returns the corresponding object wrapper, e.g. a java.lang.Boolean is returned for a field of type boolean. If the field is an object reference, the corresponding IObject is returned.The field can be specified using the dot notation, i.e. object references are followed and its fields are evaluated. If any of the object references is null, null is returned.
- Specified by:
resolveValuein interfaceIObject- Parameters:
field- the field name in dot notation- Returns:
- the value of the field
- Throws:
SnapshotException- when there is a problem retrieving the field
-
getGCRootInfo
public GCRootInfo[] getGCRootInfo() throws SnapshotException
Description copied from interface:IObjectGetGCRootInfoif the object is a garbage collection root or null otherwise. An object may or may not be a garbage collection root, it may even be one for multiple reasons (described in theGCRootInfoobject).- Specified by:
getGCRootInfoin interfaceIObject- Returns:
GCRootInfoif the object is a garbage collection root or null otherwise- Throws:
SnapshotException- when there is a problem retrieving the information
-
getSnapshot
public ISnapshot getSnapshot()
Description copied from interface:IObjectReturns the snapshot from which this object has been read.- Specified by:
getSnapshotin interfaceIObject- Returns:
- the snapshot from which this object has been read.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-