fr.umlv.corosol.component.impl
Class NativeArray

java.lang.Object
  extended by fr.umlv.corosol.component.impl.NativeArray
All Implemented Interfaces:
JAllocatable, JArray, JHeapObject, JObject

public class NativeArray
extends java.lang.Object
implements JArray

A NativeArray object represents an array not allocated in the Corosol JVM heap.

Author:
Christophe Deleray

Field Summary
 
Fields inherited from interface fr.umlv.corosol.component.JArray
T_BOOLEAN, T_BYTE, T_CHAR, T_DOUBLE, T_FLOAT, T_INT, T_LONG, T_SHORT
 
Constructor Summary
NativeArray(java.lang.Object array)
          Creates a new NativeArray instance initialized with the specified underlaying JVM array.
 
Method Summary
 boolean getBoolean(int index)
          Returns the boolean value stored at the specified index.
 byte getByte(int index)
          Returns the byte value stored at the specified index.
 char getChar(int index)
          Returns the char value stored at the specified index.
 JClass getComponentType()
          Returns the component type of this array.
 double getDouble(int index)
          Returns the double value stored at the specified index.
 float getFloat(int index)
          Returns the float value stored at the specified index.
 int getInt(int index)
          Returns the int value stored at the specified index.
 long getLong(int index)
          Returns the long value stored at the specified index.
 java.lang.Object getNativeObject()
          Returns the object equivalent to this object but which belong to the underlaying Virtual Machine.
 JHeapObject getObject(int index)
          Returns the object whose the reference value is stored at the specified index.
 int getPosition()
          Returns the position of the first byte of the memory allocated for the object representing by this JClassInstance object into the Corosol heap memory.
 short getShort(int index)
          Returns the short value stored at the specified index.
 int getSize()
          Returns the size in bytes of this object into the Corosol memory heap.
 JClass getType()
          Returns the dynamic type of this array.
 boolean isNative()
          Determines if this array is allocated into the underlaying JVM heap and not in the Corosol JVM heap.
 int length()
          Returns the length of this array.
 void setBoolean(boolean value, int index)
          Sets the specified entry with a specified boolean value.
 void setByte(byte value, int index)
          Sets the specified entry with a specified byte value.
 void setChar(char value, int index)
          Sets the specified entry with a specified char value.
 void setDouble(double value, int index)
          Sets the specified entry with a specified double value.
 void setFloat(float value, int index)
          Sets the specified entry with a specified float value.
 void setInt(int value, int index)
          Sets the specified entry with a specified int value.
 void setLayout(JArrayLayout layout)
          Sets the layout of the array representing by this JArray object.
 void setLong(long value, int index)
          Sets the specified entry with a specified long value.
 void setObject(JHeapObject object, int index)
          Sets the specified entry with the reference of the specified object.
 void setPosition(int index)
          Sets the position of the first byte of the memory allocated for the array representing by this JArray object into the Corosol heap memory.
 void setShort(short value, int index)
          Sets the specified entry with a specified short value.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NativeArray

public NativeArray(java.lang.Object array)
Creates a new NativeArray instance initialized with the specified underlaying JVM array.

Parameters:
referenceManager - the reference manager
Method Detail

getNativeObject

public java.lang.Object getNativeObject()
Returns the object equivalent to this object but which belong to the underlaying Virtual Machine.

Specified by:
getNativeObject in interface JHeapObject

length

public int length()
Returns the length of this array.

Specified by:
length in interface JArray

getType

public JClass getType()
Returns the dynamic type of this array.

Specified by:
getType in interface JHeapObject
Returns:
the type of this heap object

getComponentType

public JClass getComponentType()
Returns the component type of this array.

Specified by:
getComponentType in interface JArray

getBoolean

public boolean getBoolean(int index)
Returns the boolean value stored at the specified index.

Specified by:
getBoolean in interface JArray
Parameters:
index - an index of an entry
Returns:
the value stored at the specified index

setBoolean

public void setBoolean(boolean value,
                       int index)
Sets the specified entry with a specified boolean value.

Specified by:
setBoolean in interface JArray
Parameters:
value - the value to be stored
index - an index of an entry

getByte

public byte getByte(int index)
Returns the byte value stored at the specified index.

Specified by:
getByte in interface JArray
Parameters:
index - an index of an entry
Returns:
the value stored at the specified index

setByte

public void setByte(byte value,
                    int index)
Sets the specified entry with a specified byte value.

Specified by:
setByte in interface JArray
Parameters:
value - the value to be stored
index - an index of an entry

getChar

public char getChar(int index)
Returns the char value stored at the specified index.

Specified by:
getChar in interface JArray
Parameters:
index - an index of an entry
Returns:
the value stored at the specified index

setChar

public void setChar(char value,
                    int index)
Sets the specified entry with a specified char value.

Specified by:
setChar in interface JArray
Parameters:
value - the value to be stored
index - an index of an entry

getDouble

public double getDouble(int index)
Returns the double value stored at the specified index.

Specified by:
getDouble in interface JArray
Parameters:
index - an index of an entry
Returns:
the value stored at the specified index

setDouble

public void setDouble(double value,
                      int index)
Sets the specified entry with a specified double value.

Specified by:
setDouble in interface JArray
Parameters:
value - the value to be stored
index - an index of an entry

getFloat

public float getFloat(int index)
Returns the float value stored at the specified index.

Specified by:
getFloat in interface JArray
Parameters:
index - an index of an entry
Returns:
the value stored at the specified index

setFloat

public void setFloat(float value,
                     int index)
Sets the specified entry with a specified float value.

Specified by:
setFloat in interface JArray
Parameters:
value - the value to be stored
index - an index of an entry

getInt

public int getInt(int index)
Returns the int value stored at the specified index.

Specified by:
getInt in interface JArray
Parameters:
index - an index of an entry
Returns:
the value stored at the specified index

setInt

public void setInt(int value,
                   int index)
Sets the specified entry with a specified int value.

Specified by:
setInt in interface JArray
Parameters:
value - the value to be stored
index - an index of an entry

getLong

public long getLong(int index)
Returns the long value stored at the specified index.

Specified by:
getLong in interface JArray
Parameters:
index - an index of an entry
Returns:
the value stored at the specified index

setLong

public void setLong(long value,
                    int index)
Sets the specified entry with a specified long value.

Specified by:
setLong in interface JArray
Parameters:
value - the value to be stored
index - an index of an entry

getShort

public short getShort(int index)
Returns the short value stored at the specified index.

Specified by:
getShort in interface JArray
Parameters:
index - an index of an entry
Returns:
the value stored at the specified index

setShort

public void setShort(short value,
                     int index)
Sets the specified entry with a specified short value.

Specified by:
setShort in interface JArray
Parameters:
value - the value to be stored
index - an index of an entry

getObject

public JHeapObject getObject(int index)
Returns the object whose the reference value is stored at the specified index.

Specified by:
getObject in interface JArray
Parameters:
index - an index of an entry
Returns:
the object whose the reference value is stored at the specified index

setObject

public void setObject(JHeapObject object,
                      int index)
Sets the specified entry with the reference of the specified object.

Specified by:
setObject in interface JArray
Parameters:
object - the object whose the reference value will be stored
index - an index of an entry

isNative

public boolean isNative()
Determines if this array is allocated into the underlaying JVM heap and not in the Corosol JVM heap.

Specified by:
isNative in interface JHeapObject
Returns:
true if this array is allocated into the underlaying JVM heap; false otherwise.

setLayout

public void setLayout(JArrayLayout layout)
Sets the layout of the array representing by this JArray object. layout describes the relative position of each entry of this array into the memory allocated for it. This method does nothing because a NativeJArray object represents an array not physically allocated into the Corosol heap memory.

Specified by:
setLayout in interface JArray
Parameters:
layout - the layout describing the entry positions of this array

getPosition

public int getPosition()
Returns the position of the first byte of the memory allocated for the object representing by this JClassInstance object into the Corosol heap memory. This method should not be called because a NativeArray object represents an array not physically allocated into the Corosol heap memory.

Specified by:
getPosition in interface JAllocatable
Returns:
the position of the first byte of the memory allocated for this object into the Corosol heap memory

setPosition

public void setPosition(int index)
Sets the position of the first byte of the memory allocated for the array representing by this JArray object into the Corosol heap memory. This method does nothing because a NativeJArray object represents an array not physically allocated into the Corosol heap memory.

Specified by:
setPosition in interface JAllocatable
Parameters:
index - the position of the first byte of the memory allocated for this array into the Corosol heap memory.

getSize

public int getSize()
Returns the size in bytes of this object into the Corosol memory heap. This method returns 0 because a NativeJArray object represents an array not physically allocated into the Corosol heap memory.

Specified by:
getSize in interface JAllocatable