Top Description Methods
org.springframework.core.io.buffer

public Interface DataBufferFactory

Known Direct Implementers
org.springframework.core.io.buffer.DefaultDataBufferFactory, org.springframework.core.io.buffer.Netty5DataBufferFactory, org.springframework.core.io.buffer.NettyDataBufferFactory
Imports
java.nio.ByteBuffer, java.util.List

A factory for DataBuffers, allowing for allocation and wrapping of data buffers.
Author
Arjen Poutsma
Since
5.0
See Also
DataBuffer

Method Summary

Modifier and TypeMethod and Description
public DataBuffer

Returns:

the allocated buffer
allocateBuffer
()
Deprecated since 6.0. as of 6.0, in favor of allocateBuffer(int)

Allocate a data buffer of a default initial capacity.

public DataBuffer

Returns:

the allocated buffer
allocateBuffer
(int
the initial capacity of the buffer to allocate
initialCapacity
)

Allocate a data buffer of the given initial capacity.

public boolean

Returns:

true if this factory allocates direct buffers; false otherwise
isDirect
()

Indicates whether this factory allocates direct buffers (i.e. non-heap, native memory).

public DataBuffer

Returns:

a buffer that is composed of the dataBuffers argument
join
(List<? extends DataBuffer>
the data buffers to be composed
dataBuffers
)

Return a new DataBuffer composed of the dataBuffers elements joined together.

public DataBuffer

Returns:

the wrapped buffer
wrap
(ByteBuffer
the NIO byte buffer to wrap
byteBuffer
)

Wrap the given ByteBuffer in a DataBuffer.

public DataBuffer

Returns:

the wrapped buffer
wrap
(byte[]
the byte array to wrap
bytes
)

Wrap the given byte array in a DataBuffer.

Method Detail

allocateBufferback to summary
public DataBuffer allocateBuffer()

Deprecated

since 6.0.

as of 6.0, in favor of allocateBuffer(int)

Allocate a data buffer of a default initial capacity. Depending on the underlying implementation and its configuration, this will be heap-based or direct buffer.

Returns:DataBuffer

the allocated buffer

Annotations
@Deprecated
since:6.0
allocateBufferback to summary
public DataBuffer allocateBuffer(int initialCapacity)

Allocate a data buffer of the given initial capacity. Depending on the underlying implementation and its configuration, this will be heap-based or direct buffer.

Parameters
initialCapacity:int

the initial capacity of the buffer to allocate

Returns:DataBuffer

the allocated buffer

isDirectback to summary
public boolean isDirect()

Indicates whether this factory allocates direct buffers (i.e. non-heap, native memory).

Returns:boolean

true if this factory allocates direct buffers; false otherwise

Since
6.0
joinback to summary
public DataBuffer join(List<? extends DataBuffer> dataBuffers)

Return a new DataBuffer composed of the dataBuffers elements joined together. Depending on the implementation, the returned buffer may be a single buffer containing all data of the provided buffers, or it may be a true composite that contains references to the buffers.

Note that the given data buffers do not have to be released, as they are released as part of the returned composite.

Parameters
dataBuffers:List<? extends DataBuffer>

the data buffers to be composed

Returns:DataBuffer

a buffer that is composed of the dataBuffers argument

Since
5.0.3
wrapback to summary
public DataBuffer wrap(ByteBuffer byteBuffer)

Wrap the given ByteBuffer in a DataBuffer. Unlike allocating, wrapping does not use new memory.

Parameters
byteBuffer:ByteBuffer

the NIO byte buffer to wrap

Returns:DataBuffer

the wrapped buffer

wrapback to summary
public DataBuffer wrap(byte[] bytes)

Wrap the given byte array in a DataBuffer. Unlike allocating, wrapping does not use new memory.

Parameters
bytes:byte[]

the byte array to wrap

Returns:DataBuffer

the wrapped buffer