Class ExpandableBuffer

    • Constructor Detail

      • ExpandableBuffer

        public ExpandableBuffer​(int bufferSize,
                                ByteBufferAllocator allocator)
        Allocates buffer of the given size using the given allocator.
        Parameters:
        bufferSize - the buffer size.
        allocator - allocator to be used to allocate ByteBuffers.
    • Method Detail

      • getMode

        protected int getMode()
        Returns the current mode:

        INPUT_MODE: the buffer is in the input mode.

        OUTPUT_MODE: the buffer is in the output mode.

        Returns:
        current input/output mode.
      • setOutputMode

        protected void setOutputMode()
        Sets output mode. The buffer can now be read from.
      • setInputMode

        protected void setInputMode()
        Sets input mode. The buffer can now be written into.
      • ensureCapacity

        protected void ensureCapacity​(int requiredCapacity)
        Ensures the buffer can accommodate the required capacity.
      • capacity

        public int capacity()
        Returns the total capacity of this buffer.
        Specified by:
        capacity in interface BufferInfo
        Specified by:
        capacity in interface BufferInfo
        Returns:
        total capacity.
      • hasData

        public boolean hasData()
        Determines if the buffer contains data.
        Returns:
        true if there is data in the buffer, false otherwise.
      • length

        public int length()
        Returns the length of this buffer.
        Specified by:
        length in interface BufferInfo
        Specified by:
        length in interface BufferInfo
        Returns:
        buffer length.
      • available

        public int available()
        Returns available capacity of this buffer.
        Specified by:
        available in interface BufferInfo
        Specified by:
        available in interface BufferInfo
        Returns:
        buffer length.
      • clear

        protected void clear()
        Clears buffer.