Package db

# Interface Buffer

All Known Implementing Classes:
  `ChainedBuffer`, `DataBuffer`

public interface Buffer
`Buffer` provides a general purpose storage buffer interface providing various data access methods.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `get(int offset, byte[] bytes)`
  Get the byte data located at the specified offset and store into the bytes array provided.
  `void`
  `get(int offset, byte[] data, int dataOffset, int length)`
  Get the byte data located at the specified offset and store into the data array at the specified data offset.
  `byte[]`
  `get(int offset, int length)`
  Get the byte data located at the specified offset.
  `byte`
  `getByte(int offset)`
  Get the 8-bit byte value located at the specified offset.
  `int`
  `getId()`
  Get the buffer ID for this buffer.
  `int`
  `getInt(int offset)`
  Get the 32-bit integer value located at the specified offset.
  `long`
  `getLong(int offset)`
  Get the 64-bit long value located at the specified offset.
  `short`
  `getShort(int offset)`
  Get the 16-bit short value located at the specified offset.
  `int`
  `length()`
  Get the length of the buffer in bytes.
  `int`
  `put(int offset, byte[] bytes)`
  Put the bytes provided into the buffer at the specified offset.
  `int`
  `put(int offset, byte[] data, int dataOffset, int length)`
  Put a specified number of bytes from the array provided into the buffer at the specified offset.
  `int`
  `putByte(int offset, byte b)`
  Put the 8-bit byte value into the buffer at the specified offset.
  `int`
  `putInt(int offset, int v)`
  Put the 32-bit integer value into the buffer at the specified offset.
  `int`
  `putLong(int offset, long v)`
  Put the 64-bit long value into the buffer at the specified offset.
  `int`
  `putShort(int offset, short v)`
  Put the 16-bit short value into the buffer at the specified offset.

- ## Method Details

  - ### getId

    int getId()
    Get the buffer ID for this buffer.
    Returns:
      int

  - ### length

    int length()
    Get the length of the buffer in bytes. The length reflects the number of bytes which have been allocated to the buffer.
    Returns:
      length of allocated buffer.

  - ### get

    void get(int offset, byte[] bytes) throws IndexOutOfBoundsException, IOException
    Get the byte data located at the specified offset and store into the bytes array provided.
    Parameters:
      `offset` - byte offset from start of buffer.
      `bytes` - byte array to store data
    Throws:
      `IndexOutOfBoundsException` - is thrown if an invalid offset is specified.
      `IOException` - is thrown if an error occurs while accessing the underlying storage.

  - ### get

    void get(int offset, byte[] data, int dataOffset, int length) throws IndexOutOfBoundsException, IOException
    Get the byte data located at the specified offset and store into the data array at the specified data offset.
    Parameters:
      `offset` - byte offset from the start of the buffer.
      `data` - byte array to store the data.
      `dataOffset` - offset into the data buffer
      `length` - amount of data to read
    Throws:
      `IndexOutOfBoundsException` - if an invalid offset, dataOffset, or length is specified.
      `IOException` - is thrown if an error occurs while accessing the underlying storage.

  - ### get

    byte[] get(int offset, int length) throws IndexOutOfBoundsException, IOException
    Get the byte data located at the specified offset.
    Parameters:
      `offset` - byte offset from start of buffer.
      `length` - number of bytes to be read and returned
    Returns:
      the byte array.
    Throws:
      `IndexOutOfBoundsException` - is thrown if an invalid offset is specified or the end of the buffer was encountered while reading the data.
      `IOException` - is thrown if an error occurs while accessing the underlying storage.

  - ### getByte

    byte getByte(int offset) throws IndexOutOfBoundsException, IOException
    Get the 8-bit byte value located at the specified offset.
    Parameters:
      `offset` - byte offset from start of buffer.
    Returns:
      the byte value at the specified offset.
    Throws:
      `IndexOutOfBoundsException` - is thrown if an invalid offset is specified.
      `IOException` - is thrown if an error occurs while accessing the underlying storage.

  - ### getInt

    int getInt(int offset) throws IndexOutOfBoundsException, IOException
    Get the 32-bit integer value located at the specified offset.
    Parameters:
      `offset` - byte offset from start of buffer.
    Returns:
      the integer value at the specified offset.
    Throws:
      `IndexOutOfBoundsException` - is thrown if an invalid offset is specified or the end of the buffer was encountered while reading the value.
      `IOException` - is thrown if an error occurs while accessing the underlying storage.

  - ### getShort

    short getShort(int offset) throws IndexOutOfBoundsException, IOException
    Get the 16-bit short value located at the specified offset.
    Parameters:
      `offset` - byte offset from start of buffer.
    Returns:
      the short value at the specified offset.
    Throws:
      `IndexOutOfBoundsException` - is thrown if an invalid offset is specified or the end of the buffer was encountered while reading the value.
      `IOException` - is thrown if an error occurs while accessing the underlying storage.

  - ### getLong

    long getLong(int offset) throws IndexOutOfBoundsException, IOException
    Get the 64-bit long value located at the specified offset.
    Parameters:
      `offset` - byte offset from start of buffer.
    Returns:
      the long value at the specified offset.
    Throws:
      `IndexOutOfBoundsException` - is thrown if an invalid offset is specified or the end of the buffer was encountered while reading the value.
      `IOException` - is thrown if an error occurs while accessing the underlying storage.

  - ### put

    int put(int offset, byte[] data, int dataOffset, int length) throws IndexOutOfBoundsException, IOException
    Put a specified number of bytes from the array provided into the buffer at the specified offset. The number of bytes stored is specified by the length specified.
    Parameters:
      `offset` - byte offset from start of buffer.
      `data` - the byte data to be stored.
      `dataOffset` - the starting offset into the data.
      `length` - the number of bytes to be stored.
    Returns:
      the next available offset into the buffer, or -1 if the buffer is full.
    Throws:
      `IndexOutOfBoundsException` - if an invalid offset is provided or the end of buffer was encountered while storing the data.
      `IOException` - is thrown if an error occurs while accessing the underlying storage.

  - ### put

    int put(int offset, byte[] bytes) throws IndexOutOfBoundsException, IOException
    Put the bytes provided into the buffer at the specified offset. The number of bytes stored is determined by the length of the bytes array.
    Parameters:
      `offset` - byte offset from start of buffer.
      `bytes` - the byte data to be stored.
    Returns:
      the next available offset into the buffer, or -1 if the buffer is full.
    Throws:
      `IndexOutOfBoundsException` - if an invalid offset is provided or the end of buffer was encountered while storing the data.
      `IOException` - is thrown if an error occurs while accessing the underlying storage.

  - ### putByte

    int putByte(int offset, byte b) throws IndexOutOfBoundsException, IOException
    Put the 8-bit byte value into the buffer at the specified offset.
    Parameters:
      `offset` - byte offset from start of buffer.
      `b` - the byte value to be stored.
    Returns:
      the next available offset into the buffer, or -1 if the buffer is full.
    Throws:
      `IndexOutOfBoundsException` - if an invalid offset is provided.
      `IOException` - is thrown if an error occurs while accessing the underlying storage.

  - ### putInt

    int putInt(int offset, int v) throws IndexOutOfBoundsException, IOException
    Put the 32-bit integer value into the buffer at the specified offset.
    Parameters:
      `offset` - byte offset from start of buffer.
      `v` - the integer value to be stored.
    Returns:
      the next available offset into the buffer, or -1 if the buffer is full.
    Throws:
      `IndexOutOfBoundsException` - if an invalid offset is provided or the end of buffer was encountered while storing the data.
      `IOException` - is thrown if an error occurs while accessing the underlying storage.

  - ### putShort

    int putShort(int offset, short v) throws IndexOutOfBoundsException, IOException
    Put the 16-bit short value into the buffer at the specified offset.
    Parameters:
      `offset` - byte offset from start of buffer.
      `v` - the short value to be stored.
    Returns:
      the next available offset into the buffer, or -1 if the buffer is full.
    Throws:
      `IndexOutOfBoundsException` - if an invalid offset is provided or the end of buffer was encountered while storing the data.
      `IOException` - is thrown if an error occurs while accessing the underlying storage.

  - ### putLong

    int putLong(int offset, long v) throws IndexOutOfBoundsException, IOException
    Put the 64-bit long value into the buffer at the specified offset.
    Parameters:
      `offset` - byte offset from start of buffer.
      `v` - the long value to be stored.
    Returns:
      the next available offset into the buffer, or -1 if the buffer is full.
    Throws:
      `IndexOutOfBoundsException` - if an invalid offset is provided or the end of buffer was encountered while storing the data.
      `IOException` - is thrown if an error occurs while accessing the underlying storage.