Module org.xbib.rpm

Class ReadableChannelWrapper

java.lang.Object
org.xbib.rpm.io.ChannelWrapper
org.xbib.rpm.io.ReadableChannelWrapper
All Implemented Interfaces:
Closeable, AutoCloseable, Channel, ReadableByteChannel

public class ReadableChannelWrapper extends ChannelWrapper implements ReadableByteChannel
Wrapper for observing data read from a NIO channel. This wrapper is used for operations that must be notified of incoming IO data.
  • Field Details

  • Constructor Details

  • Method Details

    • read

      public int read(ByteBuffer buffer) throws IOException
      Reads data from the channel and passes it to the consumer. This method does not mutate the acutal data in the provided buffer, but makes it's own copy to pass to the consumer.
      Specified by:
      read in interface ReadableByteChannel
      Parameters:
      buffer - the buffer to read into
      Returns:
      the number of bytes read from the underlying channel
      Throws:
      IOException - if an IO error occurrs
    • close

      public void close() throws IOException
      Close the underlying read channel and complete any operations in the consumer.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Channel
      Specified by:
      close in interface Closeable
      Overrides:
      close in class ChannelWrapper
      Throws:
      IOException - if an IO error occurrs
    • isOpen

      public boolean isOpen()
      Boolean flag indicating whether the channel is open or closed.
      Specified by:
      isOpen in interface Channel
      Returns:
      true if the channel is open, false if not