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

public Class DefaultDataBuffer

extends Object
implements DataBuffer
Class Inheritance
All Implemented Interfaces
org.springframework.core.io.buffer.DataBuffer
Known Direct Subclasses
org.springframework.core.io.buffer.DefaultDataBuffer.SlicedDefaultDataBuffer
Imports
java.nio.ByteBuffer, java.nio.charset.Charset, java.util.Arrays, .NoSuchElementException, java.util.function.IntPredicate, org.springframework.lang.Nullable, org.springframework.util.Assert, .ObjectUtils

Default implementation of the DataBuffer interface that uses a ByteBuffer internally. with separate read and write positions. Constructed using the DefaultDataBufferFactory.

Inspired by Netty's ByteBuf. Introduced so that non-Netty runtimes (i.e. Servlet) do not require Netty on the classpath.

Authors
Arjen Poutsma, Juergen Hoeller, Brian Clozel
Since
5.0
See Also
DefaultDataBufferFactory

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class

Field Summary

Modifier and TypeField and Description
private ByteBuffer
private int
private static final int
private final DefaultDataBufferFactory
private static final int
private int
private int

Constructor Summary

AccessConstructor and Description
private
DefaultDataBuffer(DefaultDataBufferFactory dataBufferFactory, ByteBuffer byteBuffer)

Method Summary

Modifier and TypeMethod and Description
private static ByteBuffer
allocate(int capacity, boolean direct)

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.
private void
assertIndex(boolean expression, String format, Object... args)

private int
calculateCapacity(int neededCapacity)

Calculate the capacity of the buffer.

public int
capacity()

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

Return the number of bytes that this buffer can contain.
public DataBuffer
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.
private void
checkIndex(int index, int length)

private void
checkIndex(int index)

private void
checkLength(int length)

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

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 DefaultDataBufferFactory
factory()

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

Return the DataBufferFactory that created this buffer.
pack-priv static DefaultDataBuffer
pack-priv static DefaultDataBuffer
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 ByteBuffer

Returns:

the wrapped byte buffer
getNativeBuffer
()

Directly exposes the native ByteBuffer that this buffer is based on also updating the ByteBuffer's position and limit to match the current readPosition() and readableByteCount().

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
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 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 DefaultDataBuffer
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 DefaultDataBuffer
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 DefaultDataBuffer
readPosition(int
the new read position
readPosition
)

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

Set the position from which this buffer will read.
private void
setCapacity(int newCapacity)

private void
public DefaultDataBuffer
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 DataBuffer
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(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 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 DefaultDataBuffer
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 DefaultDataBuffer
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 DefaultDataBuffer
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 DefaultDataBuffer
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 DefaultDataBuffer
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.
private void
write(ByteBuffer source)

public int
writePosition()

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

Return the position to which this buffer will write.
public DefaultDataBuffer
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

byteBufferback to summary
private ByteBuffer byteBuffer
capacityback to summary
private int capacity
CAPACITY_THRESHOLDback to summary
private static final int CAPACITY_THRESHOLD
dataBufferFactoryback to summary
private final DefaultDataBufferFactory dataBufferFactory
MAX_CAPACITYback to summary
private static final int MAX_CAPACITY
readPositionback to summary
private int readPosition
writePositionback to summary
private int writePosition

Constructor Detail

DefaultDataBufferback to summary
private DefaultDataBuffer(DefaultDataBufferFactory dataBufferFactory, ByteBuffer byteBuffer)

Method Detail

allocateback to summary
private static ByteBuffer allocate(int capacity, boolean direct)
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
assertIndexback to summary
private void assertIndex(boolean expression, String format, Object... args)
calculateCapacityback to summary
private int calculateCapacity(int neededCapacity)

Calculate the capacity of the buffer.

See Also
io.netty.buffer.AbstractByteBufAllocator#calculateNewCapacity(int, int)
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 DataBuffer 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:DataBuffer

this buffer

Annotations
@Override
@Deprecated
checkIndexback to summary
private void checkIndex(int index, int length)
checkIndexback to summary
private void checkIndex(int index)
checkLengthback to summary
private void checkLength(int length)
ensureWritableback to summary
public DataBuffer ensureWritable(int length)

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
length: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 DefaultDataBufferFactory 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:DefaultDataBufferFactory

the creating buffer factory

Annotations
@Override
fromEmptyByteBufferback to summary
pack-priv static DefaultDataBuffer fromEmptyByteBuffer(DefaultDataBufferFactory dataBufferFactory, ByteBuffer byteBuffer)
fromFilledByteBufferback to summary
pack-priv static DefaultDataBuffer fromFilledByteBuffer(DefaultDataBufferFactory dataBufferFactory, ByteBuffer byteBuffer)
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 ByteBuffer getNativeBuffer()

Directly exposes the native ByteBuffer that this buffer is based on also updating the ByteBuffer's position and limit to match the current readPosition() and readableByteCount().

Returns:ByteBuffer

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 the 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
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
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 DefaultDataBuffer 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:DefaultDataBuffer

this buffer

Annotations
@Override
readback to summary
public DefaultDataBuffer 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:DefaultDataBuffer

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 DefaultDataBuffer 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:DefaultDataBuffer

this buffer

Annotations
@Override
setCapacityback to summary
private void setCapacity(int newCapacity)
setNativeBufferback to summary
private void setNativeBuffer(ByteBuffer byteBuffer)
sliceback to summary
public DefaultDataBuffer 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:DefaultDataBuffer

the specified slice of this data buffer

Annotations
@Override
@Deprecated
splitback to summary
public DataBuffer 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:DataBuffer

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(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.

Returns:String

a string representation of the object.

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 DefaultDataBuffer 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:DefaultDataBuffer

this buffer

Annotations
@Override
writeback to summary
public DefaultDataBuffer 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:DefaultDataBuffer

this buffer

Annotations
@Override
writeback to summary
public DefaultDataBuffer 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:DefaultDataBuffer

this buffer

Annotations
@Override
writeback to summary
public DefaultDataBuffer 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:DefaultDataBuffer

this buffer

Annotations
@Override
writeback to summary
public DefaultDataBuffer 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:DefaultDataBuffer

this buffer

Annotations
@Override
writeback to summary
private void write(ByteBuffer source)
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 DefaultDataBuffer 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:DefaultDataBuffer

this buffer

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

private final Class DefaultDataBuffer.ByteBufferIterator

extends Object
implements ByteBufferIterator
Class Inheritance
  • java.lang.Object
  • org.springframework.core.io.buffer.DefaultDataBuffer.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 boolean

Constructor Summary

AccessConstructor and Description
public

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

bufferback to summary
private final ByteBuffer buffer
hasNextback to summary
private boolean hasNext

Constructor Detail

ByteBufferIteratorback to summary
public ByteBufferIterator(ByteBuffer buffer)

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
org.springframework.core.io.buffer back to summary

private Class DefaultDataBuffer.SlicedDefaultDataBuffer

extends DefaultDataBuffer
Class Inheritance

Constructor Summary

AccessConstructor and Description
pack-priv
SlicedDefaultDataBuffer(ByteBuffer byteBuffer, DefaultDataBufferFactory dataBufferFactory, int length)

Method Summary

Modifier and TypeMethod and Description
public DefaultDataBuffer
capacity(int
the new capacity
newCapacity
)

Overrides org.springframework.core.io.buffer.DefaultDataBuffer.capacity.

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

Set the number of bytes that this buffer can contain.
Inherited from org.springframework.core.io.buffer.DefaultDataBuffer:
asByteBufferasByteBuffercapacityensureWritableequalsfactoryfromEmptyByteBufferfromFilledByteBuffergetBytegetNativeBufferhashCodeindexOflastIndexOfreadreadreadreadableByteBuffersreadableByteCountreadPositionreadPositionslicesplittoByteBuffertoByteBuffertoStringtoStringwritableByteBufferswritableByteCountwritewritewritewritewritewritePositionwritePosition

Constructor Detail

SlicedDefaultDataBufferback to summary
pack-priv SlicedDefaultDataBuffer(ByteBuffer byteBuffer, DefaultDataBufferFactory dataBufferFactory, int length)

Method Detail

capacityback to summary
public DefaultDataBuffer capacity(int newCapacity)

Overrides org.springframework.core.io.buffer.DefaultDataBuffer.capacity.

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

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

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
newCapacity:int

the new capacity

Returns:DefaultDataBuffer

this buffer

Annotations
@Override
@SuppressWarnings:deprecation