Module 

Class StreamSourceChannelWrappingConduit

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void awaitReadable()
      Block until this channel becomes readable again.
      void awaitReadable​(long time, java.util.concurrent.TimeUnit timeUnit)
      Block until this conduit becomes readable again, or until the timeout expires.
      XnioIoThread getReadThread()
      Get the XNIO read thread.
      XnioWorker getWorker()
      Get the XNIO worker associated with this conduit.
      boolean isReadResumed()
      Determine whether read notifications are currently enabled.
      boolean isReadShutdown()
      Determine whether reads have been shut down on this conduit.
      int read​(java.nio.ByteBuffer dst)
      Read a sequence of bytes from this conduit to the given buffer.
      long read​(java.nio.ByteBuffer[] dsts, int offs, int len)
      Read a sequence of bytes from this conduit to the given buffers.
      void resumeReads()
      Indicate that the conduit's ReadReadyHandler should be invoked as soon as data can be read without blocking.
      void setReadReadyHandler​(ReadReadyHandler handler)
      Set the handler which should receive readiness notifications.
      void suspendReads()
      Indicate that calling the conduit's ReadReadyHandler should be suspended.
      void terminateReads()
      Indicate that no more data will be read from this conduit.
      long transferTo​(long position, long count, java.nio.channels.FileChannel target)
      Transfers bytes into the given file from this channel.
      long transferTo​(long count, java.nio.ByteBuffer throughBuffer, StreamSinkChannel target)
      Transfers bytes into the given channel target.
      void wakeupReads()
      Indicate that the conduit's ReadReadyHandler should be invoked immediately, and then again as soon as data can be read without blocking.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • StreamSourceChannelWrappingConduit

        public StreamSourceChannelWrappingConduit​(StreamSourceChannel channel)
        Construct a new instance.
        Parameters:
        channel - the channel to wrap
    • Method Detail

      • terminateReads

        public void terminateReads()
                            throws java.io.IOException
        Description copied from interface: SourceConduit
        Indicate that no more data will be read from this conduit. If unread data exists, an exception may be thrown.
        Specified by:
        terminateReads in interface SourceConduit
        Throws:
        java.io.IOException - if there was a problem
      • 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
        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
        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
      • read

        public int read​(java.nio.ByteBuffer dst)
                 throws java.io.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:
        java.io.IOException - if an error occurs
      • 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
        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
      • isReadShutdown

        public boolean isReadShutdown()
        Description copied from interface: SourceConduit
        Determine whether reads have been shut down on this conduit.
        Specified by:
        isReadShutdown in interface SourceConduit
        Returns:
        true if writes are shut down, false otherwise
      • wakeupReads

        public void wakeupReads()
        Description copied from interface: SourceConduit
        Indicate that the conduit's ReadReadyHandler should be invoked immediately, and then again as soon as data can be read without blocking.
        Specified by:
        wakeupReads in interface SourceConduit
      • isReadResumed

        public boolean isReadResumed()
        Description copied from interface: SourceConduit
        Determine whether read notifications are currently enabled.
        Specified by:
        isReadResumed in interface SourceConduit
        Returns:
        true if read notifications are enabled
      • 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
        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
        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
      • setReadReadyHandler

        public void setReadReadyHandler​(ReadReadyHandler handler)
        Description copied from interface: SourceConduit
        Set the handler which should receive readiness notifications. A filter may pass this invocation on to the filter it wraps, or it may substitute itself.
        Specified by:
        setReadReadyHandler in interface SourceConduit
      • getWorker

        public XnioWorker getWorker()
        Description copied from interface: Conduit
        Get the XNIO worker associated with this conduit.
        Specified by:
        getWorker in interface Conduit
        Returns:
        the XNIO worker associated with this conduit