Module 

Class PushBackStreamSourceConduit

    • Constructor Detail

      • PushBackStreamSourceConduit

        public PushBackStreamSourceConduit​(StreamSourceConduit next)
        Construct a new instance.
        Parameters:
        next - the delegate conduit to set
    • Method Detail

      • read

        public long read​(java.nio.ByteBuffer[] dsts,
                         int offs,
                         int len)
                  throws java.io.IOException
        Description copied from interface: StreamSourceConduit
        Read a sequence of bytes from this conduit to the given buffers.
        Specified by:
        read in interface StreamSourceConduit
        Overrides:
        read in class AbstractStreamSourceConduit<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:
        java.io.IOException - if an error occurs
      • transferTo

        public long transferTo​(long position,
                               long count,
                               java.nio.channels.FileChannel target)
                        throws java.io.IOException
        Description copied from interface: StreamSourceConduit
        Transfers bytes into the given file from this channel.
        Specified by:
        transferTo in interface StreamSourceConduit
        Overrides:
        transferTo in class AbstractStreamSourceConduit<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:
        java.io.IOException - if an I/O error occurs
      • transferTo

        public long transferTo​(long count,
                               java.nio.ByteBuffer throughBuffer,
                               StreamSinkChannel target)
                        throws java.io.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
        Overrides:
        transferTo in class AbstractStreamSourceConduit<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:
        java.io.IOException - if an I/O error occurs
      • awaitReadable

        public void awaitReadable()
                           throws java.io.IOException
        Description copied from interface: SourceConduit
        Block until this channel becomes readable again. This method may return spuriously before the channel becomes readable.
        Specified by:
        awaitReadable in interface SourceConduit
        Overrides:
        awaitReadable in class AbstractSourceConduit<StreamSourceConduit>
        Throws:
        java.io.InterruptedIOException - if the operation is interrupted; the thread's interrupt flag will be set as well
        java.io.IOException - if an I/O error occurs
      • awaitReadable

        public void awaitReadable​(long time,
                                  java.util.concurrent.TimeUnit timeUnit)
                           throws java.io.IOException
        Description copied from interface: SourceConduit
        Block until this conduit becomes readable again, or until the timeout expires. This method may return spuriously before the conduit becomes readable or the timeout expires.
        Specified by:
        awaitReadable in interface SourceConduit
        Overrides:
        awaitReadable in class AbstractSourceConduit<StreamSourceConduit>
        Parameters:
        time - the time to wait
        timeUnit - the time unit
        Throws:
        java.io.InterruptedIOException - if the operation is interrupted; the thread's interrupt flag will be set as well
        java.io.IOException - if an I/O error occurs
      • pushBack

        public void pushBack​(Pooled<java.nio.ByteBuffer> pooledBuffer)
        Push a buffer back to the head of the stream. Once the buffer data is consumed, it will be released back to its original pool (if any).
        Parameters:
        pooledBuffer - the buffer to push back