Class SeekableReadableChannelOverReadableChannel<A>

All Implemented Interfaces:
Closeable, AutoCloseable, Cloneable, Channel, HasArrayOps<A>, HasPosition, ReadableChannel<A>, ReadableSource<A>, SeekableReadableChannel<A>

public class SeekableReadableChannelOverReadableChannel<A> extends ReadableChannelDecoratorBase<A, ReadableChannel<A>> implements SeekableReadableChannel<A>
  • Field Details

    • basePos

      protected long basePos
    • relPos

      protected long relPos
    • requestedPos

      protected long requestedPos
  • Constructor Details

    • SeekableReadableChannelOverReadableChannel

      public SeekableReadableChannelOverReadableChannel(ReadableChannel<A> delegate, long basePos)
  • Method Details

    • read

      public int read(A array, int position, int length) throws IOException
      Description copied from interface: ReadableSource
      Read method following the usual InputStream protocol.
      Specified by:
      read in interface ReadableSource<A>
      Overrides:
      read in class ReadableChannelDecoratorBase<A, ReadableChannel<A>>
      Parameters:
      array - The array into which to put the read data
      position - Offset into array where to start writing
      length - Maximum number of items to read.
      Returns:
      The number of items read. Return -1 if end of data was reached, and 0 iff length was 0.
      Throws:
      IOException
    • position

      public void position(long pos)
      Specified by:
      position in interface HasPosition
    • cloneObject

      public SeekableReadableChannel<A> cloneObject()
      Description copied from interface: SeekableReadableChannel
      Optional operation. Open a new channel to the underlying source at the same position as this channel. The returned channel is an independent entity and needs to be closed separatedly. Opening a channel this way may be faster than opening a new channel at the source because information about this channel may be re-used (e.g. held pages and pointers into internal data structures)
      Specified by:
      cloneObject in interface SeekableReadableChannel<A>
    • position

      public long position()
      Specified by:
      position in interface HasPosition