Package ej.bon

## Class ResourceArray

- java.lang.Object
- - ej.bon.ResourceArray

-     public class ResourceArray
      extends Object

  A resource array is an element of `ResourceBuffer`. 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 `ResourceBuffer` encoder 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
    --- | --- | ---
    `int` | `elementAt​(int index)` | Reads the element at given index.
    `int[]` | `elements()` | Reads all array elements.
    `ResourceBuffer` | `getBuffer()` | Returns the `ResourceBuffer` used to create the `ResourceArray`.
    `int` | `length()` | Gets the number of elements contained in the array (not the size in bytes).
    `ResourceBuffer` | `seekToElementPointer​(int index)` | Modify the position of the `ResourceBuffer` used to create this `ResourceArray`.

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

      `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ResourceArray

          public ResourceArray()

  - ### Method Detail

    - #### getBuffer

          public ResourceBuffer getBuffer()

      Returns the `ResourceBuffer` used to create the `ResourceArray`.
      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 IOException

      Reads 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 than `length()`.

    - #### elements

          public int[] elements()
                         throws IOException

      Reads 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 the `ResourceBuffer` used to create this `ResourceArray`. Updates its position to point on the element defined at the given index.
      Parameters:
        `index` - the `ResourceBuffer` offset pointer
      Returns:
        the `ResourceBuffer` used to create the `ResourceArray`.
      Throws:
        `IOException` - if an I/O error occurs.
        `IndexOutOfBoundsException` - when the index is negative or higher or equal than `length()`.