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

public Class DefaultDataBufferFactory

extends Object
implements DataBufferFactory
Class Inheritance
All Implemented Interfaces
org.springframework.core.io.buffer.DataBufferFactory
Imports
java.nio.ByteBuffer, java.util.List, org.springframework.util.Assert

Default implementation of the DataBufferFactory interface. Allows for specification of the default initial capacity at construction time, as well as whether heap-based or direct buffers are to be preferred.
Author
Arjen Poutsma
Since
5.0

Field Summary

Modifier and TypeField and Description
public static final int
DEFAULT_INITIAL_CAPACITY

The default capacity when none is specified.

private final int
private final boolean
public static final DefaultDataBufferFactory
sharedInstance

Shared instance based on the default constructor.

Constructor Summary

AccessConstructor and Description
public
DefaultDataBufferFactory()

Creates a new DefaultDataBufferFactory with default settings.

public
DefaultDataBufferFactory(boolean
true if direct buffers are to be preferred; false otherwise
preferDirect
)

Creates a new DefaultDataBufferFactory, indicating whether direct buffers should be created by allocateBuffer() and allocateBuffer(int).

public
DefaultDataBufferFactory(boolean
true if direct buffers are to be preferred; false otherwise
preferDirect
,
int defaultInitialCapacity)

Creates a new DefaultDataBufferFactory, indicating whether direct buffers should be created by allocateBuffer() and allocateBuffer(int), and what the capacity is to be used for allocateBuffer().

Method Summary

Modifier and TypeMethod and Description
public DefaultDataBuffer
allocateBuffer()

Implements org.springframework.core.io.buffer.DataBufferFactory.allocateBuffer.

Deprecated

Allocate a data buffer of a default initial capacity.

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

Implements org.springframework.core.io.buffer.DataBufferFactory.allocateBuffer.

Allocate a data buffer of the given initial capacity.

public boolean
isDirect()

Implements org.springframework.core.io.buffer.DataBufferFactory.isDirect.

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

public DefaultDataBuffer
join(List<? extends DataBuffer>
the data buffers to be composed
dataBuffers
)

Implements org.springframework.core.io.buffer.DataBufferFactory.join.

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

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public DefaultDataBuffer
wrap(ByteBuffer
the NIO byte buffer to wrap
byteBuffer
)

Implements org.springframework.core.io.buffer.DataBufferFactory.wrap.

Wrap the given ByteBuffer in a DataBuffer.

public DefaultDataBuffer
wrap(byte[]
the byte array to wrap
bytes
)

Implements org.springframework.core.io.buffer.DataBufferFactory.wrap.

Wrap the given byte array in a DataBuffer.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

DEFAULT_INITIAL_CAPACITYback to summary
public static final int DEFAULT_INITIAL_CAPACITY

The default capacity when none is specified.

See Also
DefaultDataBufferFactory(), DefaultDataBufferFactory(boolean)
defaultInitialCapacityback to summary
private final int defaultInitialCapacity
preferDirectback to summary
private final boolean preferDirect
sharedInstanceback to summary
public static final DefaultDataBufferFactory sharedInstance

Shared instance based on the default constructor.

Since
5.3

Constructor Detail

DefaultDataBufferFactoryback to summary
public DefaultDataBufferFactory()

Creates a new DefaultDataBufferFactory with default settings.

See Also
sharedInstance
DefaultDataBufferFactoryback to summary
public DefaultDataBufferFactory(boolean preferDirect)

Creates a new DefaultDataBufferFactory, indicating whether direct buffers should be created by allocateBuffer() and allocateBuffer(int).

Parameters
preferDirect:boolean

true if direct buffers are to be preferred; false otherwise

DefaultDataBufferFactoryback to summary
public DefaultDataBufferFactory(boolean preferDirect, int defaultInitialCapacity)

Creates a new DefaultDataBufferFactory, indicating whether direct buffers should be created by allocateBuffer() and allocateBuffer(int), and what the capacity is to be used for allocateBuffer().

Parameters
preferDirect:boolean

true if direct buffers are to be preferred; false otherwise

Method Detail

allocateBufferback to summary
public DefaultDataBuffer allocateBuffer()

Implements org.springframework.core.io.buffer.DataBufferFactory.allocateBuffer.

Doc from org.springframework.core.io.buffer.DataBufferFactory.allocateBuffer.

Deprecated

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

the allocated buffer

Annotations
@Override
@Deprecated
allocateBufferback to summary
public DefaultDataBuffer allocateBuffer(int initialCapacity)

Implements org.springframework.core.io.buffer.DataBufferFactory.allocateBuffer.

Doc from org.springframework.core.io.buffer.DataBufferFactory.allocateBuffer.

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

the allocated buffer

Annotations
@Override
isDirectback to summary
public boolean isDirect()

Implements org.springframework.core.io.buffer.DataBufferFactory.isDirect.

Doc from org.springframework.core.io.buffer.DataBufferFactory.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

Annotations
@Override
joinback to summary
public DefaultDataBuffer join(List<? extends DataBuffer> dataBuffers)

Implements org.springframework.core.io.buffer.DataBufferFactory.join.

Doc from org.springframework.core.io.buffer.DataBufferFactory.join.

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.

This implementation creates a single DefaultDataBuffer to contain the data in dataBuffers.

Parameters
dataBuffers:List<? extends DataBuffer>

the data buffers to be composed

Returns:DefaultDataBuffer

a buffer that is composed of the dataBuffers argument

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
wrapback to summary
public DefaultDataBuffer wrap(ByteBuffer byteBuffer)

Implements org.springframework.core.io.buffer.DataBufferFactory.wrap.

Doc from org.springframework.core.io.buffer.DataBufferFactory.wrap.

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

the wrapped buffer

Annotations
@Override
wrapback to summary
public DefaultDataBuffer wrap(byte[] bytes)

Implements org.springframework.core.io.buffer.DataBufferFactory.wrap.

Doc from org.springframework.core.io.buffer.DataBufferFactory.wrap.

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

the wrapped buffer

Annotations
@Override