org.jboss.netty.buffer

## Interface ChannelBufferFactory

All Known Implementing Classes:
  AbstractChannelBufferFactory, DirectChannelBufferFactory, HeapChannelBufferFactory

    public interface ChannelBufferFactory

A factory that creates or pools `ChannelBuffer`s.

### Method Summary

Methods
`ChannelBuffer` `getBuffer(byte[] array, int offset, int length)` Returns a `ChannelBuffer` whose content is equal to the sub-region of the specified `array`.
`ChannelBuffer` `getBuffer(ByteBuffer nioBuffer)` Returns a `ChannelBuffer` whose content is equal to the sub-region of the specified `nioBuffer`.
`ChannelBuffer` `getBuffer(ByteOrder endianness, byte[] array, int offset, int length)` Returns a `ChannelBuffer` whose content is equal to the sub-region of the specified `array`.
`ChannelBuffer` `getBuffer(ByteOrder endianness, int capacity)` Returns a `ChannelBuffer` with the specified `endianness` and `capacity`.
`ChannelBuffer` `getBuffer(int capacity)` Returns a `ChannelBuffer` with the specified `capacity`.
`ByteOrder` `getDefaultOrder()` Returns the default endianness of the `ChannelBuffer` which is returned by `getBuffer(int)`.

### Method Detail

#### getBuffer

    ChannelBuffer getBuffer(int capacity)

Returns a `ChannelBuffer` with the specified `capacity`. This method is identical to `getBuffer(getDefaultOrder(), capacity)`.

Parameters:
  `capacity` - the capacity of the returned `ChannelBuffer`
Returns:
  a `ChannelBuffer` with the specified `capacity`, whose `readerIndex` and `writerIndex` are `0`

#### getBuffer

    ChannelBuffer getBuffer(ByteOrder endianness,
                          int capacity)

Returns a `ChannelBuffer` with the specified `endianness` and `capacity`.

Parameters:
  `endianness` - the endianness of the returned `ChannelBuffer`
  `capacity` - the capacity of the returned `ChannelBuffer`
Returns:
  a `ChannelBuffer` with the specified `endianness` and `capacity`, whose `readerIndex` and `writerIndex` are `0`

#### getBuffer

    ChannelBuffer getBuffer(byte[] array,
                          int offset,
                          int length)

Returns a `ChannelBuffer` whose content is equal to the sub-region of the specified `array`. Depending on the factory implementation, the returned buffer could wrap the `array` or create a new copy of the `array`. This method is identical to `getBuffer(getDefaultOrder(), array, offset, length)`.

Parameters:
  `array` - the byte array
  `offset` - the offset of the byte array
  `length` - the length of the byte array
Returns:
  a `ChannelBuffer` with the specified content, whose `readerIndex` and `writerIndex` are `0` and `(length - offset)` respectively

#### getBuffer

    ChannelBuffer getBuffer(ByteOrder endianness,
                          byte[] array,
                          int offset,
                          int length)

Returns a `ChannelBuffer` whose content is equal to the sub-region of the specified `array`. Depending on the factory implementation, the returned buffer could wrap the `array` or create a new copy of the `array`.

Parameters:
  `endianness` - the endianness of the returned `ChannelBuffer`
  `array` - the byte array
  `offset` - the offset of the byte array
  `length` - the length of the byte array
Returns:
  a `ChannelBuffer` with the specified content, whose `readerIndex` and `writerIndex` are `0` and `(length - offset)` respectively

#### getBuffer

    ChannelBuffer getBuffer(ByteBuffer nioBuffer)

Returns a `ChannelBuffer` whose content is equal to the sub-region of the specified `nioBuffer`. Depending on the factory implementation, the returned buffer could wrap the `nioBuffer` or create a new copy of the `nioBuffer`.

Parameters:
  `nioBuffer` - the NIO `ByteBuffer`
Returns:
  a `ChannelBuffer` with the specified content, whose `readerIndex` and `writerIndex` are `0` and `nioBuffer.remaining()` respectively

#### getDefaultOrder

    ByteOrder getDefaultOrder()

Returns the default endianness of the `ChannelBuffer` which is returned by `getBuffer(int)`.

Returns:
  the default endianness of the `ChannelBuffer` which is returned by `getBuffer(int)`