Interface BufferAllocator


  • public interface BufferAllocator
    An API to allocate Buffers.
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      Buffer fromAscii​(java.lang.CharSequence data)
      Create a new Buffer from the given CharSequence using Ascii encoding.
      Buffer fromAscii​(java.lang.CharSequence data, boolean direct)
      Create a new Buffer from the given CharSequence using Ascii encoding.
      Buffer fromSequence​(java.lang.CharSequence data, java.nio.charset.Charset charset)
      Create a new Buffer from the given CharSequence using the Charset.
      Buffer fromSequence​(java.lang.CharSequence data, java.nio.charset.Charset charset, boolean direct)
      Create a new Buffer from the given CharSequence using the Charset.
      Buffer fromUtf8​(java.lang.CharSequence data)
      Create a new Buffer from the given CharSequence using UTF-8 encoding.
      Buffer fromUtf8​(java.lang.CharSequence data, boolean direct)
      Create a new Buffer from the given CharSequence using UTF-8 encoding.
      default Buffer newBuffer()
      Create a new buffer.
      default Buffer newBuffer​(boolean direct)
      Create a new buffer.
      Buffer newBuffer​(int initialCapacity)
      Create a new buffer with the given initial capacity.
      Buffer newBuffer​(int initialCapacity, boolean direct)
      Create a new buffer with the given initial capacity.
      Buffer newBuffer​(int initialCapacity, int maxCapacity)
      Create a new buffer with the given initial capacity and given max capacity.
      CompositeBuffer newCompositeBuffer()
      Create a new composite buffer.
      CompositeBuffer newCompositeBuffer​(int maxComponents)
      Create a new composite buffer.
      Buffer wrap​(byte[] bytes)
      Create a new Buffer that wraps the given byte array.
      default Buffer wrap​(byte[] bytes, int offset, int len)
      Create a new Buffer that wraps the given byte array.
      Buffer wrap​(java.nio.ByteBuffer buffer)
      Create a new Buffer that wraps the given ByteBuffer.
    • Method Detail

      • newBuffer

        default Buffer newBuffer()
        Create a new buffer.
        Returns:
        a new buffer.
      • newBuffer

        default Buffer newBuffer​(boolean direct)
        Create a new buffer.
        Parameters:
        direct - true if the buffer will be direct (off-heap), false otherwise.
        Returns:
        a new buffer.
      • newBuffer

        Buffer newBuffer​(int initialCapacity)
        Create a new buffer with the given initial capacity.
        Parameters:
        initialCapacity - the initial capacity of the buffer.
        Returns:
        a new buffer.
      • newBuffer

        Buffer newBuffer​(int initialCapacity,
                         int maxCapacity)
        Create a new buffer with the given initial capacity and given max capacity.
        Parameters:
        initialCapacity - the initial capacity of the buffer.
        maxCapacity - the maximum capacity of the buffer.
        Returns:
        a new buffer.
      • newBuffer

        Buffer newBuffer​(int initialCapacity,
                         boolean direct)
        Create a new buffer with the given initial capacity.
        Parameters:
        initialCapacity - the initial capacity of the allocated buffer.
        direct - true if the buffer will be direct (off-heap), false otherwise.
        Returns:
        a new buffer.
      • newCompositeBuffer

        CompositeBuffer newCompositeBuffer()
        Create a new composite buffer.
        Returns:
        the new buffer.
      • newCompositeBuffer

        CompositeBuffer newCompositeBuffer​(int maxComponents)
        Create a new composite buffer.
        Parameters:
        maxComponents - The maximum number of top level Buffer objects that can be contained.
        Returns:
        the new buffer.
      • fromSequence

        Buffer fromSequence​(java.lang.CharSequence data,
                            java.nio.charset.Charset charset)
        Create a new Buffer from the given CharSequence using the Charset.
        Parameters:
        data - the sequence.
        charset - the charset to use.
        Returns:
        a new buffer.
      • fromSequence

        Buffer fromSequence​(java.lang.CharSequence data,
                            java.nio.charset.Charset charset,
                            boolean direct)
        Create a new Buffer from the given CharSequence using the Charset.
        Parameters:
        data - the sequence.
        charset - the charset to use.
        direct - true if the buffer will be direct (off-heap), false otherwise.
        Returns:
        a new buffer.
      • fromUtf8

        Buffer fromUtf8​(java.lang.CharSequence data)
        Create a new Buffer from the given CharSequence using UTF-8 encoding.
        Parameters:
        data - the sequence.
        Returns:
        a new buffer.
      • fromUtf8

        Buffer fromUtf8​(java.lang.CharSequence data,
                        boolean direct)
        Create a new Buffer from the given CharSequence using UTF-8 encoding.
        Parameters:
        data - the sequence.
        direct - true if the buffer will be direct (off-heap), false otherwise.
        Returns:
        a new buffer.
      • fromAscii

        Buffer fromAscii​(java.lang.CharSequence data)
        Create a new Buffer from the given CharSequence using Ascii encoding.
        Parameters:
        data - the sequence.
        Returns:
        a new buffer.
      • fromAscii

        Buffer fromAscii​(java.lang.CharSequence data,
                         boolean direct)
        Create a new Buffer from the given CharSequence using Ascii encoding.
        Parameters:
        data - the sequence.
        direct - true if the buffer will be direct (off-heap), false otherwise.
        Returns:
        a new buffer.
      • wrap

        Buffer wrap​(byte[] bytes)
        Create a new Buffer that wraps the given byte array.
        Parameters:
        bytes - the byte array.
        Returns:
        a new buffer.
      • wrap

        default Buffer wrap​(byte[] bytes,
                            int offset,
                            int len)
        Create a new Buffer that wraps the given byte array.
        Parameters:
        bytes - the byte array.
        offset - the offset index of the array.
        len - the numbers of bytes.
        Returns:
        a new buffer.
      • wrap

        Buffer wrap​(java.nio.ByteBuffer buffer)
        Create a new Buffer that wraps the given ByteBuffer.
        Parameters:
        buffer - to wrap.
        Returns:
        a new buffer.