Class Netty5DataBuffer

java.lang.Object
org.springframework.core.io.buffer.Netty5DataBuffer
All Implemented Interfaces:
AutoCloseable, CloseableDataBuffer, DataBuffer, TouchableDataBuffer

@Deprecated(since="6.2.18", forRemoval=true) public final class Netty5DataBuffer extends Object implements CloseableDataBuffer, TouchableDataBuffer
Deprecated, for removal: This API element is subject to removal in a future version.
as of 6.2.18 with no replacement
Implementation of the DataBuffer interface that wraps a Netty 5 Buffer. Typically constructed with Netty5DataBufferFactory.
Since:
6.0
Author:
Violeta Georgieva, Arjen Poutsma
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.springframework.core.io.buffer.DataBuffer

    DataBuffer.ByteBufferIterator, DataBuffer.ByteProcessor
  • Method Summary

    Modifier and Type
    Method
    Description
    Deprecated.
    asByteBuffer(int index, int length)
    Deprecated.
    int
    Deprecated, for removal: This API element is subject to removal in a future version.
    Return the number of bytes that this buffer can contain.
    capacity(int capacity)
    Deprecated.
    void
    Deprecated, for removal: This API element is subject to removal in a future version.
    Closes this data buffer, freeing any resources.
    ensureWritable(int capacity)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Ensure that the current buffer has enough DataBuffer.writableByteCount() to write the amount of data given as an argument.
    boolean
    equals(Object other)
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    Deprecated, for removal: This API element is subject to removal in a future version.
    Return the DataBufferFactory that created this buffer.
    byte
    getByte(int index)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Read a single byte at the given index from this data buffer.
    io.netty5.buffer.Buffer
    Deprecated, for removal: This API element is subject to removal in a future version.
    Directly exposes the native Buffer that this buffer is based on.
    int
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    int
    indexOf(IntPredicate predicate, int fromIndex)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Return the index of the first byte in this buffer that matches the given predicate.
    int
    lastIndexOf(IntPredicate predicate, int fromIndex)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Return the index of the last byte in this buffer that matches the given predicate.
    byte
    Deprecated, for removal: This API element is subject to removal in a future version.
    Read a single byte from the current reading position from this data buffer.
    read(byte[] destination)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Read this buffer's data into the specified destination, starting at the current reading position of this buffer.
    read(byte[] destination, int offset, int length)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Read at most length bytes of this buffer into the specified destination, starting at the current reading position of this buffer.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Returns a closeable iterator over each ByteBuffer in this data buffer that can be read.
    int
    Deprecated, for removal: This API element is subject to removal in a future version.
    Return the number of bytes that can be read from this data buffer.
    int
    Deprecated, for removal: This API element is subject to removal in a future version.
    Return the position from which this buffer will read.
    readPosition(int readPosition)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Set the position from which this buffer will read.
    slice(int index, int length)
    Deprecated.
    split(int index)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Splits this data buffer into two at the given index.
    toByteBuffer(int index, int length)
    Deprecated.
    void
    toByteBuffer(int srcPos, ByteBuffer dest, int destPos, int length)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Copies the given length from this data buffer into the given destination ByteBuffer, beginning at the given source position, and the given destination position in the destination byte buffer.
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    toString(int index, int length, Charset charset)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Return a part of this buffer's data as a String using the specified charset.
    toString(Charset charset)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Return this buffer's data a String using the specified charset.
    touch(Object hint)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Associate the given hint with the data buffer for debugging purposes.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Returns a closeable iterator over each ByteBuffer in this data buffer that can be written to.
    int
    Deprecated, for removal: This API element is subject to removal in a future version.
    Return the number of bytes that can be written to this data buffer.
    write(byte b)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Write a single byte into this buffer at the current writing position.
    write(byte[] source)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Write the given source into this buffer, starting at the current writing position of this buffer.
    write(byte[] source, int offset, int length)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Write at most length bytes of the given source into this buffer, starting at the current writing position of this buffer.
    write(io.netty5.buffer.Buffer... buffers)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Writes one or more Netty 5 Buffers to this buffer, starting at the current writing position.
    write(CharSequence charSequence, Charset charset)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Write the given CharSequence using the given Charset, starting at the current writing position.
    write(ByteBuffer... buffers)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Write one or more ByteBuffer to this buffer, starting at the current writing position.
    write(DataBuffer... dataBuffers)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Write one or more DataBuffers to this buffer, starting at the current writing position.
    int
    Deprecated, for removal: This API element is subject to removal in a future version.
    Return the position to which this buffer will write.
    writePosition(int writePosition)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Set the position to which this buffer will write.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.springframework.core.io.buffer.DataBuffer

    asInputStream, asInputStream, asOutputStream, ensureCapacity, forEachByte, retainedSlice, toByteBuffer, toByteBuffer
  • Method Details

    • getNativeBuffer

      public io.netty5.buffer.Buffer getNativeBuffer()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Directly exposes the native Buffer that this buffer is based on.
      Returns:
      the wrapped buffer
    • factory

      public DataBufferFactory factory()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: DataBuffer
      Return the DataBufferFactory that created this buffer.
      Specified by:
      factory in interface DataBuffer
      Returns:
      the creating buffer factory
    • indexOf

      public int indexOf(IntPredicate predicate, int fromIndex)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: DataBuffer
      Return the index of the first byte in this buffer that matches the given predicate.
      Specified by:
      indexOf in interface DataBuffer
      Parameters:
      predicate - the predicate to match
      fromIndex - the index to start the search from
      Returns:
      the index of the first byte that matches predicate; or -1 if none match
    • lastIndexOf

      public int lastIndexOf(IntPredicate predicate, int fromIndex)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: DataBuffer
      Return the index of the last byte in this buffer that matches the given predicate.
      Specified by:
      lastIndexOf in interface DataBuffer
      Parameters:
      predicate - the predicate to match
      fromIndex - the index to start the search from
      Returns:
      the index of the last byte that matches predicate; or -1 if none match
    • readableByteCount

      public int readableByteCount()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: DataBuffer
      Return the number of bytes that can be read from this data buffer.
      Specified by:
      readableByteCount in interface DataBuffer
      Returns:
      the readable byte count
    • writableByteCount

      public int writableByteCount()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: DataBuffer
      Return the number of bytes that can be written to this data buffer.
      Specified by:
      writableByteCount in interface DataBuffer
      Returns:
      the writable byte count
    • readPosition

      public int readPosition()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: DataBuffer
      Return the position from which this buffer will read.
      Specified by:
      readPosition in interface DataBuffer
      Returns:
      the read position
    • readPosition

      public Netty5DataBuffer readPosition(int readPosition)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: DataBuffer
      Set the position from which this buffer will read.
      Specified by:
      readPosition in interface DataBuffer
      Parameters:
      readPosition - the new read position
      Returns:
      this buffer
    • writePosition

      public int writePosition()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: DataBuffer
      Return the position to which this buffer will write.
      Specified by:
      writePosition in interface DataBuffer
      Returns:
      the write position
    • writePosition

      public Netty5DataBuffer writePosition(int writePosition)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: DataBuffer
      Set the position to which this buffer will write.
      Specified by:
      writePosition in interface DataBuffer
      Parameters:
      writePosition - the new write position
      Returns:
      this buffer
    • getByte

      public byte getByte(int index)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: DataBuffer
      Read a single byte at the given index from this data buffer.
      Specified by:
      getByte in interface DataBuffer
      Parameters:
      index - the index at which the byte will be read
      Returns:
      the byte at the given index
    • capacity

      public int capacity()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: DataBuffer
      Return the number of bytes that this buffer can contain.
      Specified by:
      capacity in interface DataBuffer
      Returns:
      the capacity
    • capacity

      @Deprecated public Netty5DataBuffer capacity(int capacity)
      Deprecated.
      Description copied from interface: DataBuffer
      Set the number of bytes that this buffer can contain.

      If the new capacity is lower than the current capacity, the contents of this buffer will be truncated. If the new capacity is higher than the current capacity, it will be expanded.

      Specified by:
      capacity in interface DataBuffer
      Parameters:
      capacity - the new capacity
      Returns:
      this buffer
    • ensureWritable

      public DataBuffer ensureWritable(int capacity)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: DataBuffer
      Ensure that the current buffer has enough DataBuffer.writableByteCount() to write the amount of data given as an argument. If not, the missing capacity will be added to the buffer.
      Specified by:
      ensureWritable in interface DataBuffer
      Parameters:
      capacity - the writable capacity to check for
      Returns:
      this buffer
    • read

      public byte read()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: DataBuffer
      Read a single byte from the current reading position from this data buffer.
      Specified by:
      read in interface DataBuffer
      Returns:
      the byte at this buffer's current reading position
    • read

      public Netty5DataBuffer read(byte[] destination)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: DataBuffer
      Read this buffer's data into the specified destination, starting at the current reading position of this buffer.
      Specified by:
      read in interface DataBuffer
      Parameters:
      destination - the array into which the bytes are to be written
      Returns:
      this buffer
    • read

      public Netty5DataBuffer read(byte[] destination, int offset, int length)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: DataBuffer
      Read at most length bytes of this buffer into the specified destination, starting at the current reading position of this buffer.
      Specified by:
      read in interface DataBuffer
      Parameters:
      destination - the array into which the bytes are to be written
      offset - the index within destination of the first byte to be written
      length - the maximum number of bytes to be written in destination
      Returns:
      this buffer
    • write

      public Netty5DataBuffer write(byte b)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: DataBuffer
      Write a single byte into this buffer at the current writing position.
      Specified by:
      write in interface DataBuffer
      Parameters:
      b - the byte to be written
      Returns:
      this buffer
    • write

      public Netty5DataBuffer write(byte[] source)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: DataBuffer
      Write the given source into this buffer, starting at the current writing position of this buffer.
      Specified by:
      write in interface DataBuffer
      Parameters:
      source - the bytes to be written into this buffer
      Returns:
      this buffer
    • write

      public Netty5DataBuffer write(byte[] source, int offset, int length)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: DataBuffer
      Write at most length bytes of the given source into this buffer, starting at the current writing position of this buffer.
      Specified by:
      write in interface DataBuffer
      Parameters:
      source - the bytes to be written into this buffer
      offset - the index within source to start writing from
      length - the maximum number of bytes to be written from source
      Returns:
      this buffer
    • write

      public Netty5DataBuffer write(DataBuffer... dataBuffers)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: DataBuffer
      Write one or more DataBuffers to this buffer, starting at the current writing position. It is the responsibility of the caller to release the given data buffers.
      Specified by:
      write in interface DataBuffer
      Parameters:
      dataBuffers - the byte buffers to write into this buffer
      Returns:
      this buffer
    • write

      public Netty5DataBuffer write(ByteBuffer... buffers)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: DataBuffer
      Write one or more ByteBuffer to this buffer, starting at the current writing position.
      Specified by:
      write in interface DataBuffer
      Parameters:
      buffers - the byte buffers to write into this buffer
      Returns:
      this buffer
    • write

      public Netty5DataBuffer write(io.netty5.buffer.Buffer... buffers)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Writes one or more Netty 5 Buffers to this buffer, starting at the current writing position.
      Parameters:
      buffers - the buffers to write into this buffer
      Returns:
      this buffer
    • write

      public DataBuffer write(CharSequence charSequence, Charset charset)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: DataBuffer
      Write the given CharSequence using the given Charset, starting at the current writing position.
      Specified by:
      write in interface DataBuffer
      Parameters:
      charSequence - the char sequence to write into this buffer
      charset - the charset to encode the char sequence with
      Returns:
      this buffer
    • slice

      @Deprecated public DataBuffer slice(int index, int length)
      Deprecated.
      Create a new DataBuffer whose contents is a shared subsequence of this data buffer's content. Data between this data buffer and the returned buffer is shared; though changes in the returned buffer's position will not be reflected in the reading nor writing position of this data buffer.

      Note that this method will not call DataBufferUtils.retain(DataBuffer) on the resulting slice: the reference count will not be increased.

      Note that due to the lack of a slice method in Netty 5's Buffer, this implementation returns a copy that does not share its contents with this buffer.

      Specified by:
      slice in interface DataBuffer
      Parameters:
      index - the index at which to start the slice
      length - the length of the slice
      Returns:
      the specified slice of this data buffer
    • split

      public DataBuffer split(int index)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: DataBuffer
      Splits this data buffer into two at the given index.

      Data that precedes the index will be returned in a new buffer, while this buffer will contain data that follows after index. Memory between the two buffers is shared, but independent and cannot overlap (unlike slice).

      The read and write position of the returned buffer are truncated to fit within the buffers capacity if necessary. The positions of this buffer are set to 0 if they are smaller than index.

      Specified by:
      split in interface DataBuffer
      Parameters:
      index - the index at which it should be split
      Returns:
      a new data buffer, containing the bytes from index 0 to index
    • asByteBuffer

      @Deprecated public ByteBuffer asByteBuffer()
      Deprecated.
      Description copied from interface: DataBuffer
      Expose this buffer's bytes as a ByteBuffer. Data between this DataBuffer and the returned ByteBuffer is shared; though changes in the returned buffer's position will not be reflected in the reading nor writing position of this data buffer.
      Specified by:
      asByteBuffer in interface DataBuffer
      Returns:
      this data buffer as a byte buffer
    • asByteBuffer

      @Deprecated public ByteBuffer asByteBuffer(int index, int length)
      Deprecated.
      Description copied from interface: DataBuffer
      Expose a subsequence of this buffer's bytes as a ByteBuffer. Data between this DataBuffer and the returned ByteBuffer is shared; though changes in the returned buffer's position will not be reflected in the reading nor writing position of this data buffer.
      Specified by:
      asByteBuffer in interface DataBuffer
      Parameters:
      index - the index at which to start the byte buffer
      length - the length of the returned byte buffer
      Returns:
      this data buffer as a byte buffer
    • toByteBuffer

      @Deprecated public ByteBuffer toByteBuffer(int index, int length)
      Deprecated.
      Description copied from interface: DataBuffer
      Returns a ByteBuffer representation of a subsequence of this buffer's bytes. Data between this DataBuffer and the returned ByteBuffer is not shared.
      Specified by:
      toByteBuffer in interface DataBuffer
      Returns:
      this data buffer as a byte buffer
      See Also:
    • toByteBuffer

      public void toByteBuffer(int srcPos, ByteBuffer dest, int destPos, int length)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: DataBuffer
      Copies the given length from this data buffer into the given destination ByteBuffer, beginning at the given source position, and the given destination position in the destination byte buffer.
      Specified by:
      toByteBuffer in interface DataBuffer
      Parameters:
      srcPos - the position of this data buffer from where copying should start
      dest - the destination byte buffer
      destPos - the position in dest to where copying should start
      length - the amount of data to copy
    • readableByteBuffers

      public DataBuffer.ByteBufferIterator readableByteBuffers()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: DataBuffer
      Returns a closeable iterator over each ByteBuffer in this data buffer that can be read. Calling this method is more efficient than DataBuffer.toByteBuffer(), as no data is copied. However, the byte buffers provided can only be used during the iteration.

      Note that the returned iterator must be used in a try-with-resources clause or explicitly closed.

      Specified by:
      readableByteBuffers in interface DataBuffer
      Returns:
      a closeable iterator over the readable byte buffers contained in this data buffer
    • writableByteBuffers

      public DataBuffer.ByteBufferIterator writableByteBuffers()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: DataBuffer
      Returns a closeable iterator over each ByteBuffer in this data buffer that can be written to. The byte buffers provided can only be used during the iteration.

      Note that the returned iterator must be used in a try-with-resources clause or explicitly closed.

      Specified by:
      writableByteBuffers in interface DataBuffer
      Returns:
      a closeable iterator over the writable byte buffers contained in this data buffer
    • toString

      public String toString(Charset charset)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: DataBuffer
      Return this buffer's data a String using the specified charset. Default implementation delegates to toString(readPosition(), readableByteCount(), charset).
      Specified by:
      toString in interface DataBuffer
      Parameters:
      charset - the character set to use
      Returns:
      a string representation of all this buffers data
    • toString

      public String toString(int index, int length, Charset charset)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: DataBuffer
      Return a part of this buffer's data as a String using the specified charset.
      Specified by:
      toString in interface DataBuffer
      Parameters:
      index - the index at which to start the string
      length - the number of bytes to use for the string
      charset - the charset to use
      Returns:
      a string representation of a part of this buffers data
    • touch

      public Netty5DataBuffer touch(Object hint)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: TouchableDataBuffer
      Associate the given hint with the data buffer for debugging purposes.
      Specified by:
      touch in interface TouchableDataBuffer
      Returns:
      this buffer
    • close

      public void close()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: CloseableDataBuffer
      Closes this data buffer, freeing any resources.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface CloseableDataBuffer
    • equals

      public boolean equals(@Nullable Object other)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Overrides:
      toString in class Object