java.lang.Object
org.xnio.conduits.EmptyStreamSourceConduit
- All Implemented Interfaces:
Conduit
,SourceConduit
,StreamSourceConduit
A stream source conduit which is always empty.
- Author:
- David M. Lloyd
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Block until this channel becomes readable again.void
awaitReadable
(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.boolean
Determine whether read notifications are currently enabled.boolean
Determine whether reads have been shut down on this conduit.int
read
(ByteBuffer dst) Read a sequence of bytes from this conduit to the given buffer.long
read
(ByteBuffer[] dsts, int offs, int len) Read a sequence of bytes from this conduit to the given buffers.void
Indicate that the conduit'sReadReadyHandler
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
Indicate that calling the conduit'sReadReadyHandler
should be suspended.void
Indicate that no more data will be read from this conduit.long
transferTo
(long position, long count, FileChannel target) Transfers bytes into the given file from this channel.long
transferTo
(long count, ByteBuffer throughBuffer, StreamSinkChannel target) Transfers bytes into the given channel target.void
Indicate that the conduit'sReadReadyHandler
should be invoked immediately, and then again as soon as data can be read without blocking.
-
Constructor Details
-
EmptyStreamSourceConduit
Construct a new instance.- Parameters:
readThread
- the read thread for this conduit
-
-
Method Details
-
setReadReadyHandler
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 interfaceSourceConduit
-
transferTo
Description copied from interface:StreamSourceConduit
Transfers bytes into the given file from this channel.- Specified by:
transferTo
in 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: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 thancount
, then the remaining data inthroughBuffer
may contain data read from this channel which must be written totarget
to complete the operation.- Specified by:
transferTo
in 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:StreamSourceConduit
Read a sequence of bytes from this conduit to the given buffer.- Specified by:
read
in 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:StreamSourceConduit
Read a sequence of bytes from this conduit to the given buffers.- Specified by:
read
in interfaceStreamSourceConduit
offs
- 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:SourceConduit
Determine whether reads have been shut down on this conduit.- Specified by:
isReadShutdown
in interfaceSourceConduit
- Returns:
true
if writes are shut down,false
otherwise
-
resumeReads
public void resumeReads()Description copied from interface:SourceConduit
Indicate that the conduit'sReadReadyHandler
should be invoked as soon as data can be read without blocking.- Specified by:
resumeReads
in interfaceSourceConduit
-
suspendReads
public void suspendReads()Description copied from interface:SourceConduit
Indicate that calling the conduit'sReadReadyHandler
should be suspended.- Specified by:
suspendReads
in interfaceSourceConduit
-
wakeupReads
public void wakeupReads()Description copied from interface:SourceConduit
Indicate that the conduit'sReadReadyHandler
should be invoked immediately, and then again as soon as data can be read without blocking.- Specified by:
wakeupReads
in interfaceSourceConduit
-
isReadResumed
public boolean isReadResumed()Description copied from interface:SourceConduit
Determine whether read notifications are currently enabled.- Specified by:
isReadResumed
in interfaceSourceConduit
- Returns:
true
if read notifications are enabled
-
awaitReadable
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 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: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 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
-
terminateReads
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 interfaceSourceConduit
- Throws:
IOException
- if there was a problem
-
getReadThread
Description copied from interface:SourceConduit
Get the XNIO read thread.- Specified by:
getReadThread
in interfaceSourceConduit
- Returns:
- the XNIO read thread
-
getWorker
Description copied from interface:Conduit
Get the XNIO worker associated with this conduit.
-