com.io7m.jpra.runtime.java

## Class JPRACursor2DByteBufferedChecked<T extends JPRAValueType>

- java.lang.Object
- - com.io7m.jpra.runtime.java.JPRACursor2DByteBufferedChecked<T>

- Type Parameters:
    `T` - The type of addressed values
  All Implemented Interfaces:
    JPRACursor2DType<T>, JPRACursorByteReadableType, JPRACursorType<T>

      public final class JPRACursor2DByteBufferedChecked<T extends JPRAValueType>
      extends Object
      implements JPRACursor2DType<T>

  A 2D cursor implementation that addresses values within a `ByteBuffer` and performs bounds checking.

- - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `AtomicLong` | `getByteOffsetObservable()`
    `T` | `getElementView()`
    `int` | `getElementX()`
    `int` | `getElementY()`
    `static <T extends JPRAValueType> JPRACursor2DType<T>` | `newCursor(ByteBuffer in_buffer, int width, int height, JPRAValueByteBufferedConstructorType<T> in_cons)` Construct a new cursor, assuming that the given buffer contains a `width * height` region of elements of type `T`.
    `void` | `setElementPosition(int in_x, int in_y)` Point the cursor at element `(x, y)` of the array.
    `String` | `toString()`

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

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

- - ### Method Detail

    - #### newCursor

          public static <T extends JPRAValueType> JPRACursor2DType<T> newCursor(ByteBuffer in_buffer,
                                                                                int width,
                                                                                int height,
                                                                                JPRAValueByteBufferedConstructorType<T> in_cons)

      Construct a new cursor, assuming that the given buffer contains a `width * height` region of elements of type `T`.
      Type Parameters:
        `T` - The precise type of elements
      Parameters:
        `in_buffer` - The byte buffer
        `width` - The width of the region
        `height` - The height of the region
        `in_cons` - An element value constructor
      Returns:
        A new cursor

    - #### getElementView

          public T getElementView()

      Specified by:
        `getElementView` in interface `JPRACursorType<T extends JPRAValueType>`
      Returns:
        A view of the current element, updated whenever the cursor position changes

    - #### getByteOffsetObservable

          public AtomicLong getByteOffsetObservable()

      Specified by:
        `getByteOffsetObservable` in interface `JPRACursorByteReadableType`
      Returns:
        The current byte offset

    - #### getElementX

          public int getElementX()

      Specified by:
        `getElementX` in interface `JPRACursor2DType<T extends JPRAValueType>`
      Returns:
        The current element `x` position

    - #### getElementY

          public int getElementY()

      Specified by:
        `getElementY` in interface `JPRACursor2DType<T extends JPRAValueType>`
      Returns:
        The current element `y` position

    - #### setElementPosition

          public void setElementPosition(int in_x,
                                         int in_y)
                                  throws IndexOutOfBoundsException

      Description copied from interface: `JPRACursor2DType`

      Point the cursor at element `(x, y)` of the array.

      Implementations are permitted to perform bounds checking, and must throw `IndexOutOfBoundsException` on out-of-bounds indices.

      Specified by:
        `setElementPosition` in interface `JPRACursor2DType<T extends JPRAValueType>`
      Parameters:
        `in_x` - The `x` (horizontal, columns) position
        `in_y` - The `y` (vertical, rows) position
      Throws:
        `IndexOutOfBoundsException` - Iff the implementation performs bounds checking and the element is out of range

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright © 2015 <code@io7m.com> http://io7m.com