Package org.xnio

# Interface BufferAllocator<B extends Buffer>

Type Parameters:
  `B` - the buffer type

public interface BufferAllocator<B extends Buffer>
A simple allocator for buffers.

Author:
  David M. Lloyd

## Field Summary

Fields
Modifier and Type
Field
Description
`static final BufferAllocator<ByteBuffer>`
`BYTE_BUFFER_ALLOCATOR`
A simple allocator for heap-array-backed byte buffers.
`static final BufferAllocator<ByteBuffer>`
`DIRECT_BYTE_BUFFER_ALLOCATOR`
A simple allocator for direct byte buffers.

## Method Summary

Modifier and Type
Method
Description
`B`
`allocate(int size)`
Allocate a buffer of the given size.

## Field Details

### BYTE_BUFFER_ALLOCATOR

static final BufferAllocator<ByteBuffer> BYTE_BUFFER_ALLOCATOR
A simple allocator for heap-array-backed byte buffers.

### DIRECT_BYTE_BUFFER_ALLOCATOR

static final BufferAllocator<ByteBuffer> DIRECT_BYTE_BUFFER_ALLOCATOR
A simple allocator for direct byte buffers.

## Method Details

### allocate

B allocate(int size) throws IllegalArgumentException
Allocate a buffer of the given size.

Parameters:
  `size` - the size
Returns:
  the buffer
Throws:
  `IllegalArgumentException` - if the given buffer size is less than zero