Package ej.bon
Class ResourceArray
- java.lang.Object
-
- ej.bon.ResourceArray
-
public class ResourceArray extends Object
A resource array is an element ofResourceBuffer. It holds a set of data.The data size in bytes is the same for all elements (aligned on bigger encoded element). Each element data is aligned in memory on element size: 4 bytes for 32-bits values and 2 bytes for 16-bits values. The
ResourceBufferencoder ensures the array is aligned too (using the same rule).
-
-
Constructor Summary
Constructors Constructor Description ResourceArray()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intelementAt(int index)Reads the element at given index.int[]elements()Reads all array elements.ResourceBuffergetBuffer()Returns theResourceBufferused to create theResourceArray.intlength()Gets the number of elements contained in the array (not the size in bytes).ResourceBufferseekToElementPointer(int index)Modify the position of theResourceBufferused to create thisResourceArray.
-
-
-
Method Detail
-
getBuffer
public ResourceBuffer getBuffer()
Returns theResourceBufferused to create theResourceArray.- Returns:
- the
ResourceBuffer
-
length
public int length()
Gets the number of elements contained in the array (not the size in bytes).- Returns:
- the available number of elements
-
elementAt
public int elementAt(int index) throws IOExceptionReads the element at given index.- Parameters:
index- the element index- Returns:
- the element read
- Throws:
IOException- if an I/O error occurs.IndexOutOfBoundsException- when the index is negative or higher or equal thanlength().
-
elements
public int[] elements() throws IOExceptionReads all array elements.- Returns:
- the elements read.
- Throws:
IOException- if an I/O error occurs.
-
seekToElementPointer
public ResourceBuffer seekToElementPointer(int index) throws IOException
Modify the position of theResourceBufferused to create thisResourceArray. Updates its position to point on the element defined at the given index.- Parameters:
index- theResourceBufferoffset pointer- Returns:
- the
ResourceBufferused to create theResourceArray. - Throws:
IOException- if an I/O error occurs.IndexOutOfBoundsException- when the index is negative or higher or equal thanlength().
-
-