Interface ReadWriteBuf

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void clear()
      Clears (resets) the buffer so that it can be reused.
      int limit()
      Defines the size of the message in the buffer.
      void put​(byte value)
      Write a byte into the buffer at writePosition().
      void put​(byte[] value, int start, int length)
      Put an array of bytes into the buffer at writePosition().
      void putBoolean​(boolean value)
      Put a boolean into the buffer at writePosition() .
      void putDouble​(double value)
      Write a 64-bit float into the buffer at writePosition().
      void putFloat​(float value)
      Write a 32-bit float into the buffer at writePosition().
      void putInt​(int value)
      Write a 32-bit into in the buffer at writePosition().
      void putLong​(long value)
      Write a 64-bit into in the buffer at writePosition().
      void putShort​(short value)
      Write a 16-bit into in the buffer at writePosition().
      boolean requestCapacity​(int capacity)
      Request capacity of the buffer.
      void set​(int index, byte value)
      Read a byte from data.
      void set​(int index, byte[] value, int start, int length)
      Write an array of bytes into the buffer.
      void setBoolean​(int index, boolean value)
      Write boolean into a given position on the buffer.
      void setDouble​(int index, double value)
      Read a 64-bit float from data.
      void setFloat​(int index, float value)
      Read a 32-bit float from data.
      void setInt​(int index, int value)
      Read a 32-bit int from data.
      void setLong​(int index, long value)
      Read a 64-bit long from data.
      void setShort​(int index, short value)
      Read a short from data.
      int writePosition()  
    • Method Detail

      • clear

        void clear()
        Clears (resets) the buffer so that it can be reused. Write position will be set to the start.
      • putBoolean

        void putBoolean​(boolean value)
        Put a boolean into the buffer at writePosition() . Booleans as stored as single byte. Write position will be incremented.
      • put

        void put​(byte[] value,
                 int start,
                 int length)
        Put an array of bytes into the buffer at writePosition(). Write position will be incremented.
        Parameters:
        value - the data to be copied
        start - initial position on value to be copied
        length - amount of bytes to be copied
      • put

        void put​(byte value)
        Write a byte into the buffer at writePosition(). Write position will be incremented.
      • putShort

        void putShort​(short value)
        Write a 16-bit into in the buffer at writePosition(). Write position will be incremented.
      • putInt

        void putInt​(int value)
        Write a 32-bit into in the buffer at writePosition(). Write position will be incremented.
      • putLong

        void putLong​(long value)
        Write a 64-bit into in the buffer at writePosition(). Write position will be incremented.
      • putFloat

        void putFloat​(float value)
        Write a 32-bit float into the buffer at writePosition(). Write position will be incremented.
      • putDouble

        void putDouble​(double value)
        Write a 64-bit float into the buffer at writePosition(). Write position will be incremented.
      • setBoolean

        void setBoolean​(int index,
                        boolean value)
        Write boolean into a given position on the buffer. Booleans as stored as single byte.
        Parameters:
        index - position of the element in buffer
      • set

        void set​(int index,
                 byte value)
        Read a byte from data.
        Parameters:
        index - position of the element in the buffer
      • set

        void set​(int index,
                 byte[] value,
                 int start,
                 int length)
        Write an array of bytes into the buffer.
        Parameters:
        index - initial position of the buffer to be written
        value - the data to be copied
        start - initial position on value to be copied
        length - amount of bytes to be copied
      • setShort

        void setShort​(int index,
                      short value)
        Read a short from data.
        Parameters:
        index - position of the element in ReadBuf
      • setInt

        void setInt​(int index,
                    int value)
        Read a 32-bit int from data.
        Parameters:
        index - position of the element in ReadBuf
      • setLong

        void setLong​(int index,
                     long value)
        Read a 64-bit long from data.
        Parameters:
        index - position of the element in ReadBuf
      • setFloat

        void setFloat​(int index,
                      float value)
        Read a 32-bit float from data.
        Parameters:
        index - position of the element in ReadBuf
      • setDouble

        void setDouble​(int index,
                       double value)
        Read a 64-bit float from data.
        Parameters:
        index - position of the element in ReadBuf
      • writePosition

        int writePosition()
      • limit

        int limit()
        Defines the size of the message in the buffer. It also determines last position that buffer can be read or write. Last byte to be accessed is in position limit() -1.
        Specified by:
        limit in interface ReadBuf
        Returns:
        indicate last position
      • requestCapacity

        boolean requestCapacity​(int capacity)
        Request capacity of the buffer. In case buffer is already larger than the requested, this method will just return true. Otherwise It might try to resize the buffer.
        Returns:
        true if buffer is able to offer the requested capacity