Package org.eclipse.mat.parser.model

## Class PrimitiveArrayImpl

- java.lang.Object
- - org.eclipse.mat.parser.model.AbstractObjectImpl
  - - org.eclipse.mat.parser.model.AbstractArrayImpl
    - - org.eclipse.mat.parser.model.PrimitiveArrayImpl

All Implemented Interfaces:
  `java.io.Serializable`, `IArray`, `IObject`, `IPrimitiveArray`

    public class PrimitiveArrayImpl
    extends AbstractArrayImpl
    implements IPrimitiveArray

Implementation of a primitive array of type byte[], short[], int[], long[], boolean, char[], float[], double[].

See Also:
  Serialized Form
No Extend:

### Nested Class Summary

### Nested classes/interfaces inherited from interface org.eclipse.mat.snapshot.model.IObject

`IObject.Type`

### Field Summary

### Fields inherited from interface org.eclipse.mat.snapshot.model.IPrimitiveArray

`COMPONENT_TYPE, ELEMENT_SIZE, SIGNATURES, TYPE`

### Constructor Summary

Constructors
`PrimitiveArrayImpl​(int objectId, long address, ClassImpl classInstance, int length, int type)` Constructs a primitive array

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`static long` `doGetUsedHeapSize​(ClassImpl clazz, int length, int type)` Calculates the size of a primitive array
`java.lang.Class<?>` `getComponentType()` Returns the component type of the array.
`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.
`ArrayLong` `getReferences()` Gets the outbound references from this object, as addresses.
`int` `getType()` Returns the `IObject.Type` of the primitive array.
`long` `getUsedHeapSize()` Get used heap size of just this object.
`java.lang.Object` `getValueArray()` Get the primitive Java array.
`java.lang.Object` `getValueArray​(int offset, int length)` Get the primitive Java array, beginning at `offset` and `length` number of elements.
`java.lang.Object` `getValueAt​(int index)` Returns the value of the array at the specified index

### Methods inherited from class org.eclipse.mat.parser.model.AbstractArrayImpl

`getInfo, getLength, getObjectAddress, getObjectId, getTechnicalName, setInfo, setLength`

### Methods inherited from class org.eclipse.mat.parser.model.AbstractObjectImpl

`equals, getClassAddress, getClassId, getClassSpecificName, getClazz, getComparatorForClassSpecificName, getComparatorForTechnicalName, getComparatorForUsedHeapSize, getDisplayName, getGCRootInfo, getRetainedHeapSize, getSnapshot, hashCode, resolveValue, setClassInstance, setObjectAddress, setObjectId, setSnapshot, toString`

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

`getClass, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface org.eclipse.mat.snapshot.model.IArray

`getLength`

### Methods inherited from interface org.eclipse.mat.snapshot.model.IObject

`getClassSpecificName, getClazz, getDisplayName, getGCRootInfo, getObjectAddress, getObjectId, getRetainedHeapSize, getSnapshot, getTechnicalName, resolveValue`

### Constructor Detail

#### PrimitiveArrayImpl

    public PrimitiveArrayImpl​(int objectId,
                              long address,
                              ClassImpl classInstance,
                              int length,
                              int type)

Constructs a primitive array

Parameters:
  `objectId` - the id of the array
  `address` - the address of the array
  `classInstance` - the type (class) of the array
  `length` - the length in elements
  `type` - the actual type `IObject.Type`

### Method Detail

#### getType

    public int getType()

Description copied from interface: `IPrimitiveArray`
Returns the `IObject.Type` of the primitive array.

Specified by:
  `getType` in interface `IPrimitiveArray`
Returns:
  the type

#### getComponentType

    public java.lang.Class<?> getComponentType()

Description copied from interface: `IPrimitiveArray`
Returns the component type of the array.

Specified by:
  `getComponentType` in interface `IPrimitiveArray`
Returns:
  the Java class of the component type

#### getValueAt

    public java.lang.Object getValueAt​(int index)

Description copied from interface: `IPrimitiveArray`
Returns the value of the array at the specified index

Specified by:
  `getValueAt` in interface `IPrimitiveArray`
Parameters:
  `index` - from 0 to length-1
Returns:
  Byte - for a byte array Short - for a short array Integer - for an int array Long - for a long array Boolean - for a boolean array Char - for a char array Float - for a float array Double - for a double array

#### getValueArray

    public java.lang.Object getValueArray()

Description copied from interface: `IPrimitiveArray`
Get the primitive Java array. The return value can be cast into the correct component type, e.g.

     if (char.class == array.getComponentType())
     {
         char[] content = (char[]) array.getValueArray();
         System.out.println(content.length);
     }

The return value must not be modified because it is cached by the heap dump adapter. This method does not return a copy of the array for performance reasons.

Specified by:
  `getValueArray` in interface `IPrimitiveArray`
Returns:
  the contents of the primitive array

#### getValueArray

    public java.lang.Object getValueArray​(int offset,
                                          int length)

Description copied from interface: `IPrimitiveArray`
Get the primitive Java array, beginning at `offset` and `length` number of elements.

The return value must not be modified because it is cached by the heap dump adapter. This method does not return a copy of the array for performance reasons.

Specified by:
  `getValueArray` in interface `IPrimitiveArray`
Parameters:
  `offset` - the starting index
  `length` - the number of entries
Returns:
  the contents of the primitive array starting at the index for length entries

#### getReferences

    public ArrayLong getReferences()

Description copied from class: `AbstractObjectImpl`
Gets the outbound references from this object, as addresses.

Specified by:
  `getReferences` in class `AbstractObjectImpl`
Returns:
  a list of outbound references

#### getOutboundReferences

    public java.util.List<NamedReference> getOutboundReferences()

Description copied from interface: `IObject`
Get list of snapshot objects referenced from this snapshot object with the name of the field over which it was referenced.

Specified by:
  `getOutboundReferences` in interface `IObject`
Returns:
  list of snapshot objects referenced from this snapshot object with the name of the field over which it was referenced

#### getUsedHeapSize

    public long getUsedHeapSize()

Description copied from interface: `IObject`
Get used heap size of just this object.

Specified by:
  `getUsedHeapSize` in interface `IObject`
Specified by:
  `getUsedHeapSize` in class `AbstractObjectImpl`
Returns:
  used heap size of this object

#### doGetUsedHeapSize

    public static long doGetUsedHeapSize​(ClassImpl clazz,
                                         int length,
                                         int type)

Calculates the size of a primitive array

Parameters:
  `clazz` - the type
  `length` - the length in elements
  `type` - the actual type `IObject.Type`
Returns:
  the size in bytes
Since:
  1.0