Package org.xnio.conduits
Class StreamSourceChannelWrappingConduit
java.lang.Object
org.xnio.conduits.StreamSourceChannelWrappingConduit
- All Implemented Interfaces:
Conduit,SourceConduit,StreamSourceConduit
A conduit which wraps a channel, for compatibility.
- Author:
- David M. Lloyd
-
Constructor Summary
ConstructorsConstructorDescriptionConstruct a new instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidBlock until this channel becomes readable again.voidawaitReadable(long time, TimeUnit timeUnit) Block until this conduit becomes readable again, or until the timeout expires.Get the XNIO read thread.Get the XNIO worker associated with this conduit.booleanDetermine whether read notifications are currently enabled.booleanDetermine whether reads have been shut down on this conduit.intread(ByteBuffer dst) Read a sequence of bytes from this conduit to the given buffer.longread(ByteBuffer[] dsts, int offs, int len) Read a sequence of bytes from this conduit to the given buffers.voidIndicate that the conduit'sReadReadyHandlershould be invoked as soon as data can be read without blocking.voidsetReadReadyHandler(ReadReadyHandler handler) Set the handler which should receive readiness notifications.voidIndicate that calling the conduit'sReadReadyHandlershould be suspended.voidIndicate that no more data will be read from this conduit.longtransferTo(long position, long count, FileChannel target) Transfers bytes into the given file from this channel.longtransferTo(long count, ByteBuffer throughBuffer, StreamSinkChannel target) Transfers bytes into the given channel target.voidIndicate that the conduit'sReadReadyHandlershould be invoked immediately, and then again as soon as data can be read without blocking.
-
Constructor Details
-
StreamSourceChannelWrappingConduit
Construct a new instance.- Parameters:
channel- the channel to wrap
-
-
Method Details
-
terminateReads
Description copied from interface:SourceConduitIndicate that no more data will be read from this conduit. If unread data exists, an exception may be thrown.- Specified by:
terminateReadsin interfaceSourceConduit- Throws:
IOException- if there was a problem
-
transferTo
Description copied from interface:StreamSourceConduitTransfers bytes into the given file from this channel.- Specified by:
transferToin interfaceStreamSourceConduit- Parameters:
position- the position within the file from which the transfer is to begincount- the number of bytes to be transferredtarget- 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:StreamSourceConduitTransfers bytes into the given channel target. On entry,throughBufferwill 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 thancount, then the remaining data inthroughBuffermay contain data read from this channel which must be written totargetto complete the operation.- Specified by:
transferToin interfaceStreamSourceConduit- Parameters:
count- the number of bytes to be transferredthroughBuffer- 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
Description copied from interface:StreamSourceConduitRead a sequence of bytes from this conduit to the given buffer.- Specified by:
readin interfaceStreamSourceConduit- 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
Description copied from interface:StreamSourceConduitRead a sequence of bytes from this conduit to the given buffers.- Specified by:
readin interfaceStreamSourceConduitoffs- the offset into the buffer arraylen- 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
-
isReadShutdown
public boolean isReadShutdown()Description copied from interface:SourceConduitDetermine whether reads have been shut down on this conduit.- Specified by:
isReadShutdownin interfaceSourceConduit- Returns:
trueif writes are shut down,falseotherwise
-
resumeReads
public void resumeReads()Description copied from interface:SourceConduitIndicate that the conduit'sReadReadyHandlershould be invoked as soon as data can be read without blocking.- Specified by:
resumeReadsin interfaceSourceConduit
-
suspendReads
public void suspendReads()Description copied from interface:SourceConduitIndicate that calling the conduit'sReadReadyHandlershould be suspended.- Specified by:
suspendReadsin interfaceSourceConduit
-
wakeupReads
public void wakeupReads()Description copied from interface:SourceConduitIndicate that the conduit'sReadReadyHandlershould be invoked immediately, and then again as soon as data can be read without blocking.- Specified by:
wakeupReadsin interfaceSourceConduit
-
isReadResumed
public boolean isReadResumed()Description copied from interface:SourceConduitDetermine whether read notifications are currently enabled.- Specified by:
isReadResumedin interfaceSourceConduit- Returns:
trueif read notifications are enabled
-
awaitReadable
Description copied from interface:SourceConduitBlock until this channel becomes readable again. This method may return spuriously before the channel becomes readable.- Specified by:
awaitReadablein interfaceSourceConduit- Throws:
InterruptedIOException- if the operation is interrupted; the thread's interrupt flag will be set as wellIOException- if an I/O error occurs
-
awaitReadable
Description copied from interface:SourceConduitBlock 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:
awaitReadablein interfaceSourceConduit- Parameters:
time- the time to waittimeUnit- the time unit- Throws:
InterruptedIOException- if the operation is interrupted; the thread's interrupt flag will be set as wellIOException- if an I/O error occurs
-
getReadThread
Description copied from interface:SourceConduitGet the XNIO read thread.- Specified by:
getReadThreadin interfaceSourceConduit- Returns:
- the XNIO read thread
-
setReadReadyHandler
Description copied from interface:SourceConduitSet 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:
setReadReadyHandlerin interfaceSourceConduit
-
getWorker
Description copied from interface:ConduitGet the XNIO worker associated with this conduit.
-