Class ByteArrayByteBuffer<T>

java.lang.Object
io.micronaut.servlet.http.ByteArrayByteBuffer<T>
Type Parameters:
T -
All Implemented Interfaces:
io.micronaut.core.io.buffer.ByteBuffer<T>

@Internal public class ByteArrayByteBuffer<T> extends Object implements io.micronaut.core.io.buffer.ByteBuffer<T>
A ByteBuffer implementation that is backed by a byte array.
  • Constructor Details

    • ByteArrayByteBuffer

      public ByteArrayByteBuffer(byte[] underlyingBytes)
      Construct a new ByteArrayByteBuffer for the given bytes.
      Parameters:
      underlyingBytes - the bytes to wrap
    • ByteArrayByteBuffer

      public ByteArrayByteBuffer(byte[] underlyingBytes, int capacity)
      Construct a new ByteArrayByteBuffer for the given bytes and capacity. If capacity is greater than the length of the underlyingBytes, extra bytes will be zeroed out. If capacity is less than the length of the underlyingBytes, the underlyingBytes will be truncated.
      Parameters:
      underlyingBytes - the bytes to wrap
      capacity - the capacity of the buffer
  • Method Details

    • asNativeBuffer

      public T asNativeBuffer()
      Specified by:
      asNativeBuffer in interface io.micronaut.core.io.buffer.ByteBuffer<T>
    • readableBytes

      public int readableBytes()
      Specified by:
      readableBytes in interface io.micronaut.core.io.buffer.ByteBuffer<T>
    • writableBytes

      public int writableBytes()
      Specified by:
      writableBytes in interface io.micronaut.core.io.buffer.ByteBuffer<T>
    • maxCapacity

      public int maxCapacity()
      Specified by:
      maxCapacity in interface io.micronaut.core.io.buffer.ByteBuffer<T>
    • capacity

      public io.micronaut.core.io.buffer.ByteBuffer capacity(int capacity)
      Specified by:
      capacity in interface io.micronaut.core.io.buffer.ByteBuffer<T>
    • readerIndex

      public int readerIndex()
      Specified by:
      readerIndex in interface io.micronaut.core.io.buffer.ByteBuffer<T>
    • readerIndex

      public io.micronaut.core.io.buffer.ByteBuffer readerIndex(int readPosition)
      Specified by:
      readerIndex in interface io.micronaut.core.io.buffer.ByteBuffer<T>
    • writerIndex

      public int writerIndex()
      Specified by:
      writerIndex in interface io.micronaut.core.io.buffer.ByteBuffer<T>
    • writerIndex

      public io.micronaut.core.io.buffer.ByteBuffer writerIndex(int position)
      Specified by:
      writerIndex in interface io.micronaut.core.io.buffer.ByteBuffer<T>
    • read

      public byte read()
      Specified by:
      read in interface io.micronaut.core.io.buffer.ByteBuffer<T>
    • readCharSequence

      public CharSequence readCharSequence(int length, Charset charset)
      Specified by:
      readCharSequence in interface io.micronaut.core.io.buffer.ByteBuffer<T>
    • read

      public io.micronaut.core.io.buffer.ByteBuffer read(byte[] destination)
      Specified by:
      read in interface io.micronaut.core.io.buffer.ByteBuffer<T>
    • read

      public io.micronaut.core.io.buffer.ByteBuffer read(byte[] destination, int offset, int length)
      Specified by:
      read in interface io.micronaut.core.io.buffer.ByteBuffer<T>
    • write

      public io.micronaut.core.io.buffer.ByteBuffer write(byte b)
      Specified by:
      write in interface io.micronaut.core.io.buffer.ByteBuffer<T>
    • write

      public io.micronaut.core.io.buffer.ByteBuffer write(byte[] source)
      Specified by:
      write in interface io.micronaut.core.io.buffer.ByteBuffer<T>
    • write

      public io.micronaut.core.io.buffer.ByteBuffer write(CharSequence source, Charset charset)
      Specified by:
      write in interface io.micronaut.core.io.buffer.ByteBuffer<T>
    • write

      public io.micronaut.core.io.buffer.ByteBuffer write(byte[] source, int offset, int length)
      Specified by:
      write in interface io.micronaut.core.io.buffer.ByteBuffer<T>
    • write

      public io.micronaut.core.io.buffer.ByteBuffer write(io.micronaut.core.io.buffer.ByteBuffer... buffers)
      Specified by:
      write in interface io.micronaut.core.io.buffer.ByteBuffer<T>
    • write

      public io.micronaut.core.io.buffer.ByteBuffer write(ByteBuffer... buffers)
      Specified by:
      write in interface io.micronaut.core.io.buffer.ByteBuffer<T>
    • slice

      public io.micronaut.core.io.buffer.ByteBuffer slice(int index, int length)
      Specified by:
      slice in interface io.micronaut.core.io.buffer.ByteBuffer<T>
    • asNioBuffer

      public ByteBuffer asNioBuffer()
      Specified by:
      asNioBuffer in interface io.micronaut.core.io.buffer.ByteBuffer<T>
    • asNioBuffer

      public ByteBuffer asNioBuffer(int index, int length)
      Specified by:
      asNioBuffer in interface io.micronaut.core.io.buffer.ByteBuffer<T>
    • toInputStream

      public InputStream toInputStream()
      Specified by:
      toInputStream in interface io.micronaut.core.io.buffer.ByteBuffer<T>
    • toOutputStream

      public OutputStream toOutputStream()
      Specified by:
      toOutputStream in interface io.micronaut.core.io.buffer.ByteBuffer<T>
    • toByteArray

      public byte[] toByteArray()
      Specified by:
      toByteArray in interface io.micronaut.core.io.buffer.ByteBuffer<T>
    • toString

      public String toString(Charset charset)
      Specified by:
      toString in interface io.micronaut.core.io.buffer.ByteBuffer<T>
    • indexOf

      public int indexOf(byte b)
      Specified by:
      indexOf in interface io.micronaut.core.io.buffer.ByteBuffer<T>
    • getByte

      public byte getByte(int index)
      Specified by:
      getByte in interface io.micronaut.core.io.buffer.ByteBuffer<T>