Top Description Inners Fields Constructors Methods
org.springframework.core.io.buffer

public Class NettyDataBuffer

extends Object
implements PooledDataBuffer
Class Inheritance
All Implemented Interfaces
org.springframework.core.io.buffer.PooledDataBuffer, org.springframework.core.io.buffer.TouchableDataBuffer, org.springframework.core.io.buffer.DataBuffer
Imports
java.nio.ByteBuffer, java.nio.charset.Charset, .StandardCharsets, java.util.NoSuchElementException, java.util.function.IntPredicate, io.netty.buffer.ByteBuf, .ByteBufUtil, org.springframework.lang.Nullable, org.springframework.util.Assert, .ObjectUtils

Implementation of the DataBuffer interface that wraps a Netty 4 ByteBuf. Typically constructed with NettyDataBufferFactory.
Authors
Arjen Poutsma, Brian Clozel
Since
5.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private ByteBuf
private final NettyDataBufferFactory

Constructor Summary

AccessConstructor and Description
pack-priv
NettyDataBuffer(ByteBuf
the buffer to base this buffer on
byteBuf
,
NettyDataBufferFactory dataBufferFactory)

Create a new NettyDataBuffer based on the given ByteBuff.

Method Summary

Modifier and TypeMethod and Description
public ByteBuffer
asByteBuffer()

Implements org.springframework.core.io.buffer.DataBuffer.asByteBuffer.

Deprecated

Expose this buffer's bytes as a ByteBuffer.

public ByteBuffer
asByteBuffer(int
the index at which to start the byte buffer
index
,
int
the length of the returned byte buffer
length
)

Implements org.springframework.core.io.buffer.DataBuffer.asByteBuffer.

Deprecated

Expose a subsequence of this buffer's bytes as a ByteBuffer.

public int
capacity()

Implements org.springframework.core.io.buffer.DataBuffer.capacity.

Return the number of bytes that this buffer can contain.

public NettyDataBuffer
capacity(int
the new capacity
capacity
)

Implements org.springframework.core.io.buffer.DataBuffer.capacity.

Deprecated

Set the number of bytes that this buffer can contain.

public DataBuffer
ensureWritable(int
the writable capacity to check for
capacity
)

Implements org.springframework.core.io.buffer.DataBuffer.ensureWritable.

Ensure that the current buffer has enough writableByteCount() to write the amount of data given as an argument.

public boolean
equals(Object
the reference object with which to compare.
other
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public NettyDataBufferFactory
factory()

Implements org.springframework.core.io.buffer.DataBuffer.factory.

Return the DataBufferFactory that created this buffer.

public byte
getByte(int
the index at which the byte will be read
index
)

Implements org.springframework.core.io.buffer.DataBuffer.getByte.

Read a single byte at the given index from this data buffer.

public ByteBuf

Returns:

the wrapped byte buffer
getNativeBuffer
()

Directly exposes the native ByteBuf that this buffer is based on.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

private static boolean
public int
indexOf(IntPredicate
the predicate to match
predicate
,
int
the index to start the search from
fromIndex
)

Implements org.springframework.core.io.buffer.DataBuffer.indexOf.

Return the index of the first byte in this buffer that matches the given predicate.

public boolean
isAllocated()

Implements org.springframework.core.io.buffer.PooledDataBuffer.isAllocated.

Return true if this buffer is allocated; false if it has been deallocated.

public int
lastIndexOf(IntPredicate
the predicate to match
predicate
,
int
the index to start the search from
fromIndex
)

Implements org.springframework.core.io.buffer.DataBuffer.lastIndexOf.

Return the index of the last byte in this buffer that matches the given predicate.

public byte
read()

Implements org.springframework.core.io.buffer.DataBuffer.read.

Read a single byte from the current reading position from this data buffer.

public NettyDataBuffer
read(byte[]
the array into which the bytes are to be written
destination
)

Implements org.springframework.core.io.buffer.DataBuffer.read.

Read this buffer's data into the specified destination, starting at the current reading position of this buffer.

public NettyDataBuffer
read(byte[]
the array into which the bytes are to be written
destination
,
int
the index within destination of the first byte to be written
offset
,
int
the maximum number of bytes to be written in destination
length
)

Implements org.springframework.core.io.buffer.DataBuffer.read.

Read at most length bytes of this buffer into the specified destination, starting at the current reading position of this buffer.

public DataBuffer.ByteBufferIterator
readableByteBuffers()

Implements org.springframework.core.io.buffer.DataBuffer.readableByteBuffers.

Returns a closeable iterator over each ByteBuffer in this data buffer that can be read.

public int
readableByteCount()

Implements org.springframework.core.io.buffer.DataBuffer.readableByteCount.

Return the number of bytes that can be read from this data buffer.

public int
readPosition()

Implements org.springframework.core.io.buffer.DataBuffer.readPosition.

Return the position from which this buffer will read.

public NettyDataBuffer
readPosition(int
the new read position
readPosition
)

Implements org.springframework.core.io.buffer.DataBuffer.readPosition.

Set the position from which this buffer will read.

public boolean
release()

Implements org.springframework.core.io.buffer.PooledDataBuffer.release.

Decrease the reference count for this buffer by one, and deallocate it once the count reaches zero.

public PooledDataBuffer
retain()

Implements org.springframework.core.io.buffer.PooledDataBuffer.retain.

Increase the reference count for this buffer by one.

public NettyDataBuffer
retainedSlice(int
the index at which to start the slice
index
,
int
the length of the slice
length
)

Overrides default org.springframework.core.io.buffer.DataBuffer.retainedSlice.

Deprecated

Create a new DataBuffer whose contents is a shared, retained subsequence of this data buffer's content.

public NettyDataBuffer
slice(int
the index at which to start the slice
index
,
int
the length of the slice
length
)

Implements org.springframework.core.io.buffer.DataBuffer.slice.

Deprecated

Create a new DataBuffer whose contents is a shared subsequence of this data buffer's content.

public NettyDataBuffer
split(int
the index at which it should be split
index
)

Implements org.springframework.core.io.buffer.DataBuffer.split.

Splits this data buffer into two at the given index.

public ByteBuffer
toByteBuffer(int index, int length)

Implements org.springframework.core.io.buffer.DataBuffer.toByteBuffer.

Deprecated

Returns a ByteBuffer representation of a subsequence of this buffer's bytes.

public void
toByteBuffer(int
the position of this data buffer from where copying should start
srcPos
,
ByteBuffer
the destination byte buffer
dest
,
int
the position in dest to where copying should start
destPos
,
int
the amount of data to copy
length
)

Implements org.springframework.core.io.buffer.DataBuffer.toByteBuffer.

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.

public String
toString(Charset
the character set to use
charset
)

Overrides default org.springframework.core.io.buffer.DataBuffer.toString.

Return this buffer's data a String using the specified charset.

public String
toString(int
the index at which to start the string
index
,
int
the number of bytes to use for the string
length
,
Charset
the charset to use
charset
)

Implements org.springframework.core.io.buffer.DataBuffer.toString.

Return a part of this buffer's data as a String using the specified charset.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public PooledDataBuffer
touch(Object hint)

Implements org.springframework.core.io.buffer.PooledDataBuffer.touch.

Associate the given hint with the data buffer for debugging purposes.

public DataBuffer.ByteBufferIterator
writableByteBuffers()

Implements org.springframework.core.io.buffer.DataBuffer.writableByteBuffers.

Returns a closeable iterator over each ByteBuffer in this data buffer that can be written to.

public int
writableByteCount()

Implements org.springframework.core.io.buffer.DataBuffer.writableByteCount.

Return the number of bytes that can be written to this data buffer.

public NettyDataBuffer
write(byte
the byte to be written
b
)

Implements org.springframework.core.io.buffer.DataBuffer.write.

Write a single byte into this buffer at the current writing position.

public NettyDataBuffer
write(byte[]
the bytes to be written into this buffer
source
)

Implements org.springframework.core.io.buffer.DataBuffer.write.

Write the given source into this buffer, starting at the current writing position of this buffer.

public NettyDataBuffer
write(byte[]
the bytes to be written into this buffer
source
,
int
the index within source to start writing from
offset
,
int
the maximum number of bytes to be written from source
length
)

Implements org.springframework.core.io.buffer.DataBuffer.write.

Write at most length bytes of the given source into this buffer, starting at the current writing position of this buffer.

public NettyDataBuffer
write(DataBuffer...
the byte buffers to write into this buffer
dataBuffers
)

Implements org.springframework.core.io.buffer.DataBuffer.write.

Write one or more DataBuffers to this buffer, starting at the current writing position.

public NettyDataBuffer
write(ByteBuffer...
the byte buffers to write into this buffer
buffers
)

Implements org.springframework.core.io.buffer.DataBuffer.write.

Write one or more ByteBuffer to this buffer, starting at the current writing position.

public NettyDataBuffer

Returns:

this buffer
write
(ByteBuf...
the buffers to write into this buffer
byteBufs
)

Writes one or more Netty ByteBufs to this buffer, starting at the current writing position.

public DataBuffer
write(CharSequence
the char sequence to write into this buffer
charSequence
,
Charset
the charset to encode the char sequence with
charset
)

Overrides default org.springframework.core.io.buffer.DataBuffer.write.

Write the given CharSequence using the given Charset, starting at the current writing position.

public int
writePosition()

Implements org.springframework.core.io.buffer.DataBuffer.writePosition.

Return the position to which this buffer will write.

public NettyDataBuffer
writePosition(int
the new write position
writePosition
)

Implements org.springframework.core.io.buffer.DataBuffer.writePosition.

Set the position to which this buffer will write.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

byteBufback to summary
private ByteBuf byteBuf
dataBufferFactoryback to summary
private final NettyDataBufferFactory dataBufferFactory

Constructor Detail

NettyDataBufferback to summary
pack-priv NettyDataBuffer(ByteBuf byteBuf, NettyDataBufferFactory dataBufferFactory)

Create a new NettyDataBuffer based on the given ByteBuff.

Parameters
byteBuf:ByteBuf

the buffer to base this buffer on

Method Detail

asByteBufferback to summary
public ByteBuffer asByteBuffer()

Implements org.springframework.core.io.buffer.DataBuffer.asByteBuffer.

Doc from org.springframework.core.io.buffer.DataBuffer.asByteBuffer.

Deprecated

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.

Returns:ByteBuffer

this data buffer as a byte buffer

Annotations
@Override
@Deprecated
asByteBufferback to summary
public ByteBuffer asByteBuffer(int index, int length)

Implements org.springframework.core.io.buffer.DataBuffer.asByteBuffer.

Doc from org.springframework.core.io.buffer.DataBuffer.asByteBuffer.

Deprecated

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.

Parameters
index:int

the index at which to start the byte buffer

length:int

the length of the returned byte buffer

Returns:ByteBuffer

this data buffer as a byte buffer

Annotations
@Override
@Deprecated
capacityback to summary
public int capacity()

Implements org.springframework.core.io.buffer.DataBuffer.capacity.

Doc from org.springframework.core.io.buffer.DataBuffer.capacity.

Return the number of bytes that this buffer can contain.

Returns:int

the capacity

Annotations
@Override
capacityback to summary
public NettyDataBuffer capacity(int capacity)

Implements org.springframework.core.io.buffer.DataBuffer.capacity.

Doc from org.springframework.core.io.buffer.DataBuffer.capacity.

Deprecated

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.

Parameters
capacity:int

the new capacity

Returns:NettyDataBuffer

this buffer

Annotations
@Override
@Deprecated
ensureWritableback to summary
public DataBuffer ensureWritable(int capacity)

Implements org.springframework.core.io.buffer.DataBuffer.ensureWritable.

Doc from org.springframework.core.io.buffer.DataBuffer.ensureWritable.

Ensure that the current buffer has enough writableByteCount() to write the amount of data given as an argument. If not, the missing capacity will be added to the buffer.

Parameters
capacity:int

the writable capacity to check for

Returns:DataBuffer

this buffer

Annotations
@Override
equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
other:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
factoryback to summary
public NettyDataBufferFactory factory()

Implements org.springframework.core.io.buffer.DataBuffer.factory.

Doc from org.springframework.core.io.buffer.DataBuffer.factory.

Return the DataBufferFactory that created this buffer.

Returns:NettyDataBufferFactory

the creating buffer factory

Annotations
@Override
getByteback to summary
public byte getByte(int index)

Implements org.springframework.core.io.buffer.DataBuffer.getByte.

Doc from org.springframework.core.io.buffer.DataBuffer.getByte.

Read a single byte at the given index from this data buffer.

Parameters
index:int

the index at which the byte will be read

Returns:byte

the byte at the given index

Annotations
@Override
getNativeBufferback to summary
public ByteBuf getNativeBuffer()

Directly exposes the native ByteBuf that this buffer is based on.

Returns:ByteBuf

the wrapped byte buffer

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
hasNettyDataBuffersback to summary
private static boolean hasNettyDataBuffers(DataBuffer[] buffers)
indexOfback to summary
public int indexOf(IntPredicate predicate, int fromIndex)

Implements org.springframework.core.io.buffer.DataBuffer.indexOf.

Doc from org.springframework.core.io.buffer.DataBuffer.indexOf.

Return the index of the first byte in this buffer that matches the given predicate.

Parameters
predicate:IntPredicate

the predicate to match

fromIndex:int

the index to start the search from

Returns:int

the index of the first byte that matches predicate; or -1 if none match

Annotations
@Override
isAllocatedback to summary
public boolean isAllocated()

Implements org.springframework.core.io.buffer.PooledDataBuffer.isAllocated.

Doc from org.springframework.core.io.buffer.PooledDataBuffer.isAllocated.

Return true if this buffer is allocated; false if it has been deallocated.

Annotations
@Override
lastIndexOfback to summary
public int lastIndexOf(IntPredicate predicate, int fromIndex)

Implements org.springframework.core.io.buffer.DataBuffer.lastIndexOf.

Doc from org.springframework.core.io.buffer.DataBuffer.lastIndexOf.

Return the index of the last byte in this buffer that matches the given predicate.

Parameters
predicate:IntPredicate

the predicate to match

fromIndex:int

the index to start the search from

Returns:int

the index of the last byte that matches predicate; or -1 if none match

Annotations
@Override
readback to summary
public byte read()

Implements org.springframework.core.io.buffer.DataBuffer.read.

Doc from org.springframework.core.io.buffer.DataBuffer.read.

Read a single byte from the current reading position from this data buffer.

Returns:byte

the byte at this buffer's current reading position

Annotations
@Override
readback to summary
public NettyDataBuffer read(byte[] destination)

Implements org.springframework.core.io.buffer.DataBuffer.read.

Doc from org.springframework.core.io.buffer.DataBuffer.read.

Read this buffer's data into the specified destination, starting at the current reading position of this buffer.

Parameters
destination:byte[]

the array into which the bytes are to be written

Returns:NettyDataBuffer

this buffer

Annotations
@Override
readback to summary
public NettyDataBuffer read(byte[] destination, int offset, int length)

Implements org.springframework.core.io.buffer.DataBuffer.read.

Doc from org.springframework.core.io.buffer.DataBuffer.read.

Read at most length bytes of this buffer into the specified destination, starting at the current reading position of this buffer.

Parameters
destination:byte[]

the array into which the bytes are to be written

offset:int

the index within destination of the first byte to be written

length:int

the maximum number of bytes to be written in destination

Returns:NettyDataBuffer

this buffer

Annotations
@Override
readableByteBuffersback to summary
public DataBuffer.ByteBufferIterator readableByteBuffers()

Implements org.springframework.core.io.buffer.DataBuffer.readableByteBuffers.

Doc from org.springframework.core.io.buffer.DataBuffer.readableByteBuffers.

Returns a closeable iterator over each ByteBuffer in this data buffer that can be read. Calling this method is more efficient than 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.

Returns:DataBuffer.ByteBufferIterator

a closeable iterator over the readable byte buffers contained in this data buffer

Annotations
@Override
readableByteCountback to summary
public int readableByteCount()

Implements org.springframework.core.io.buffer.DataBuffer.readableByteCount.

Doc from org.springframework.core.io.buffer.DataBuffer.readableByteCount.

Return the number of bytes that can be read from this data buffer.

Returns:int

the readable byte count

Annotations
@Override
readPositionback to summary
public int readPosition()

Implements org.springframework.core.io.buffer.DataBuffer.readPosition.

Doc from org.springframework.core.io.buffer.DataBuffer.readPosition.

Return the position from which this buffer will read.

Returns:int

the read position

Annotations
@Override
readPositionback to summary
public NettyDataBuffer readPosition(int readPosition)

Implements org.springframework.core.io.buffer.DataBuffer.readPosition.

Doc from org.springframework.core.io.buffer.DataBuffer.readPosition.

Set the position from which this buffer will read.

Parameters
readPosition:int

the new read position

Returns:NettyDataBuffer

this buffer

Annotations
@Override
releaseback to summary
public boolean release()

Implements org.springframework.core.io.buffer.PooledDataBuffer.release.

Doc from org.springframework.core.io.buffer.PooledDataBuffer.release.

Decrease the reference count for this buffer by one, and deallocate it once the count reaches zero.

Returns:boolean

true if the buffer was deallocated; false otherwise

Annotations
@Override
retainback to summary
public PooledDataBuffer retain()

Implements org.springframework.core.io.buffer.PooledDataBuffer.retain.

Doc from org.springframework.core.io.buffer.PooledDataBuffer.retain.

Increase the reference count for this buffer by one.

Returns:PooledDataBuffer

this buffer

Annotations
@Override
retainedSliceback to summary
public NettyDataBuffer retainedSlice(int index, int length)

Overrides default org.springframework.core.io.buffer.DataBuffer.retainedSlice.

Doc from org.springframework.core.io.buffer.DataBuffer.retainedSlice.

Deprecated

Create a new DataBuffer whose contents is a shared, retained 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 unlike slice(int, int), this method will call DataBufferUtils#retain(DataBuffer) (or equivalent) on the resulting slice.

Parameters
index:int

the index at which to start the slice

length:int

the length of the slice

Returns:NettyDataBuffer

the specified, retained slice of this data buffer

Annotations
@Override
@Deprecated
sliceback to summary
public NettyDataBuffer slice(int index, int length)

Implements org.springframework.core.io.buffer.DataBuffer.slice.

Doc from org.springframework.core.io.buffer.DataBuffer.slice.

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.

Parameters
index:int

the index at which to start the slice

length:int

the length of the slice

Returns:NettyDataBuffer

the specified slice of this data buffer

Annotations
@Override
@Deprecated
splitback to summary
public NettyDataBuffer split(int index)

Implements org.springframework.core.io.buffer.DataBuffer.split.

Doc from org.springframework.core.io.buffer.DataBuffer.split.

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.

Parameters
index:int

the index at which it should be split

Returns:NettyDataBuffer

a new data buffer, containing the bytes from index 0 to index

Annotations
@Override
toByteBufferback to summary
public ByteBuffer toByteBuffer(int index, int length)

Implements org.springframework.core.io.buffer.DataBuffer.toByteBuffer.

Doc from org.springframework.core.io.buffer.DataBuffer.toByteBuffer.

Deprecated

Returns a ByteBuffer representation of a subsequence of this buffer's bytes. Data between this DataBuffer and the returned ByteBuffer is not shared.

Returns:ByteBuffer

this data buffer as a byte buffer

Annotations
@Override
@Deprecated
toByteBufferback to summary
public void toByteBuffer(int srcPos, ByteBuffer dest, int destPos, int length)

Implements org.springframework.core.io.buffer.DataBuffer.toByteBuffer.

Doc from org.springframework.core.io.buffer.DataBuffer.toByteBuffer.

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.

Parameters
srcPos:int

the position of this data buffer from where copying should start

dest:ByteBuffer

the destination byte buffer

destPos:int

the position in dest to where copying should start

length:int

the amount of data to copy

Annotations
@Override
toStringback to summary
public String toString(Charset charset)

Overrides default org.springframework.core.io.buffer.DataBuffer.toString.

Doc from org.springframework.core.io.buffer.DataBuffer.toString.

Return this buffer's data a String using the specified charset. Default implementation delegates to toString(readPosition(), readableByteCount(), charset).

Parameters
charset:Charset

the character set to use

Returns:String

a string representation of all this buffers data

Annotations
@Override
toStringback to summary
public String toString(int index, int length, Charset charset)

Implements org.springframework.core.io.buffer.DataBuffer.toString.

Doc from org.springframework.core.io.buffer.DataBuffer.toString.

Return a part of this buffer's data as a String using the specified charset.

Parameters
index:int

the index at which to start the string

length:int

the number of bytes to use for the string

charset:Charset

the charset to use

Returns:String

a string representation of a part of this buffers data

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
touchback to summary
public PooledDataBuffer touch(Object hint)

Implements org.springframework.core.io.buffer.PooledDataBuffer.touch.

Doc from org.springframework.core.io.buffer.PooledDataBuffer.touch.

Associate the given hint with the data buffer for debugging purposes.

Returns:PooledDataBuffer

this buffer

Annotations
@Override
writableByteBuffersback to summary
public DataBuffer.ByteBufferIterator writableByteBuffers()

Implements org.springframework.core.io.buffer.DataBuffer.writableByteBuffers.

Doc from org.springframework.core.io.buffer.DataBuffer.writableByteBuffers.

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.

Returns:DataBuffer.ByteBufferIterator

a closeable iterator over the writable byte buffers contained in this data buffer

Annotations
@Override
writableByteCountback to summary
public int writableByteCount()

Implements org.springframework.core.io.buffer.DataBuffer.writableByteCount.

Doc from org.springframework.core.io.buffer.DataBuffer.writableByteCount.

Return the number of bytes that can be written to this data buffer.

Returns:int

the writable byte count

Annotations
@Override
writeback to summary
public NettyDataBuffer write(byte b)

Implements org.springframework.core.io.buffer.DataBuffer.write.

Doc from org.springframework.core.io.buffer.DataBuffer.write.

Write a single byte into this buffer at the current writing position.

Parameters
b:byte

the byte to be written

Returns:NettyDataBuffer

this buffer

Annotations
@Override
writeback to summary
public NettyDataBuffer write(byte[] source)

Implements org.springframework.core.io.buffer.DataBuffer.write.

Doc from org.springframework.core.io.buffer.DataBuffer.write.

Write the given source into this buffer, starting at the current writing position of this buffer.

Parameters
source:byte[]

the bytes to be written into this buffer

Returns:NettyDataBuffer

this buffer

Annotations
@Override
writeback to summary
public NettyDataBuffer write(byte[] source, int offset, int length)

Implements org.springframework.core.io.buffer.DataBuffer.write.

Doc from org.springframework.core.io.buffer.DataBuffer.write.

Write at most length bytes of the given source into this buffer, starting at the current writing position of this buffer.

Parameters
source:byte[]

the bytes to be written into this buffer

offset:int

the index within source to start writing from

length:int

the maximum number of bytes to be written from source

Returns:NettyDataBuffer

this buffer

Annotations
@Override
writeback to summary
public NettyDataBuffer write(DataBuffer... dataBuffers)

Implements org.springframework.core.io.buffer.DataBuffer.write.

Doc from org.springframework.core.io.buffer.DataBuffer.write.

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.

Parameters
dataBuffers:DataBuffer[]

the byte buffers to write into this buffer

Returns:NettyDataBuffer

this buffer

Annotations
@Override
writeback to summary
public NettyDataBuffer write(ByteBuffer... buffers)

Implements org.springframework.core.io.buffer.DataBuffer.write.

Doc from org.springframework.core.io.buffer.DataBuffer.write.

Write one or more ByteBuffer to this buffer, starting at the current writing position.

Parameters
buffers:ByteBuffer[]

the byte buffers to write into this buffer

Returns:NettyDataBuffer

this buffer

Annotations
@Override
writeback to summary
public NettyDataBuffer write(ByteBuf... byteBufs)

Writes one or more Netty ByteBufs to this buffer, starting at the current writing position.

Parameters
byteBufs:ByteBuf[]

the buffers to write into this buffer

Returns:NettyDataBuffer

this buffer

writeback to summary
public DataBuffer write(CharSequence charSequence, Charset charset)

Overrides default org.springframework.core.io.buffer.DataBuffer.write.

Doc from org.springframework.core.io.buffer.DataBuffer.write.

Write the given CharSequence using the given Charset, starting at the current writing position.

Parameters
charSequence:CharSequence

the char sequence to write into this buffer

charset:Charset

the charset to encode the char sequence with

Returns:DataBuffer

this buffer

Annotations
@Override
writePositionback to summary
public int writePosition()

Implements org.springframework.core.io.buffer.DataBuffer.writePosition.

Doc from org.springframework.core.io.buffer.DataBuffer.writePosition.

Return the position to which this buffer will write.

Returns:int

the write position

Annotations
@Override
writePositionback to summary
public NettyDataBuffer writePosition(int writePosition)

Implements org.springframework.core.io.buffer.DataBuffer.writePosition.

Doc from org.springframework.core.io.buffer.DataBuffer.writePosition.

Set the position to which this buffer will write.

Parameters
writePosition:int

the new write position

Returns:NettyDataBuffer

this buffer

Annotations
@Override
org.springframework.core.io.buffer back to summary

private final Class NettyDataBuffer.ByteBufferIterator

extends Object
implements ByteBufferIterator
Class Inheritance
  • java.lang.Object
  • org.springframework.core.io.buffer.NettyDataBuffer.ByteBufferIterator
All Implemented Interfaces
org.springframework.core.io.buffer.DataBuffer.ByteBufferIterator, java.io.Closeable, java.lang.AutoCloseable, java.util.Iterator

Field Summary

Modifier and TypeField and Description
private final ByteBuffer[]
private int
private final boolean

Constructor Summary

AccessConstructor and Description
public
ByteBufferIterator(ByteBuffer[] byteBuffers, boolean readOnly)

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements org.springframework.core.io.buffer.DataBuffer.ByteBufferIterator.close.

Closes this stream and releases any system resources associated with it.

public boolean
hasNext()

Implements java.util.Iterator.hasNext.

Returns true if the iteration has more elements.

public ByteBuffer
next()

Implements java.util.Iterator.next.

Returns the next element in the iteration.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

byteBuffersback to summary
private final ByteBuffer[] byteBuffers
cursorback to summary
private int cursor
readOnlyback to summary
private final boolean readOnly

Constructor Detail

ByteBufferIteratorback to summary
public ByteBufferIterator(ByteBuffer[] byteBuffers, boolean readOnly)

Method Detail

closeback to summary
public void close()

Implements org.springframework.core.io.buffer.DataBuffer.ByteBufferIterator.close.

Doc from java.io.Closeable.close.

Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect.

As noted in AutoCloseable#close(), cases where the close may fail require careful attention. It is strongly advised to relinquish the underlying resources and to internally mark the Closeable as closed, prior to throwing the IOException.

Annotations
@Override
hasNextback to summary
public boolean hasNext()

Implements java.util.Iterator.hasNext.

Doc from java.util.Iterator.hasNext.

Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)

Returns:boolean

true if the iteration has more elements

Annotations
@Override
nextback to summary
public ByteBuffer next()

Implements java.util.Iterator.next.

Doc from java.util.Iterator.next.

Returns the next element in the iteration.

Returns:ByteBuffer

the next element in the iteration

Annotations
@Override