类 DefaultDataBufferFactory
java.lang.Object
cn.taketoday.core.io.buffer.DefaultDataBufferFactory
- 所有已实现的接口:
DataBufferFactory
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.- 从以下版本开始:
- 4.0
- 作者:
- Arjen Poutsma
-
字段概要
字段修饰符和类型字段说明static final intThe default capacity when none is specified.private final intprivate final booleanstatic final DefaultDataBufferFactoryShared instance based on the default constructor. -
构造器概要
构造器构造器说明Creates a newDefaultDataBufferFactorywith default settings.DefaultDataBufferFactory(boolean preferDirect) Creates a newDefaultDataBufferFactory, indicating whether direct buffers should be created byallocateBuffer()andallocateBuffer(int).DefaultDataBufferFactory(boolean preferDirect, int defaultInitialCapacity) Creates a newDefaultDataBufferFactory, indicating whether direct buffers should be created byallocateBuffer()andallocateBuffer(int), and what the capacity is to be used forallocateBuffer(). -
方法概要
修饰符和类型方法说明Allocate a data buffer of a default initial capacity.allocateBuffer(int initialCapacity) Allocate a data buffer of the given initial capacity.booleanisDirect()Indicates whether this factory allocates direct buffers (i.e. non-heap, native memory).join(List<? extends DataBuffer> dataBuffers) Return a newDataBuffercomposed of thedataBufferselements joined together.toString()wrap(byte[] bytes) Wrap the givenbytearray in aDataBuffer.wrap(ByteBuffer byteBuffer) Wrap the givenByteBufferin aDataBuffer.
-
字段详细资料
-
DEFAULT_INITIAL_CAPACITY
public static final int DEFAULT_INITIAL_CAPACITYThe default capacity when none is specified. -
preferDirect
private final boolean preferDirect -
defaultInitialCapacity
private final int defaultInitialCapacity
-
-
构造器详细资料
-
DefaultDataBufferFactory
public DefaultDataBufferFactory()Creates a newDefaultDataBufferFactorywith default settings.- 另请参阅:
-
DefaultDataBufferFactory
public DefaultDataBufferFactory(boolean preferDirect) Creates a newDefaultDataBufferFactory, indicating whether direct buffers should be created byallocateBuffer()andallocateBuffer(int).- 参数:
preferDirect-trueif direct buffers are to be preferred;falseotherwise
-
DefaultDataBufferFactory
public DefaultDataBufferFactory(boolean preferDirect, int defaultInitialCapacity) Creates a newDefaultDataBufferFactory, indicating whether direct buffers should be created byallocateBuffer()andallocateBuffer(int), and what the capacity is to be used forallocateBuffer().- 参数:
preferDirect-trueif direct buffers are to be preferred;falseotherwise
-
-
方法详细资料
-
allocateBuffer
从接口复制的说明:DataBufferFactoryAllocate a data buffer of a default initial capacity. Depending on the underlying implementation and its configuration, this will be heap-based or direct buffer.- 指定者:
allocateBuffer在接口中DataBufferFactory- 返回:
- the allocated buffer
-
allocateBuffer
从接口复制的说明:DataBufferFactoryAllocate a data buffer of the given initial capacity. Depending on the underlying implementation and its configuration, this will be heap-based or direct buffer.- 指定者:
allocateBuffer在接口中DataBufferFactory- 参数:
initialCapacity- the initial capacity of the buffer to allocate- 返回:
- the allocated buffer
-
wrap
从接口复制的说明:DataBufferFactory- 指定者:
wrap在接口中DataBufferFactory- 参数:
byteBuffer- the NIO byte buffer to wrap- 返回:
- the wrapped buffer
-
wrap
从接口复制的说明:DataBufferFactory- 指定者:
wrap在接口中DataBufferFactory- 参数:
bytes- the byte array to wrap- 返回:
- the wrapped buffer
-
join
Return a newDataBuffercomposed of thedataBufferselements 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
DefaultDataBufferto contain the data indataBuffers.- 指定者:
join在接口中DataBufferFactory- 参数:
dataBuffers- the data buffers to be composed- 返回:
- a buffer that is composed of the
dataBuffersargument
-
isDirect
public boolean isDirect()从接口复制的说明:DataBufferFactoryIndicates whether this factory allocates direct buffers (i.e. non-heap, native memory).- 指定者:
isDirect在接口中DataBufferFactory- 返回:
trueif this factory allocates direct buffers;falseotherwise
-
toString
-