Interface ByteBufferFactory<T,​B>

  • Type Parameters:
    T - The type
    B - The body

    public interface ByteBufferFactory<T,​B>
    An allocator for ByteBuffer instances.
    Since:
    1.0
    • Method Detail

      • getNativeAllocator

        T getNativeAllocator()
        Returns:
        The native allocator
      • buffer

        ByteBuffer<B> buffer()
        Allocate a ByteBuffer. If it is a direct or heap buffer depends on the actual implementation.
        Returns:
        The buffer
      • buffer

        ByteBuffer<B> buffer​(int initialCapacity)
        Allocate a ByteBuffer with the given initial capacity. If it is a direct or heap buffer depends on the actual implementation.
        Parameters:
        initialCapacity - The initial capacity
        Returns:
        the buffer
      • buffer

        ByteBuffer<B> buffer​(int initialCapacity,
                             int maxCapacity)
        Allocate a ByteBuffer with the given initial capacity and the given maximal capacity. If it is a direct or heap buffer depends on the actual implementation.
        Parameters:
        initialCapacity - The initial capacity
        maxCapacity - The maximum capacity
        Returns:
        The buffer
      • copiedBuffer

        ByteBuffer<B> copiedBuffer​(byte[] bytes)
        Creates a new big-endian buffer whose content is a copy of the specified array's sub-region. The new buffer's readerIndex and writerIndex are 0 and the specified length respectively.
        Parameters:
        bytes - The bytes
        Returns:
        The buffer
      • copiedBuffer

        ByteBuffer<B> copiedBuffer​(java.nio.ByteBuffer nioBuffer)
        Creates a new big-endian buffer whose content is a copy of the specified NIO buffer. The new buffer's readerIndex and writerIndex are 0 and the specified length respectively.
        Parameters:
        nioBuffer - The nioBuffer
        Returns:
        The buffer
      • wrap

        ByteBuffer<B> wrap​(B existing)
        Wrap an existing buffer.
        Parameters:
        existing - The buffer to wrap
        Returns:
        The wrapped ByteBuffer
      • wrap

        ByteBuffer<B> wrap​(byte[] existing)
        Wrap an existing buffer.
        Parameters:
        existing - The bytes to wrap
        Returns:
        The wrapped ByteBuffer