Class ExpansibleByteBuffer

    • Constructor Detail

      • ExpansibleByteBuffer

        public ExpansibleByteBuffer()
        Create a default ExpansibleByteBuffer capable of holding 10 bytes
      • ExpansibleByteBuffer

        public ExpansibleByteBuffer​(int initialSize)
        Creates a ExpansibleByteBuffer which has an initialze size
        Parameters:
        initialSize - The initial buffer size
    • Method Detail

      • clear

        public final void clear()
        Reset the Buffer position to 0. Every new added byte will be put on position 0. Note that whatever this buffer contained before a call to the clear() method will not be removed.
      • position

        public final int position()
        Returns:
        The position of the last byte in the buffer
      • position

        public final void position​(int pos)
        Set the position to a specific value
        Parameters:
        pos - the new position
      • capacity

        public final int capacity()
        Returns:
        The number of bytes that can be added into this buffer
      • get

        public final byte get​(int i)
        Returns the byte at a given position. Note that no control is done on the position validity.
        Parameters:
        i - The position
        Returns:
        The byte at the given position in the buffer
      • buffer

        public final byte[] buffer()
        Get's the bytes, the backing store for this buffer. Note that you need to use the position index to determine where to stop reading from this buffer.
        Returns:
        The interned Byte[]
      • copyOfUsedBytes

        public final byte[] copyOfUsedBytes()
        Get's a copy of the bytes used.
        Returns:
        A copy of the interned Byte[]
      • append

        public final void append​(byte[] bytes)
        Appends the bytes to this buffer.
        Parameters:
        bytes - The byte[] to append to the buffer
      • append

        public final void append​(byte b)
        Appends a byte to this buffer.
        Parameters:
        b - The byte to append to the buffer
      • append

        public final void append​(int val)
        Appends an int to this buffer. WARNING: the int is truncated to a byte value.
        Parameters:
        val - The integer to append to the buffer