Class CompositeByteArrayRelativeReader

java.lang.Object
org.apache.mina.util.byteaccess.CompositeByteArrayRelativeBase
org.apache.mina.util.byteaccess.CompositeByteArrayRelativeReader
All Implemented Interfaces:
IoRelativeReader

public class CompositeByteArrayRelativeReader extends CompositeByteArrayRelativeBase 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 ByteArrays.
  • Field Details

    • autoFree

      private final boolean autoFree
      Whether or not to free component CompositeByteArrays when the cursor moves past them.
  • Constructor Details

    • 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 Details

    • cursorPassedFirstComponent

      protected void cursorPassedFirstComponent()
      Description copied from class: CompositeByteArrayRelativeBase
      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).
      Specified by:
      cursorPassedFirstComponent in class CompositeByteArrayRelativeBase
    • skip

      public void skip(int length)
      Advances the reader by the given number of bytes.
      Specified by:
      skip in interface IoRelativeReader
      Parameters:
      length - the number of bytes to skip
    • slice

      public ByteArray slice(int length)
      Specified by:
      slice in interface IoRelativeReader
      Parameters:
      length - The number of bytes to get
      Returns:
      an array with a view of part of this array.
    • get

      public byte get()
      Specified by:
      get in interface IoRelativeReader
      Returns:
      the byte at the current position in the buffer
    • get

      public void get(IoBuffer bb)
      places the data starting at current position into the supplied IoBuffer
      Specified by:
      get in interface IoRelativeReader
      Parameters:
      bb - The IoBuffer that will contain the read bytes
    • getShort

      public short getShort()
      Specified by:
      getShort in interface IoRelativeReader
      Returns:
      a short and advances the reader.
    • getInt

      public int getInt()
      Specified by:
      getInt in interface IoRelativeReader
      Returns:
      an int and advances the reader.
    • getLong

      public long getLong()
      Specified by:
      getLong in interface IoRelativeReader
      Returns:
      a long and advances the reader.
    • getFloat

      public float getFloat()
      Specified by:
      getFloat in interface IoRelativeReader
      Returns:
      a float and advances the reader.
    • getDouble

      public double getDouble()
      Specified by:
      getDouble in interface IoRelativeReader
      Returns:
      a double and advances the reader.
    • getChar

      public char getChar()
      Specified by:
      getChar in interface IoRelativeReader
      Returns:
      a char and advances the reader.