org.apache.mina.util.byteaccess

## Class CompositeByteArrayRelativeReader

- java.lang.Object
- - org.apache.mina.util.byteaccess.CompositeByteArrayRelativeReader

- All Implemented Interfaces:
    IoRelativeReader

      public class CompositeByteArrayRelativeReader
      extends Object
      implements IoRelativeReader

  Provides restricted, relative, read-only access to the bytes in a `CompositeByteArray`. Using this interface has the advantage that it can be automatically determined when a component `ByteArray` can no longer be read, and thus components can be automatically freed. This makes it easier to use pooling for underlying `ByteArray`s.
  Author:
    Apache MINA Project

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected CompositeByteArray` | `cba` The underlying `CompositeByteArray`.
    `protected ByteArray.Cursor` | `cursor` A cursor of the underlying `CompositeByteArray`.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CompositeByteArrayRelativeReader(CompositeByteArray cba, boolean autoFree)` Creates a new instance of CompositeByteArrayRelativeReader.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `append(ByteArray ba)` Make a `ByteArray` available for access at the end of this object.
    `protected void` | `cursorPassedFirstComponent()` Called whenever the cursor has passed from the `cba`'s first component.
    `void` | `free()` Free all resources associated with this object.
    `byte` | `get()` Returns the byte at the current position in the buffer
    `void` | `get(IoBuffer bb)` places the data starting at current position into the supplied `IoBuffer`
    `char` | `getChar()` Gets a `char` and advances the reader.
    `double` | `getDouble()` Gets a `double` and advances the reader.
    `float` | `getFloat()` Gets a `float` and advances the reader.
    `int` | `getIndex()` Get the index that will be used for the next access.
    `int` | `getInt()` Gets an `int` and advances the reader.
    `long` | `getLong()` Gets a `long` and advances the reader.
    `int` | `getRemaining()`
    `short` | `getShort()` Gets a `short` and advances the reader.
    `boolean` | `hasRemaining()`
    `int` | `last()` Get the index after the last byte that can be accessed.
    `ByteOrder` | `order()`
    `void` | `skip(int length)` Advances the reader by the given number of bytes.
    `ByteArray` | `slice(int length)` Creates an array with a view of part of this array.

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

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

    - ### Methods inherited from interface org.apache.mina.util.byteaccess.IoRelativeReader

      `getRemaining, hasRemaining, order`

- - ### Field Detail

    - #### cba

          protected final CompositeByteArray cba

      The underlying `CompositeByteArray`.

    - #### cursor

          protected final ByteArray.Cursor cursor

      A cursor of the underlying `CompositeByteArray`. This cursor is never moved directly; its position only changes through calls to relative read or write methods.

  - ### Constructor Detail

    - #### CompositeByteArrayRelativeReader

          public CompositeByteArrayRelativeReader(CompositeByteArray cba,
                                          boolean autoFree)

      Creates a new instance of CompositeByteArrayRelativeReader.
      Parameters:
        `cba` - The backing ByteArray
        `autoFree` - If data should be freed once it has been passed in the list

  - ### Method Detail

    - #### cursorPassedFirstComponent

          protected void cursorPassedFirstComponent()

      Called whenever the cursor has passed from the `cba`'s first component. As the first component is no longer used, this provides a good opportunity for subclasses to perform some action on it (such as freeing it).

    - #### skip

          public void skip(int length)

      Description copied from interface: `IoRelativeReader`
      Advances the reader by the given number of bytes.
      Specified by:
        `skip` in interface `IoRelativeReader`

    - #### slice

          public ByteArray slice(int length)

      Description copied from interface: `IoRelativeReader`
      Creates an array with a view of part of this array.
      Specified by:
        `slice` in interface `IoRelativeReader`

    - #### get

          public byte get()

      Returns the byte at the current position in the buffer
      Specified by:
        `get` in interface `IoRelativeReader`

    - #### get

          public void get(IoBuffer bb)

      places the data starting at current position into the supplied `IoBuffer`
      Specified by:
        `get` in interface `IoRelativeReader`

    - #### getShort

          public short getShort()

      Description copied from interface: `IoRelativeReader`
      Gets a `short` and advances the reader.
      Specified by:
        `getShort` in interface `IoRelativeReader`

    - #### getInt

          public int getInt()

      Description copied from interface: `IoRelativeReader`
      Gets an `int` and advances the reader.
      Specified by:
        `getInt` in interface `IoRelativeReader`

    - #### getLong

          public long getLong()

      Description copied from interface: `IoRelativeReader`
      Gets a `long` and advances the reader.
      Specified by:
        `getLong` in interface `IoRelativeReader`

    - #### getFloat

          public float getFloat()

      Description copied from interface: `IoRelativeReader`
      Gets a `float` and advances the reader.
      Specified by:
        `getFloat` in interface `IoRelativeReader`

    - #### getDouble

          public double getDouble()

      Description copied from interface: `IoRelativeReader`
      Gets a `double` and advances the reader.
      Specified by:
        `getDouble` in interface `IoRelativeReader`

    - #### getChar

          public char getChar()

      Description copied from interface: `IoRelativeReader`
      Gets a `char` and advances the reader.
      Specified by:
        `getChar` in interface `IoRelativeReader`

    - #### getRemaining

          public final int getRemaining()

    - #### hasRemaining

          public final boolean hasRemaining()

    - #### order

          public ByteOrder order()

    - #### append

          public final void append(ByteArray ba)

      Make a `ByteArray` available for access at the end of this object.

    - #### free

          public final void free()

      Free all resources associated with this object.

    - #### getIndex

          public final int getIndex()

      Get the index that will be used for the next access.

    - #### last

          public final int last()

      Get the index after the last byte that can be accessed.

Copyright © 2004-2012 Apache MINA Project. All Rights Reserved.