Interface ProtonBufferAccessors

All Known Subinterfaces:
ProtonBuffer, ProtonCompositeBuffer
All Known Implementing Classes:
Netty4ToProtonBufferAdapter, Netty5ToProtonBufferAdapter, ProtonByteArrayBuffer, ProtonCompositeBufferImpl

public interface ProtonBufferAccessors
Interface for any buffer access implementation which provides consistent read and write APIs for primitive values. These APIs are useful for serialization and de-serialization APIs which need to write at a primitive level.
  • Method Summary

    Modifier and Type
    Method
    Description
    default boolean
    getBoolean(int index)
    Reads a single byte at the given index and returns it as a boolean value, without modification to the target buffer read offset.
    byte
    getByte(int index)
    Reads a single byte at the given index and returns it without modification to the target buffer read offset.
    char
    getChar(int index)
    Gets a 2-byte char from the specified index, this method will not modify the read or write index.
    default double
    getDouble(int index)
    Gets a double from the specified index, this method will not modify the read or write index.
    default float
    getFloat(int index)
    Gets a float from the specified index, this method will not modify the read or write index.
    int
    getInt(int index)
    Gets a int from the specified index, this method will not modify the read or write index.
    long
    getLong(int index)
    Gets a long from the specified index, this method will not modify the read or write index.
    short
    getShort(int index)
    Gets a short from the specified index, this method will not modify the read or write index.
    default int
    getUnsignedByte(int index)
    Gets a unsigned byte from the specified index, this method will not modify the read or write index.
    default long
    getUnsignedInt(int index)
    Gets a unsigned int from the specified index, this method will not modify the read or write index.
    default int
    getUnsignedShort(int index)
    Gets a unsigned short from the specified index, this method will not modify the read or write index.
    default boolean
    Reads a boolean value from the buffer and advances the read index by one.
    byte
    Reads one byte from the buffer and advances the read index by one.
    char
    Reads a character value from the buffer and advances the read index by four.
    default double
    Reads a double value from the buffer and advances the read index by eight.
    default float
    Reads a float value from the buffer and advances the read index by four.
    int
    Reads a integer value from the buffer and advances the read index by four.
    long
    Reads a long value from the buffer and advances the read index by eight.
    short
    Reads a short value from the buffer and advances the read index by two.
    default int
    Reads one byte from the buffer and advances the read index by one.
    default long
    Reads a unsigned integer value from the buffer and advances the read index by four.
    default int
    Reads an integer value from the buffer that represent the unsigned value of the short and advances the read index by two.
    default ProtonBuffer
    setBoolean(int index, boolean value)
    Sets the boolean value at the given write index in this buffer's backing data store.
    setByte(int index, byte value)
    Sets the byte value at the given write index in this buffer's backing data store.
    setChar(int index, char value)
    Sets the char value at the given write index in this buffer's backing data store.
    default ProtonBuffer
    setDouble(int index, double value)
    Sets the double value at the given write index in this buffer's backing data store.
    default ProtonBuffer
    setFloat(int index, float value)
    Sets the float value at the given write index in this buffer's backing data store.
    setInt(int index, int value)
    Sets the int value at the given write index in this buffer's backing data store.
    setLong(int index, long value)
    Sets the long value at the given write index in this buffer's backing data store.
    setShort(int index, short value)
    Sets the short value at the given write index in this buffer's backing data store.
    default ProtonBuffer
    setUnsignedByte(int index, int value)
    Sets the unsigned byte value at the given write index in this buffer's backing data store.
    default ProtonBuffer
    setUnsignedInt(int index, long value)
    Sets the long value at the given write index in this buffer's backing data store.
    default ProtonBuffer
    setUnsignedShort(int index, int value)
    Sets the short value at the given write index in this buffer's backing data store.
    default ProtonBuffer
    writeBoolean(boolean value)
    Writes a single boolean to the buffer and advances the write index by one.
    writeByte(byte value)
    Writes a single byte to the buffer and advances the write index by one.
    writeChar(char value)
    Writes a single character to the buffer and advances the write index by four.
    default ProtonBuffer
    writeDouble(double value)
    Writes a single double to the buffer and advances the write index by eight.
    default ProtonBuffer
    writeFloat(float value)
    Writes a single float to the buffer and advances the write index by four.
    writeInt(int value)
    Writes a single integer to the buffer and advances the write index by four.
    writeLong(long value)
    Writes a single long to the buffer and advances the write index by eight.
    writeShort(short value)
    Writes a single short to the buffer and advances the write index by two.
    default ProtonBuffer
    writeUnsignedByte(int value)
    Writes a single byte to the buffer and advances the write index by one.
    default ProtonBuffer
    writeUnsignedInt(long value)
    Writes a single unsigned int to the buffer and advances the write index by four.
    default ProtonBuffer
    writeUnsignedShort(int value)
    Writes a single short to the buffer using the input integer value and advances the write index by two.
  • Method Details

    • getByte

      byte getByte(int index)
      Reads a single byte at the given index and returns it without modification to the target buffer read offset.
      Parameters:
      index - The index into the buffer where the value should be read.
      Returns:
      the value read from the given index.
      Throws:
      IndexOutOfBoundsException - if the index is negative or past the current buffer capacity.
    • setByte

      ProtonBuffer setByte(int index, byte value)
      Sets the byte value at the given write index in this buffer's backing data store.
      Parameters:
      index - The index to start the write from.
      value - The value to write at the given index.
      Returns:
      a reference to this ProtonBuffer for chaining.
      Throws:
      IndexOutOfBoundsException - if the index is negative or the write would exceed capacity.
    • readByte

      byte readByte()
      Reads one byte from the buffer and advances the read index by one.
      Returns:
      a single byte from the ProtonBuffer.
      Throws:
      IndexOutOfBoundsException - if there is no readable bytes left in the buffer.
    • writeByte

      ProtonBuffer writeByte(byte value)
      Writes a single byte to the buffer and advances the write index by one.
      Parameters:
      value - The byte to write into the buffer.
      Returns:
      this ProtonBuffer for chaining.
      Throws:
      IndexOutOfBoundsException - if there is no room in the buffer for this write operation.
    • getBoolean

      default boolean getBoolean(int index)
      Reads a single byte at the given index and returns it as a boolean value, without modification to the target buffer read offset.
      Parameters:
      index - The index where the value should be read from.
      Returns:
      the value read from the given index.
      Throws:
      IndexOutOfBoundsException - if the index is negative or past the current buffer capacity.
    • setBoolean

      default ProtonBuffer setBoolean(int index, boolean value)
      Sets the boolean value at the given write index in this buffer's backing data store.
      Parameters:
      index - The index to start the write from.
      value - The value to write at the given index.
      Returns:
      a reference to this ProtonBuffer for chaining.
      Throws:
      IndexOutOfBoundsException - if the index is negative or the write would exceed capacity.
    • readBoolean

      default boolean readBoolean()
      Reads a boolean value from the buffer and advances the read index by one.
      Returns:
      boolean value read from the buffer.
      Throws:
      IndexOutOfBoundsException - if a value cannot be read from the buffer.
    • writeBoolean

      default ProtonBuffer writeBoolean(boolean value)
      Writes a single boolean to the buffer and advances the write index by one.
      Parameters:
      value - The boolean to write into the buffer.
      Returns:
      this ProtonBuffer for chaining.
      Throws:
      IndexOutOfBoundsException - if there is no room in the buffer for this write operation.
    • getUnsignedByte

      default int getUnsignedByte(int index)
      Gets a unsigned byte from the specified index, this method will not modify the read or write index.
      Parameters:
      index - The index into the buffer where the value should be read.
      Returns:
      the value read from the given index.
      Throws:
      IndexOutOfBoundsException - if the index is negative or past the current buffer capacity.
    • setUnsignedByte

      default ProtonBuffer setUnsignedByte(int index, int value)
      Sets the unsigned byte value at the given write index in this buffer's backing data store.
      Parameters:
      index - The index to start the write from.
      value - The value to write at the given index.
      Returns:
      a reference to this ProtonBuffer for chaining.
      Throws:
      IndexOutOfBoundsException - if the index is negative or the write would exceed capacity.
    • readUnsignedByte

      default int readUnsignedByte()
      Reads one byte from the buffer and advances the read index by one.
      Returns:
      a single byte from the ProtonBuffer.
      Throws:
      IndexOutOfBoundsException - if there is no readable bytes left in the buffer.
    • writeUnsignedByte

      default ProtonBuffer writeUnsignedByte(int value)
      Writes a single byte to the buffer and advances the write index by one.
      Parameters:
      value - The byte to write into the buffer.
      Returns:
      this ProtonBuffer for chaining.
      Throws:
      IndexOutOfBoundsException - if there is no room in the buffer for this write operation.
    • getChar

      char getChar(int index)
      Gets a 2-byte char from the specified index, this method will not modify the read or write index.
      Parameters:
      index - The index into the buffer where the value should be read.
      Returns:
      the value read from the given index.
      Throws:
      IndexOutOfBoundsException - if the index is negative or past the current buffer capacity.
    • setChar

      ProtonBuffer setChar(int index, char value)
      Sets the char value at the given write index in this buffer's backing data store.
      Parameters:
      index - The index to start the write from.
      value - The value to write at the given index.
      Returns:
      a reference to this ProtonBuffer for chaining.
      Throws:
      IndexOutOfBoundsException - if the index is negative or the write would exceed capacity.
    • readChar

      char readChar()
      Reads a character value from the buffer and advances the read index by four.
      Returns:
      char value read from the buffer.
      Throws:
      IndexOutOfBoundsException - if a value cannot be read from the buffer.
    • writeChar

      ProtonBuffer writeChar(char value)
      Writes a single character to the buffer and advances the write index by four.
      Parameters:
      value - The char to write into the buffer.
      Returns:
      this ProtonBuffer for chaining.
      Throws:
      IndexOutOfBoundsException - if there is no room in the buffer for this write operation.
    • getShort

      short getShort(int index)
      Gets a short from the specified index, this method will not modify the read or write index.
      Parameters:
      index - The index into the buffer where the value should be read.
      Returns:
      the value read from the given index.
      Throws:
      IndexOutOfBoundsException - if the index is negative or past the current buffer capacity.
    • setShort

      ProtonBuffer setShort(int index, short value)
      Sets the short value at the given write index in this buffer's backing data store.
      Parameters:
      index - The index to start the write from.
      value - The value to write at the given index.
      Returns:
      a reference to this ProtonBuffer for chaining.
      Throws:
      IndexOutOfBoundsException - if the index is negative or the write would exceed capacity.
    • readShort

      short readShort()
      Reads a short value from the buffer and advances the read index by two.
      Returns:
      short value read from the buffer.
      Throws:
      IndexOutOfBoundsException - if a value cannot be read from the buffer.
    • writeShort

      ProtonBuffer writeShort(short value)
      Writes a single short to the buffer and advances the write index by two.
      Parameters:
      value - The short to write into the buffer.
      Returns:
      this ProtonBuffer for chaining.
      Throws:
      IndexOutOfBoundsException - if there is no room in the buffer for this write operation.
    • getUnsignedShort

      default int getUnsignedShort(int index)
      Gets a unsigned short from the specified index, this method will not modify the read or write index.
      Parameters:
      index - The index into the buffer where the value should be read.
      Returns:
      the value read from the given index.
      Throws:
      IndexOutOfBoundsException - if the index is negative or past the current buffer capacity.
    • setUnsignedShort

      default ProtonBuffer setUnsignedShort(int index, int value)
      Sets the short value at the given write index in this buffer's backing data store.
      Parameters:
      index - The index to start the write from.
      value - The value to write at the given index.
      Returns:
      a reference to this ProtonBuffer for chaining.
      Throws:
      IndexOutOfBoundsException - if the index is negative or the write would exceed capacity.
    • readUnsignedShort

      default int readUnsignedShort()
      Reads an integer value from the buffer that represent the unsigned value of the short and advances the read index by two.
      Returns:
      unsigned short value read from the buffer.
      Throws:
      IndexOutOfBoundsException - if a value cannot be read from the buffer.
    • writeUnsignedShort

      default ProtonBuffer writeUnsignedShort(int value)
      Writes a single short to the buffer using the input integer value and advances the write index by two.
      Parameters:
      value - The integer to write into the buffer as an unsigned short.
      Returns:
      this ProtonBuffer for chaining.
      Throws:
      IndexOutOfBoundsException - if there is no room in the buffer for this write operation.
    • getInt

      int getInt(int index)
      Gets a int from the specified index, this method will not modify the read or write index.
      Parameters:
      index - The index into the buffer where the value should be read.
      Returns:
      the value read from the given index.
      Throws:
      IndexOutOfBoundsException - if the index is negative or past the current buffer capacity.
    • setInt

      ProtonBuffer setInt(int index, int value)
      Sets the int value at the given write index in this buffer's backing data store.
      Parameters:
      index - The index to start the write from.
      value - The value to write at the given index.
      Returns:
      a reference to this ProtonBuffer for chaining.
      Throws:
      IndexOutOfBoundsException - if the index is negative or the write would exceed capacity.
    • readInt

      int readInt()
      Reads a integer value from the buffer and advances the read index by four.
      Returns:
      integer value read from the buffer.
      Throws:
      IndexOutOfBoundsException - if a value cannot be read from the buffer.
    • writeInt

      ProtonBuffer writeInt(int value)
      Writes a single integer to the buffer and advances the write index by four.
      Parameters:
      value - The integer to write into the buffer.
      Returns:
      this ProtonBuffer for chaining.
      Throws:
      IndexOutOfBoundsException - if there is no room in the buffer for this write operation.
    • getUnsignedInt

      default long getUnsignedInt(int index)
      Gets a unsigned int from the specified index, this method will not modify the read or write index.
      Parameters:
      index - The index into the buffer where the value should be read.
      Returns:
      the value read from the given index.
      Throws:
      IndexOutOfBoundsException - if the index is negative or past the current buffer capacity.
    • setUnsignedInt

      default ProtonBuffer setUnsignedInt(int index, long value)
      Sets the long value at the given write index in this buffer's backing data store.
      Parameters:
      index - The index to start the write from.
      value - The value to write at the given index.
      Returns:
      a reference to this ProtonBuffer for chaining.
      Throws:
      IndexOutOfBoundsException - if the index is negative or the write would exceed capacity.
    • readUnsignedInt

      default long readUnsignedInt()
      Reads a unsigned integer value from the buffer and advances the read index by four.
      Returns:
      long value read from the buffer.
      Throws:
      IndexOutOfBoundsException - if a value cannot be read from the buffer.
    • writeUnsignedInt

      default ProtonBuffer writeUnsignedInt(long value)
      Writes a single unsigned int to the buffer and advances the write index by four.
      Parameters:
      value - The long to write into the buffer.
      Returns:
      this ProtonBuffer for chaining.
      Throws:
      IndexOutOfBoundsException - if there is no room in the buffer for this write operation.
    • getLong

      long getLong(int index)
      Gets a long from the specified index, this method will not modify the read or write index.
      Parameters:
      index - The index into the buffer where the value should be read.
      Returns:
      the value read from the given index.
      Throws:
      IndexOutOfBoundsException - if the index is negative or past the current buffer capacity.
    • setLong

      ProtonBuffer setLong(int index, long value)
      Sets the long value at the given write index in this buffer's backing data store.
      Parameters:
      index - The index to start the write from.
      value - The value to write at the given index.
      Returns:
      a reference to this ProtonBuffer for chaining.
      Throws:
      IndexOutOfBoundsException - if the index is negative or the write would exceed capacity.
    • readLong

      long readLong()
      Reads a long value from the buffer and advances the read index by eight.
      Returns:
      long value read from the buffer.
      Throws:
      IndexOutOfBoundsException - if a value cannot be read from the buffer.
    • writeLong

      ProtonBuffer writeLong(long value)
      Writes a single long to the buffer and advances the write index by eight.
      Parameters:
      value - The long to write into the buffer.
      Returns:
      this ProtonBuffer for chaining.
      Throws:
      IndexOutOfBoundsException - if there is no room in the buffer for this write operation.
    • getFloat

      default float getFloat(int index)
      Gets a float from the specified index, this method will not modify the read or write index.
      Parameters:
      index - The index into the buffer where the value should be read.
      Returns:
      the value read from the given index.
      Throws:
      IndexOutOfBoundsException - if the index is negative or past the current buffer capacity.
    • setFloat

      default ProtonBuffer setFloat(int index, float value)
      Sets the float value at the given write index in this buffer's backing data store.
      Parameters:
      index - The index to start the write from.
      value - The value to write at the given index.
      Returns:
      a reference to this ProtonBuffer for chaining.
      Throws:
      IndexOutOfBoundsException - if the index is negative or the write would exceed capacity.
    • readFloat

      default float readFloat()
      Reads a float value from the buffer and advances the read index by four.
      Returns:
      float value read from the buffer.
      Throws:
      IndexOutOfBoundsException - if a value cannot be read from the buffer.
    • writeFloat

      default ProtonBuffer writeFloat(float value)
      Writes a single float to the buffer and advances the write index by four.
      Parameters:
      value - The float to write into the buffer.
      Returns:
      this ProtonBuffer for chaining.
      Throws:
      IndexOutOfBoundsException - if there is no room in the buffer for this write operation.
    • getDouble

      default double getDouble(int index)
      Gets a double from the specified index, this method will not modify the read or write index.
      Parameters:
      index - The index into the buffer where the value should be read.
      Returns:
      the value read from the given index.
      Throws:
      IndexOutOfBoundsException - if the index is negative or past the current buffer capacity.
    • setDouble

      default ProtonBuffer setDouble(int index, double value)
      Sets the double value at the given write index in this buffer's backing data store.
      Parameters:
      index - The index to start the write from.
      value - The value to write at the given index.
      Returns:
      a reference to this ProtonBuffer for chaining.
      Throws:
      IndexOutOfBoundsException - if the index is negative or the write would exceed capacity.
    • readDouble

      default double readDouble()
      Reads a double value from the buffer and advances the read index by eight.
      Returns:
      double value read from the buffer.
      Throws:
      IndexOutOfBoundsException - if a value cannot be read from the buffer.
    • writeDouble

      default ProtonBuffer writeDouble(double value)
      Writes a single double to the buffer and advances the write index by eight.
      Parameters:
      value - The double to write into the buffer.
      Returns:
      this ProtonBuffer for chaining.
      Throws:
      IndexOutOfBoundsException - if there is no room in the buffer for this write operation.