org.apache.mina.common

Class SimpleByteBufferAllocator

Implemented Interfaces:
ByteBufferAllocator

public class SimpleByteBufferAllocator
extends java.lang.Object
implements ByteBufferAllocator

A simplistic ByteBufferAllocator which simply allocates a new buffer every time.

Constructor Summary

SimpleByteBufferAllocator()

Method Summary

ByteBuffer
allocate(int capacity, boolean direct)
Returns the buffer which is capable of the specified size.
void
dispose()
Dispose of this allocator.
ByteBuffer
wrap(java.nio.ByteBuffer nioBuffer)
Wraps the specified NIO java.nio.ByteBuffer into MINA buffer.

Constructor Details

SimpleByteBufferAllocator

public SimpleByteBufferAllocator()

Method Details

allocate

public ByteBuffer allocate(int capacity,
                           boolean direct)
Returns the buffer which is capable of the specified size.
Specified by:
allocate in interface ByteBufferAllocator
Parameters:
capacity - the capacity of the buffer
direct - true to get a direct buffer, false to get a heap buffer.

dispose

public void dispose()
Dispose of this allocator.
Specified by:
dispose in interface ByteBufferAllocator

wrap

public ByteBuffer wrap(java.nio.ByteBuffer nioBuffer)
Wraps the specified NIO java.nio.ByteBuffer into MINA buffer.
Specified by:
wrap in interface ByteBufferAllocator