Class ReadableChannelWithLimit<A,X extends ReadableChannel<A>>

java.lang.Object
org.aksw.commons.io.input.ReadableChannelWithLimit<A,X>
All Implemented Interfaces:
Closeable, AutoCloseable, Channel, HasArrayOps<A>, ReadableChannel<A>, ReadableSource<A>

public class ReadableChannelWithLimit<A,X extends ReadableChannel<A>> extends Object implements ReadableChannel<A>
  • Field Details

    • delegate

      protected X extends ReadableChannel<A> delegate
    • limit

      protected long limit
    • remaining

      protected long remaining
  • Constructor Details

    • ReadableChannelWithLimit

      public ReadableChannelWithLimit(X backend, long limit)
  • Method Details

    • getDelegate

      public X getDelegate()
    • getArrayOps

      public ArrayOps<A> getArrayOps()
      Specified by:
      getArrayOps in interface HasArrayOps<A>
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Channel
      Specified by:
      close in interface Closeable
      Throws:
      IOException
    • isOpen

      public boolean isOpen()
      Specified by:
      isOpen in interface Channel
    • 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>
      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