Module 

Class MessageStreamSourceConduit

All Implemented Interfaces:
Conduit, SourceConduit, StreamSourceConduit

public final class MessageStreamSourceConduit extends AbstractSourceConduit<MessageSourceConduit> implements StreamSourceConduit
A stream source conduit which reads stream data from messages. The receive buffer should always be as large as the largest possible incoming message, or larger, to avoid data loss.
Author:
David M. Lloyd
  • Constructor Details

    • MessageStreamSourceConduit

      public MessageStreamSourceConduit(MessageSourceConduit next)
      Construct a new instance.
      Parameters:
      next - the delegate conduit to set
  • Method Details

    • transferTo

      public long transferTo(long position, long count, FileChannel target) throws IOException
      Description copied from interface: StreamSourceConduit
      Transfers bytes into the given file from this channel.
      Specified by:
      transferTo in interface StreamSourceConduit
      Parameters:
      position - the position within the file from which the transfer is to begin
      count - the number of bytes to be transferred
      target - the file to write to
      Returns:
      the number of bytes (possibly 0) that were actually transferred
      Throws:
      IOException - if an I/O error occurs
    • transferTo

      public long transferTo(long count, ByteBuffer throughBuffer, StreamSinkChannel target) throws IOException
      Description copied from interface: StreamSourceConduit
      Transfers bytes into the given channel target. On entry, throughBuffer will be cleared. On exit, the buffer will be flipped for emptying, and may possibly be empty or may contain data. If this method returns a value less than count, then the remaining data in throughBuffer may contain data read from this channel which must be written to target to complete the operation.
      Specified by:
      transferTo in interface StreamSourceConduit
      Parameters:
      count - the number of bytes to be transferred
      throughBuffer - the buffer to copy through.
      target - the destination to write to
      Returns:
      the number of bytes (possibly 0) that were actually transferred, or -1 if the end of input was reached
      Throws:
      IOException - if an I/O error occurs
    • read

      public int read(ByteBuffer dst) throws IOException
      Description copied from interface: StreamSourceConduit
      Read a sequence of bytes from this conduit to the given buffer.
      Specified by:
      read in interface StreamSourceConduit
      Returns:
      the number of bytes (possibly 0) that were actually transferred, or -1 if the end of input was reached or this conduit's SourceConduit.terminateReads() method was previously called
      Throws:
      IOException - if an error occurs
    • read

      public long read(ByteBuffer[] dsts, int offs, int len) throws IOException
      Description copied from interface: StreamSourceConduit
      Read a sequence of bytes from this conduit to the given buffers.
      Specified by:
      read in interface StreamSourceConduit
      offs - the offset into the buffer array
      len - the number of buffers to fill
      Returns:
      the number of bytes (possibly 0) that were actually transferred, or -1 if the end of input was reached or this conduit's SourceConduit.terminateReads() method was previously called
      Throws:
      IOException - if an error occurs