org.apache.mina.codec

## Class IoBuffer

- java.lang.Object
- - org.apache.mina.codec.IoBuffer

    public final class IoBuffer
    extends Object

A proxy class used to manage ByteBuffers as if they were just a big ByteBuffer. We can add as many buffers as needed when accumulating data. From the user point of view, the methods are the very same as ByteBuffer provides.

IoBuffer instances are *not* thread safe.

The IoBuffer uses a singly linked list to handle the multiple Buffers. Thus sequential access is very efficient and random access is not. It fits well with the common usage patterns of IoBuffer.

Author:
  Apache MINA Project

### Method Summary

Methods
`IoBuffer` `add(ByteBuffer... buffers)` Add one or more ByteBuffer to the current IoBuffer
`static IoBuffer` `allocate(int capacity)`
`static IoBuffer` `allocateDirect(int capacity)`
`byte[]` `array()`
`int` `arrayOffset()`
`InputStream` `asInputStream()` Provides an input stream which is actually reading the `IoBuffer` instance.
`IoBuffer` `asReadOnlyBuffer()`
`int` `capacity()`
`IoBuffer` `clear()`
`IoBuffer` `compact()`
`IoBuffer` `duplicate()` Returns a copy of the current `IoBuffer`, with an independent copy of the position, limit and mark.
`boolean` `equals(Object ob)`
`IoBuffer` `extend(int size)` Extends the current IoBuffer capacity.
`IoBuffer` `flip()`
`byte` `get()`
`IoBuffer` `get(byte[] dst)`
`IoBuffer` `get(byte[] dst, int offset, int length)`
`byte` `get(int index)`
`char` `getChar()`
`char` `getChar(int index)`
`double` `getDouble()`
`double` `getDouble(int index)`
`float` `getFloat()`
`float` `getFloat(int index)`
`int` `getInt()`
`int` `getInt(int index)`
`long` `getLong()`
`long` `getLong(int index)`
`short` `getShort()`
`long` `getShort(int index)`
`int` `hashCode()`
`boolean` `hasRemaining()`
`boolean` `isDirect()`
`boolean` `isReadOnly()`
`int` `limit()`
`void` `limit(int newLimit)`
`void` `mark()`
`static IoBuffer` `newInstance()` Build a new instance of `IoBuffer`
`ByteOrder` `order()` Returns the byte order used by this IoBuffer when converting bytes from/to other primitive types.
`IoBuffer` `order(ByteOrder bo)` Sets the byte order of this IoBuffer.
`int` `position()`
`void` `position(int newPosition)`
`IoBuffer` `put(byte b)`
`IoBuffer` `put(byte[] src)`
`IoBuffer` `put(byte[] src, int offset, int length)`
`IoBuffer` `put(ByteBuffer src)`
`IoBuffer` `put(int index, byte value)`
`IoBuffer` `put(IoBuffer src)`
`IoBuffer` `putChar(char value)`
`IoBuffer` `putChar(int index, char value)`
`IoBuffer` `putDouble(double value)`
`IoBuffer` `putDouble(int index, double value)`
`IoBuffer` `putFloat(float value)`
`IoBuffer` `putFloat(int index, float value)`
`IoBuffer` `putInt(int value)`
`IoBuffer` `putInt(int index, int value)`
`IoBuffer` `putLong(int index, long value)`
`IoBuffer` `putLong(long value)`
`IoBuffer` `putShort(int index, short value)`
`IoBuffer` `putShort(short value)`
`int` `remaining()`
`IoBuffer` `reset()`
`IoBuffer` `rewind()`
`IoBuffer` `slice()`
`String` `toString()`
`static IoBuffer` `wrap(byte[]... arrays)`
`static IoBuffer` `wrap(byte[] array, int offset, int length)`
`static IoBuffer` `wrap(ByteBuffer... buffers)` Wraps ByteBuffers into a new IoBuffer

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

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

### Method Detail

#### allocate

    public static IoBuffer allocate(int capacity)

See Also:
  `ByteBuffer.allocate(int)`

#### allocateDirect

    public static IoBuffer allocateDirect(int capacity)

See Also:
  `ByteBuffer.allocateDirect(int)`

#### newInstance

    public static IoBuffer newInstance()

Build a new instance of `IoBuffer`

Returns:
  a new instance of `IoBuffer`

#### wrap

    public static IoBuffer wrap(byte[]... arrays)

See Also:
  `ByteBuffer.wrap(byte[])`

#### wrap

    public static IoBuffer wrap(byte[] array,
                int offset,
                int length)

See Also:
  `ByteBuffer.wrap(byte[], int, int)`

#### wrap

    public static IoBuffer wrap(ByteBuffer... buffers)

Wraps ByteBuffers into a new IoBuffer

Parameters:
  `buffers` - the ByteBuffers to wrap
Returns:
  the new `IoBuffer`

#### add

    public IoBuffer add(ByteBuffer... buffers)

Add one or more ByteBuffer to the current IoBuffer

Parameters:
  `buffers` - the ByteBuffers to add
Returns:
  the current `IoBuffer`

#### array

    public byte[] array()

See Also:
  `ByteBuffer.array()`

#### arrayOffset

    public int arrayOffset()

See Also:
  `ByteBuffer.arrayOffset()`

#### asInputStream

    public InputStream asInputStream()

Provides an input stream which is actually reading the `IoBuffer` instance.

Further reads on the returned InputStream move the reading head of the `IoBuffer` instance used for it's creation

Returns:
  an input stream

#### asReadOnlyBuffer

    public IoBuffer asReadOnlyBuffer()

See Also:
  `ByteBuffer.asReadOnlyBuffer()`

#### capacity

    public int capacity()

See Also:
  `Buffer.capacity()`

#### clear

    public IoBuffer clear()

See Also:
  `Buffer.clear()`

#### compact

    public IoBuffer compact()

See Also:
  `ByteBuffer.compact()`

#### duplicate

    public IoBuffer duplicate()

Returns a copy of the current `IoBuffer`, with an independent copy of the position, limit and mark.

Returns:
  the copied `IoBuffer`

#### equals

    public boolean equals(Object ob)

Overrides:
  `equals` in class `Object`

#### extend

    public IoBuffer extend(int size)

Extends the current IoBuffer capacity.

Parameters:
  `size` - the number of bytes to extend the current IoBuffer
Returns:
  the current `IoBuffer`

#### flip

    public IoBuffer flip()

See Also:
  `Buffer.flip()`

#### get

    public byte get()

See Also:
  `ByteBuffer.get()`

#### get

    public IoBuffer get(byte[] dst)

See Also:
  `ByteBuffer.get(byte[])`

#### get

    public IoBuffer get(byte[] dst,
               int offset,
               int length)

See Also:
  `ByteBuffer.get(byte[], int,int)`

#### get

    public byte get(int index)

See Also:
  `ByteBuffer.get(int)`

#### getChar

    public char getChar()

See Also:
  `ByteBuffer.getChar()`

#### getChar

    public char getChar(int index)

See Also:
  `ByteBuffer.getChar(int)`

#### getDouble

    public double getDouble()

See Also:
  `ByteBuffer.getDouble()`

#### getDouble

    public double getDouble(int index)

See Also:
  `ByteBuffer.getDouble(int)`

#### getFloat

    public float getFloat()

See Also:
  `ByteBuffer.getFloat()`

#### getFloat

    public float getFloat(int index)

See Also:
  `ByteBuffer.getFloat(int)`

#### getInt

    public int getInt()

See Also:
  `ByteBuffer.getInt()`

#### getInt

    public int getInt(int index)

See Also:
  `ByteBuffer.getInt(int)`

#### getLong

    public long getLong()

See Also:
  `ByteBuffer.getLong()`

#### getLong

    public long getLong(int index)

See Also:
  `ByteBuffer.getLong(int)`

#### getShort

    public short getShort()

See Also:
  `ByteBuffer.getShort()`

#### getShort

    public long getShort(int index)

See Also:
  `ByteBuffer.getShort(int)`

#### hashCode

    public int hashCode()

Overrides:
  `hashCode` in class `Object`

#### hasRemaining

    public boolean hasRemaining()

See Also:
  `Buffer.hasRemaining()`

#### isDirect

    public boolean isDirect()

See Also:
  `ByteBuffer.isDirect()`

#### isReadOnly

    public boolean isReadOnly()

See Also:
  `Buffer.isReadOnly()`

#### limit

    public int limit()

See Also:
  `Buffer.limit()`

#### limit

    public void limit(int newLimit)

See Also:
  `Buffer.limit(int)`

#### mark

    public void mark()

See Also:
  `Buffer.mark()`

#### order

    public ByteOrder order()

Returns the byte order used by this IoBuffer when converting bytes from/to other primitive types.

The default byte order of byte buffer is always `BIG_ENDIAN`

Returns:
  the byte order used by this IoBuffer when converting bytes from/to other primitive types.
See Also:
  `ByteBuffer.order()`

#### order

    public IoBuffer order(ByteOrder bo)

Sets the byte order of this IoBuffer.

Parameters:
  `bo` - the byte order to set. If `null` then the order will be `LITTLE_ENDIAN`.
Returns:
  this IoBuffer.
See Also:
  `ByteBuffer.order(ByteOrder)`

#### position

    public int position()

See Also:
  `Buffer.position()`

#### position

    public void position(int newPosition)

See Also:
  `Buffer.position(int)`

#### put

    public IoBuffer put(byte b)

See Also:
  `ByteBuffer.put(byte)`

#### put

    public IoBuffer put(byte[] src)

See Also:
  `ByteBuffer.put(byte[])`

#### put

    public IoBuffer put(ByteBuffer src)

See Also:
  `ByteBuffer.put(ByteBuffer)`

#### put

    public IoBuffer put(IoBuffer src)

See Also:
  `ByteBuffer.put(ByteBuffer)`

#### put

    public IoBuffer put(byte[] src,
               int offset,
               int length)

See Also:
  `ByteBuffer.put(byte[], int, int)`

#### put

    public IoBuffer put(int index,
               byte value)

See Also:
  `ByteBuffer.put(int, byte)`

#### putChar

    public IoBuffer putChar(char value)

See Also:
  `ByteBuffer.putChar(char)`

#### putChar

    public IoBuffer putChar(int index,
                   char value)

See Also:
  `ByteBuffer.putChar(int, char)`

#### putDouble

    public IoBuffer putDouble(double value)

See Also:
  `ByteBuffer.putDouble(double)`

#### putDouble

    public IoBuffer putDouble(int index,
                     double value)

See Also:
  `ByteBuffer.putDouble(int, double)`

#### putFloat

    public IoBuffer putFloat(float value)

See Also:
  `ByteBuffer.putFloat(float)`

#### putFloat

    public IoBuffer putFloat(int index,
                    float value)

See Also:
  `ByteBuffer.putFloat(int, float)`

#### putInt

    public IoBuffer putInt(int value)

See Also:
  `ByteBuffer.putInt(int)`

#### putInt

    public IoBuffer putInt(int index,
                  int value)

See Also:
  `ByteBuffer.putInt(int, int)`

#### putLong

    public IoBuffer putLong(int index,
                   long value)

See Also:
  `ByteBuffer.putLong(int, long)`

#### putLong

    public IoBuffer putLong(long value)

See Also:
  `ByteBuffer.putLong(long)`

#### putShort

    public IoBuffer putShort(int index,
                    short value)

See Also:
  `ByteBuffer.putShort(int, short)`

#### putShort

    public IoBuffer putShort(short value)

See Also:
  `ByteBuffer.putShort(short)`

#### remaining

    public int remaining()

See Also:
  `Buffer.remaining()`

#### reset

    public IoBuffer reset()

See Also:
  `Buffer.reset()`

#### rewind

    public IoBuffer rewind()

See Also:
  `Buffer.rewind()`

#### slice

    public IoBuffer slice()

See Also:
  `ByteBuffer.slice()`

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`