Module 

Class FixedLengthStreamSourceChannel

java.lang.Object
org.xnio.channels.FixedLengthStreamSourceChannel
All Implemented Interfaces:
Closeable, AutoCloseable, Channel, InterruptibleChannel, ReadableByteChannel, ScatteringByteChannel, CloseableChannel, CloseListenerSettable<FixedLengthStreamSourceChannel>, Configurable, ProtectedWrappedChannel<StreamSourceChannel>, ReadListenerSettable<FixedLengthStreamSourceChannel>, StreamSourceChannel, SuspendableReadChannel

A channel which reads data of a fixed length and calls a finish listener. When the finish listener is called, it should examine the result of getRemaining() to see if more bytes were pending when the channel was closed.
Author:
David M. Lloyd
  • Constructor Details

    • FixedLengthStreamSourceChannel

      public FixedLengthStreamSourceChannel(StreamSourceChannel delegate, long contentLength, ChannelListener<? super FixedLengthStreamSourceChannel> finishListener, Object guard)
      Construct a new instance. The given listener is called once all the bytes are read from the stream or the stream is closed. This listener should cause the remaining data to be drained from the underlying stream via the #drain() method if the underlying stream is to be reused.

      Calling this constructor will replace the read listener of the underlying channel. The listener should be restored from the finishListener object. The underlying stream should not be closed while this wrapper stream is active.

      Parameters:
      delegate - the stream source channel to read from
      contentLength - the amount of content to read
      finishListener - the listener to call once the stream is exhausted or closed
      guard - the guard object to use
    • FixedLengthStreamSourceChannel

      public FixedLengthStreamSourceChannel(StreamSourceChannel delegate, long contentLength, boolean configurable, ChannelListener<? super FixedLengthStreamSourceChannel> finishListener, Object guard)
      Construct a new instance. The given listener is called once all the bytes are read from the stream or the stream is closed. This listener should cause the remaining data to be drained from the underlying stream via the #drain() method if the underlying stream is to be reused.

      Calling this constructor will replace the read listener of the underlying channel. The listener should be restored from the finishListener object. The underlying stream should not be closed while this wrapper stream is active.

      Parameters:
      delegate - the stream source channel to read from
      contentLength - the amount of content to read
      configurable - true to allow options to pass through to the delegate, false otherwise
      finishListener - the listener to call once the stream is exhausted or closed
      guard - the guard object to use
    • FixedLengthStreamSourceChannel

      public FixedLengthStreamSourceChannel(StreamSourceChannel delegate, long contentLength, boolean configurable, boolean propagateClose, ChannelListener<? super FixedLengthStreamSourceChannel> finishListener, Object guard)
      Construct a new instance. The given listener is called once all the bytes are read from the stream or the stream is closed. This listener should cause the remaining data to be drained from the underlying stream via the #drain() method if the underlying stream is to be reused.

      Calling this constructor will replace the read listener of the underlying channel. The listener should be restored from the finishListener object. The underlying stream should not be closed while this wrapper stream is active.

      Parameters:
      delegate - the stream source channel to read from
      contentLength - the amount of content to read
      configurable - true to allow options to pass through to the delegate, false otherwise
      propagateClose - true to propagate close/shutdown to the delegate, false otherwise
      finishListener - the listener to call once the stream is exhausted or closed
      guard - the guard object to use
  • Method Details