com.io7m.jpra.runtime.java

## Class JPRAStringCursorByteBuffered

- java.lang.Object
- - com.io7m.jpra.runtime.java.JPRAStringCursorByteBuffered

- All Implemented Interfaces:
    JPRAStringCursorReadableType, JPRAStringCursorType, JPRAStringCursorWritableType

      public final class JPRAStringCursorByteBuffered
      extends Object
      implements JPRAStringCursorType

  An implementation of the `JPRAStringCursorType` that accesses an underlying `ByteBuffer`.

- - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `byte` | `getByte(int index)`
    `void` | `getBytes(byte[] buf, int buf_offset, int length)`
    `Charset` | `getEncoding()`
    `int` | `getMaximumLength()`
    `String` | `getNewValue()`
    `int` | `getUsedLength()`
    `static JPRAStringCursorType` | `newString(ByteBuffer in_buffer, int in_offset, JPRACursorByteReadableType in_cursor, Charset in_encoding, int in_max_length)` Construct a new string pointer.
    `void` | `setValue(String text, JPRAStringTruncation trunc)` Set the string value, optionally truncating data based on `trunc`.

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

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

- - ### Method Detail

    - #### newString

          public static JPRAStringCursorType newString(ByteBuffer in_buffer,
                                                       int in_offset,
                                                       JPRACursorByteReadableType in_cursor,
                                                       Charset in_encoding,
                                                       int in_max_length)

      Construct a new string pointer.
      Parameters:
        `in_buffer` - The byte buffer
        `in_offset` - The offset of this string from the base cursor
        `in_cursor` - The base cursor
        `in_encoding` - The string encoding
        `in_max_length` - The maximum string length
      Returns:
        A new string pointer

    - #### getMaximumLength

          public int getMaximumLength()

      Specified by:
        `getMaximumLength` in interface `JPRAStringCursorReadableType`
      Returns:
        The maximum length of the string in octets

    - #### getUsedLength

          public int getUsedLength()

      Specified by:
        `getUsedLength` in interface `JPRAStringCursorReadableType`
      Returns:
        The number of octets of the string that are actually being used

    - #### getByte

          public byte getByte(int index)
                       throws IndexOutOfBoundsException

      Specified by:
        `getByte` in interface `JPRAStringCursorReadableType`
      Parameters:
        `index` - The byte index
      Returns:
        The byte at index `index` in the string
      Throws:
        `IndexOutOfBoundsException` - Iff `index >= getMaximumLength()`

    - #### getBytes

          public void getBytes(byte[] buf,
                               int buf_offset,
                               int length)
                        throws IndexOutOfBoundsException

      Specified by:
        `getBytes` in interface `JPRAStringCursorReadableType`
      Parameters:
        `buf` - The buffer to which string data will be written
        `buf_offset` - The starting index of `buf` to which data will be written
        `length` - The number of octets to copy into `buf`
      Throws:
        `IndexOutOfBoundsException` - Iff `length > getMaximumLength()`

    - #### getNewValue

          public String getNewValue()

      Specified by:
        `getNewValue` in interface `JPRAStringCursorReadableType`
      Returns:
        A freshly allocated string based on the current contents of the string data

    - #### getEncoding

          public Charset getEncoding()

      Specified by:
        `getEncoding` in interface `JPRAStringCursorReadableType`
      Returns:
        The string encoding

    - #### setValue

          public void setValue(String text,
                               JPRAStringTruncation trunc)

      Description copied from interface: `JPRAStringCursorWritableType`
      Set the string value, optionally truncating data based on `trunc`.
      Specified by:
        `setValue` in interface `JPRAStringCursorWritableType`
      Parameters:
        `text` - The new string value
        `trunc` - The truncation behaviour

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