public final class SplitStreamSourceChannel extends Object implements StreamSourceChannel, ReadListenerSettable<SplitStreamSourceChannel>, CloseListenerSettable<SplitStreamSourceChannel>
ReadListenerSettable.Setter<C extends Channel>CloseListenerSettable.Setter<C extends Channel>EMPTY| Constructor and Description |
|---|
SplitStreamSourceChannel(StreamSourceChannel delegate)
Construct a new instance which doesn't delegate configuration.
|
SplitStreamSourceChannel(StreamSourceChannel delegate,
boolean delegateConfig)
Construct a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
awaitReadable()
Block until this channel becomes readable again.
|
void |
awaitReadable(long time,
TimeUnit timeUnit)
Block until this channel becomes readable again, or until the timeout expires.
|
void |
close()
Close this channel.
|
ChannelListener<? super SplitStreamSourceChannel> |
getCloseListener()
Get the close listener.
|
ChannelListener.Setter<? extends SplitStreamSourceChannel> |
getCloseSetter()
Get the setter which can be used to change the close listener for this channel.
|
XnioIoThread |
getIoThread()
Get the I/O thread associated with this channel.
|
<T> T |
getOption(Option<T> option)
Get the value of a channel option.
|
ChannelListener<? super SplitStreamSourceChannel> |
getReadListener()
Get the read listener.
|
ChannelListener.Setter<? extends SplitStreamSourceChannel> |
getReadSetter()
Get the setter which can be used to change the read listener for this channel.
|
XnioExecutor |
getReadThread()
Deprecated.
|
XnioWorker |
getWorker()
Get the worker for this channel.
|
boolean |
isOpen() |
boolean |
isReadResumed()
Determine whether reads are resumed.
|
int |
read(ByteBuffer dst) |
long |
read(ByteBuffer[] dsts) |
long |
read(ByteBuffer[] dsts,
int offset,
int length) |
void |
resumeReads()
Resume reads on this channel.
|
void |
setCloseListener(ChannelListener<? super SplitStreamSourceChannel> closeListener)
Set the close listener.
|
<T> T |
setOption(Option<T> option,
T value)
Set an option for this channel.
|
void |
setReadListener(ChannelListener<? super SplitStreamSourceChannel> readListener)
Set the read listener.
|
void |
shutdownReads()
Places this readable channel at "end of stream".
|
boolean |
supportsOption(Option<?> option)
Determine whether an option is supported on this channel.
|
void |
suspendReads()
Suspend further read notifications on this channel.
|
long |
transferTo(long count,
ByteBuffer throughBuffer,
StreamSinkChannel target)
Transfers bytes into the given channel target.
|
long |
transferTo(long position,
long count,
FileChannel target)
Transfers bytes into the given file from this channel.
|
void |
wakeupReads()
Resume reads on this channel, and force the read listener to be triggered even if the
channel isn't actually readable. |
public SplitStreamSourceChannel(StreamSourceChannel delegate, boolean delegateConfig)
delegate - the delegate channeldelegateConfig - true to delegate configuration, false otherwisepublic SplitStreamSourceChannel(StreamSourceChannel delegate)
delegate - the delegate channelpublic void setReadListener(ChannelListener<? super SplitStreamSourceChannel> readListener)
ReadListenerSettablesetReadListener in interface ReadListenerSettable<SplitStreamSourceChannel>readListener - the read listenerpublic ChannelListener<? super SplitStreamSourceChannel> getReadListener()
ReadListenerSettablegetReadListener in interface ReadListenerSettable<SplitStreamSourceChannel>public void setCloseListener(ChannelListener<? super SplitStreamSourceChannel> closeListener)
CloseListenerSettablesetCloseListener in interface CloseListenerSettable<SplitStreamSourceChannel>closeListener - the close listenerpublic ChannelListener<? super SplitStreamSourceChannel> getCloseListener()
CloseListenerSettablegetCloseListener in interface CloseListenerSettable<SplitStreamSourceChannel>public ChannelListener.Setter<? extends SplitStreamSourceChannel> getReadSetter()
StreamSourceChannelgetReadSetter in interface StreamSourceChannelgetReadSetter in interface SuspendableReadChannelpublic ChannelListener.Setter<? extends SplitStreamSourceChannel> getCloseSetter()
StreamSourceChannelgetCloseSetter in interface CloseableChannelgetCloseSetter in interface StreamSourceChannelgetCloseSetter in interface SuspendableReadChannelpublic long transferTo(long position,
long count,
FileChannel target)
throws IOException
StreamSourceChannelFileChannel.transferFrom(ReadableByteChannel, long, long)
may provide a performance advantage on some platforms.
If the current thread is interrupted when this method is called, it may throw a InterruptedIOException;
however, if this exception is thrown, the InterruptedIOException.bytesTransferred field is
guaranteed to be 0.
transferTo in interface StreamSourceChannelposition - the position within the file from which the transfer is to begincount - the number of bytes to be transferredtarget - the file to write toIOException - if an I/O error occurspublic long transferTo(long count,
ByteBuffer throughBuffer,
StreamSinkChannel target)
throws IOException
StreamSourceChannelthroughBuffer parameter's buffer
space. 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. Note that using a direct buffer may provide an
intermediate performance gain on platforms without zero-copy facilities.
If the current thread is interrupted when this method is called, it may throw a InterruptedIOException;
however, if this exception is thrown, the InterruptedIOException.bytesTransferred field is
guaranteed to be 0.
Note that the return value is the amount of data that was actually transferred to the StreamSinkChannel.
The actual amount of data read could be larger than this, and can be calculated by adding the return value and
the amount of data left in throughBuffer.
transferTo in interface StreamSourceChannelcount - the number of bytes to be transferredthroughBuffer - the buffer to copy through.target - the destination to write toIOException - if an I/O error occurspublic int read(ByteBuffer dst) throws IOException
read in interface ReadableByteChannelIOExceptionpublic long read(ByteBuffer[] dsts, int offset, int length) throws IOException
read in interface ScatteringByteChannelIOExceptionpublic long read(ByteBuffer[] dsts) throws IOException
read in interface ScatteringByteChannelIOExceptionpublic void suspendReads()
SuspendableReadChannelsuspendReads in interface SuspendableReadChannelpublic void resumeReads()
SuspendableReadChannelresumeReads in interface SuspendableReadChannelpublic void wakeupReads()
SuspendableReadChannelResume reads on this channel, and force the read listener to be triggered even if the
channel isn't actually readable.wakeupReads in interface SuspendableReadChannelpublic boolean isReadResumed()
SuspendableReadChannelisReadResumed in interface SuspendableReadChanneltrue if reads are resumed, false if reads are suspendedpublic void awaitReadable()
throws IOException
SuspendableReadChannelawaitReadable in interface SuspendableReadChannelInterruptedIOException - if the operation is interrupted; the thread's interrupt flag will be set as wellIOException - if an I/O error occurspublic void awaitReadable(long time,
TimeUnit timeUnit)
throws IOException
SuspendableReadChannelawaitReadable in interface SuspendableReadChanneltime - the time to waittimeUnit - the time unitInterruptedIOException - if the operation is interrupted; the thread's interrupt flag will be set as wellIOException - if an I/O error occurspublic XnioWorker getWorker()
CloseableChannelgetWorker in interface CloseableChannelpublic boolean supportsOption(Option<?> option)
ConfigurablesupportsOption in interface Configurableoption - the optiontrue if it is supportedpublic <T> T getOption(Option<T> option) throws IOException
ConfigurablegetOption in interface ConfigurableT - the type of the option valueoption - the option to getnull if it is not setIOException - if an I/O error occurred when reading the optionpublic <T> T setOption(Option<T> option, T value) throws IllegalArgumentException, IOException
ConfigurablesetOption in interface ConfigurableT - the type of the option valueoption - the option to setvalue - the value of the option to setIllegalArgumentException - if the value is not acceptable for this optionIOException - if an I/O error occurred when modifying the optionpublic void shutdownReads()
throws IOException
SuspendableReadChannelCloseableChannel.close() to be called automatically.shutdownReads in interface SuspendableReadChannelIOException - if an I/O error occurs@Deprecated public XnioExecutor getReadThread()
SuspendableReadChannelgetReadThread in interface SuspendableReadChannelnull if none is configured or availablepublic XnioIoThread getIoThread()
CloseableChannelgetIoThread in interface CloseableChannelpublic void close()
throws IOException
CloseableChannelclose in interface Closeableclose in interface AutoCloseableclose in interface Channelclose in interface InterruptibleChannelclose in interface CloseableChannelIOException - if the close failedCopyright © 2017 JBoss by Red Hat. All rights reserved.