Class ByteArrayBufferFactory

java.lang.Object
io.micronaut.core.io.buffer.ByteArrayBufferFactory
All Implemented Interfaces:
ByteBufferFactory<Void,byte[]>

@Internal public class ByteArrayBufferFactory extends Object implements ByteBufferFactory<Void,byte[]>
ByteBufferFactory implementation based on simple byte arrays.
Since:
4.7
Author:
Jonas Konrad
  • Field Details

  • Method Details

    • getNativeAllocator

      public Void getNativeAllocator()
      Specified by:
      getNativeAllocator in interface ByteBufferFactory<Void,byte[]>
      Returns:
      The native allocator
    • buffer

      public ByteArrayByteBuffer buffer()
      Description copied from interface: ByteBufferFactory
      Allocate a ByteBuffer. If it is a direct or heap buffer depends on the actual implementation.
      Specified by:
      buffer in interface ByteBufferFactory<Void,byte[]>
      Returns:
      The buffer
    • buffer

      public ByteArrayByteBuffer buffer(int initialCapacity)
      Description copied from interface: ByteBufferFactory
      Allocate a ByteBuffer with the given initial capacity. If it is a direct or heap buffer depends on the actual implementation.
      Specified by:
      buffer in interface ByteBufferFactory<Void,byte[]>
      Parameters:
      initialCapacity - The initial capacity
      Returns:
      the buffer
    • buffer

      public ByteArrayByteBuffer buffer(int initialCapacity, int maxCapacity)
      Description copied from interface: ByteBufferFactory
      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.
      Specified by:
      buffer in interface ByteBufferFactory<Void,byte[]>
      Parameters:
      initialCapacity - The initial capacity
      maxCapacity - The maximum capacity
      Returns:
      The buffer
    • copiedBuffer

      public ByteArrayByteBuffer copiedBuffer(byte[] bytes)
      Description copied from interface: ByteBufferFactory
      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.
      Specified by:
      copiedBuffer in interface ByteBufferFactory<Void,byte[]>
      Parameters:
      bytes - The bytes
      Returns:
      The buffer
    • copiedBuffer

      public ByteArrayByteBuffer copiedBuffer(ByteBuffer nioBuffer)
      Description copied from interface: ByteBufferFactory
      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.
      Specified by:
      copiedBuffer in interface ByteBufferFactory<Void,byte[]>
      Parameters:
      nioBuffer - The nioBuffer
      Returns:
      The buffer
    • wrap

      public ByteArrayByteBuffer wrap(byte[] existing)
      Description copied from interface: ByteBufferFactory
      Wrap an existing buffer.
      Specified by:
      wrap in interface ByteBufferFactory<Void,byte[]>
      Parameters:
      existing - The buffer to wrap
      Returns:
      The wrapped ByteBuffer