Package org.apache.mina.core.buffer
Class SimpleBufferAllocator
- java.lang.Object
-
- org.apache.mina.core.buffer.SimpleBufferAllocator
-
- All Implemented Interfaces:
IoBufferAllocator
public class SimpleBufferAllocator extends Object implements IoBufferAllocator
A simplisticIoBufferAllocator
which simply allocates a new buffer every time.- Author:
- Apache MINA Project
-
-
Constructor Summary
Constructors Constructor Description SimpleBufferAllocator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IoBuffer
allocate(int capacity, boolean direct)
Returns the buffer which is capable of the specified size.ByteBuffer
allocateNioBuffer(int capacity, boolean direct)
Returns the NIO buffer which is capable of the specified size.void
dispose()
Dispose of this allocator.IoBuffer
wrap(ByteBuffer nioBuffer)
Wraps the specified NIOByteBuffer
into MINA buffer.
-
-
-
Method Detail
-
allocate
public IoBuffer allocate(int capacity, boolean direct)
Description copied from interface:IoBufferAllocator
Returns the buffer which is capable of the specified size.- Specified by:
allocate
in interfaceIoBufferAllocator
- Parameters:
capacity
- the capacity of the bufferdirect
- true to get a direct buffer, false to get a heap buffer.- Returns:
- The allocated
IoBuffer
-
allocateNioBuffer
public ByteBuffer allocateNioBuffer(int capacity, boolean direct)
Description copied from interface:IoBufferAllocator
Returns the NIO buffer which is capable of the specified size.- Specified by:
allocateNioBuffer
in interfaceIoBufferAllocator
- Parameters:
capacity
- the capacity of the bufferdirect
- true to get a direct buffer, false to get a heap buffer.- Returns:
- The allocated
ByteBuffer
-
wrap
public IoBuffer wrap(ByteBuffer nioBuffer)
Description copied from interface:IoBufferAllocator
Wraps the specified NIOByteBuffer
into MINA buffer.- Specified by:
wrap
in interfaceIoBufferAllocator
- Parameters:
nioBuffer
- TheByteBuffer
to wrap- Returns:
- The
IoBuffer
wrapping theByteBuffer
-
dispose
public void dispose()
Description copied from interface:IoBufferAllocator
Dispose of this allocator.- Specified by:
dispose
in interfaceIoBufferAllocator
-
-