Class ArrayInstance
- java.lang.Object
-
- com.tonic.analysis.execution.heap.ObjectInstance
-
- com.tonic.analysis.execution.heap.ArrayInstance
-
public class ArrayInstance extends ObjectInstance
A heap-allocated array with typed primitive or reference backing storage.
-
-
Constructor Summary
Constructors Constructor Description ArrayInstance(int id, String componentType, int length)Allocates an array with zeroed storage matching the component type.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Objectget(int index)Reads an element as a boxed value or reference.booleangetBoolean(int index)Reads a boolean element.bytegetByte(int index)Reads a byte element.chargetChar(int index)Reads a char element.StringgetComponentType()doublegetDouble(int index)Reads a double element.floatgetFloat(int index)Reads a float element.intgetInt(int index)Reads an int element.intgetLength()longgetLong(int index)Reads a long element.shortgetShort(int index)Reads a short element.booleanisPrimitiveArray()voidset(int index, Object value)Writes an element, unboxing to the storage type as needed.voidsetBoolean(int index, boolean value)Writes a boolean element.voidsetByte(int index, byte value)Writes a byte element.voidsetChar(int index, char value)Writes a char element.voidsetDouble(int index, double value)Writes a double element.voidsetFloat(int index, float value)Writes a float element.voidsetInt(int index, int value)Writes an int element.voidsetLong(int index, long value)Writes a long element.voidsetShort(int index, short value)Writes a short element.StringtoString()-
Methods inherited from class com.tonic.analysis.execution.heap.ObjectInstance
getClassName, getField, getId, getIdentityHashCode, hashCode, isInstanceOf, setClassResolver, setField
-
-
-
-
Constructor Detail
-
ArrayInstance
public ArrayInstance(int id, String componentType, int length)Allocates an array with zeroed storage matching the component type.- Parameters:
id- the heap object idcomponentType- descriptor of the element typelength- the number of elements- Throws:
HeapException- if the length is negative
-
-
Method Detail
-
getLength
public int getLength()
- Returns:
- the length
-
getComponentType
public String getComponentType()
- Returns:
- the component type
-
isPrimitiveArray
public boolean isPrimitiveArray()
- Returns:
- whether primitive array
-
get
public Object get(int index)
Reads an element as a boxed value or reference.- Parameters:
index- the element index- Returns:
- the element value
- Throws:
HeapException- if the index is out of bounds
-
set
public void set(int index, Object value)Writes an element, unboxing to the storage type as needed.- Parameters:
index- the element indexvalue- the value to store- Throws:
HeapException- if the index is out of bounds
-
getInt
public int getInt(int index)
Reads an int element.- Parameters:
index- the element index- Returns:
- the element value
- Throws:
HeapException- if out of bounds or the storage is not int[]
-
setInt
public void setInt(int index, int value)Writes an int element.- Parameters:
index- the element indexvalue- the value to store- Throws:
HeapException- if out of bounds or the storage is not int[]
-
getLong
public long getLong(int index)
Reads a long element.- Parameters:
index- the element index- Returns:
- the element value
- Throws:
HeapException- if out of bounds or the storage is not long[]
-
setLong
public void setLong(int index, long value)Writes a long element.- Parameters:
index- the element indexvalue- the value to store- Throws:
HeapException- if out of bounds or the storage is not long[]
-
getBoolean
public boolean getBoolean(int index)
Reads a boolean element.- Parameters:
index- the element index- Returns:
- the element value
- Throws:
HeapException- if out of bounds or the storage is not boolean[]
-
setBoolean
public void setBoolean(int index, boolean value)Writes a boolean element.- Parameters:
index- the element indexvalue- the value to store- Throws:
HeapException- if out of bounds or the storage is not boolean[]
-
getByte
public byte getByte(int index)
Reads a byte element.- Parameters:
index- the element index- Returns:
- the element value
- Throws:
HeapException- if out of bounds or the storage is not byte[]
-
setByte
public void setByte(int index, byte value)Writes a byte element.- Parameters:
index- the element indexvalue- the value to store- Throws:
HeapException- if out of bounds or the storage is not byte[]
-
getChar
public char getChar(int index)
Reads a char element.- Parameters:
index- the element index- Returns:
- the element value
- Throws:
HeapException- if out of bounds or the storage is not char[]
-
setChar
public void setChar(int index, char value)Writes a char element.- Parameters:
index- the element indexvalue- the value to store- Throws:
HeapException- if out of bounds or the storage is not char[]
-
getShort
public short getShort(int index)
Reads a short element.- Parameters:
index- the element index- Returns:
- the element value
- Throws:
HeapException- if out of bounds or the storage is not short[]
-
setShort
public void setShort(int index, short value)Writes a short element.- Parameters:
index- the element indexvalue- the value to store- Throws:
HeapException- if out of bounds or the storage is not short[]
-
getFloat
public float getFloat(int index)
Reads a float element.- Parameters:
index- the element index- Returns:
- the element value
- Throws:
HeapException- if out of bounds or the storage is not float[]
-
setFloat
public void setFloat(int index, float value)Writes a float element.- Parameters:
index- the element indexvalue- the value to store- Throws:
HeapException- if out of bounds or the storage is not float[]
-
getDouble
public double getDouble(int index)
Reads a double element.- Parameters:
index- the element index- Returns:
- the element value
- Throws:
HeapException- if out of bounds or the storage is not double[]
-
setDouble
public void setDouble(int index, double value)Writes a double element.- Parameters:
index- the element indexvalue- the value to store- Throws:
HeapException- if out of bounds or the storage is not double[]
-
toString
public String toString()
- Overrides:
toStringin classObjectInstance
-
-