org.jboss.netty.buffer

## Class AbstractChannelBufferFactory

- java.lang.Object
- - org.jboss.netty.buffer.AbstractChannelBufferFactory

- All Implemented Interfaces:
    ChannelBufferFactory
  Direct Known Subclasses:
    DirectChannelBufferFactory, HeapChannelBufferFactory

      public abstract class AbstractChannelBufferFactory
      extends Object
      implements ChannelBufferFactory

  A skeletal implementation of `ChannelBufferFactory`.

- - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `AbstractChannelBufferFactory()` Creates a new factory whose default `ByteOrder` is `ByteOrder.BIG_ENDIAN`.
    `protected` | `AbstractChannelBufferFactory(ByteOrder defaultOrder)` Creates a new factory with the specified default `ByteOrder`.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `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(int capacity)` Returns a `ChannelBuffer` with the specified `capacity`.
    `ByteOrder` | `getDefaultOrder()` Returns the default endianness of the `ChannelBuffer` which is returned by `ChannelBufferFactory.getBuffer(int)`.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.jboss.netty.buffer.ChannelBufferFactory

      `getBuffer, getBuffer, getBuffer`

- - ### Constructor Detail

    - #### AbstractChannelBufferFactory

          protected AbstractChannelBufferFactory()

      Creates a new factory whose default `ByteOrder` is `ByteOrder.BIG_ENDIAN`.

    - #### AbstractChannelBufferFactory

          protected AbstractChannelBufferFactory(ByteOrder defaultOrder)

      Creates a new factory with the specified default `ByteOrder`.
      Parameters:
        `defaultOrder` - the default `ByteOrder` of this factory

  - ### Method Detail

    - #### getBuffer

          public ChannelBuffer getBuffer(int capacity)

      Description copied from interface: `ChannelBufferFactory`
      Returns a `ChannelBuffer` with the specified `capacity`. This method is identical to `getBuffer(getDefaultOrder(), capacity)`.
      Specified by:
        `getBuffer` in interface `ChannelBufferFactory`
      Parameters:
        `capacity` - the capacity of the returned `ChannelBuffer`
      Returns:
        a `ChannelBuffer` with the specified `capacity`, whose `readerIndex` and `writerIndex` are `0`

    - #### getBuffer

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

      Description copied from interface: `ChannelBufferFactory`
      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)`.
      Specified by:
        `getBuffer` in interface `ChannelBufferFactory`
      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

    - #### getDefaultOrder

          public ByteOrder getDefaultOrder()

      Description copied from interface: `ChannelBufferFactory`
      Returns the default endianness of the `ChannelBuffer` which is returned by `ChannelBufferFactory.getBuffer(int)`.
      Specified by:
        `getDefaultOrder` in interface `ChannelBufferFactory`
      Returns:
        the default endianness of the `ChannelBuffer` which is returned by `ChannelBufferFactory.getBuffer(int)`

Copyright © 2008-2012 The Netty Project. All Rights Reserved.