getRemaining() to see if more bytes were pending when the channel was
closed.
| Modifier and Type | Field and Description |
|---|---|
| private ChannelListener | |
| private final StreamSourceChannel | |
| private final ChannelListener | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private final Object | |
| private ChannelListener | |
| private long | |
| private int |
| Access | Constructor and Description |
|---|---|
| public | FixedLengthStreamSourceChannel(final StreamSourceChannel
the stream source channel to read from delegate, final long the amount of content to read contentLength, final ChannelListener<? super FixedLengthStreamSourceChannel> the listener to call once the stream is exhausted or closed finishListener, final Object the guard object to use guard)Construct a new instance. |
| public | FixedLengthStreamSourceChannel(final StreamSourceChannel
the stream source channel to read from delegate, final long the amount of content to read contentLength, final boolean true to allow options to pass through to the delegate, false otherwisethe listener to call once the stream is exhausted or closed finishListener, final Object the guard object to use guard)Construct a new instance. |
| public | FixedLengthStreamSourceChannel(final StreamSourceChannel
the stream source channel to read from delegate, final long the amount of content to read contentLength, final boolean true to allow options to pass through to the delegate, false otherwisetrue to propagate close/shutdown to the delegate, false otherwisethe listener to call once the stream is exhausted or closed finishListener, final Object the guard object to use guard)Construct a new instance. |
| Modifier and Type | Method and Description |
|---|---|
| public void | awaitReadable()
Implements org. Block until this channel becomes readable again. |
| public void | awaitReadable(final long
the time to wait time, final TimeUnit the time unit timeUnit)Implements org. Block until this channel becomes readable again, or until the timeout expires. |
| private void | |
| private void | |
| public void | close()
Implements java. Closes this channel. |
| public StreamSourceChannel | getChannel(final Object
the guard object guard)Implements org. Get the channel which is wrapped by this object, or |
| public ChannelListener | getCloseListener()
Implements org. Get the close listener. |
| public ChannelListener. | getCloseSetter()
Implements org. Get the setter which can be used to change the close listener for this channel. |
| public XnioIoThread | getIoThread()
Implements org. Get the I/O thread associated with this channel. |
| public <T> T | getOption(final Option<T>
the option to get option)Implements org. Get the value of a channel option. |
| public ChannelListener | getReadListener()
Implements org. Get the read listener. |
| public ChannelListener. | getReadSetter()
Implements org. Get the setter which can be used to change the read listener for this channel. |
| public XnioExecutor | getReadThread()
Implements org.
Deprecated
Get the read thread for this channel. |
| public long | |
| public XnioWorker | getWorker()
Implements org. Get the worker for this channel. |
| public boolean | |
| public boolean | isReadResumed()
Implements org. Determine whether reads are resumed. |
| public long | read(final ByteBuffer[]
The buffers into which bytes are to be transferred dsts, final int The offset within the buffer array of the first buffer into
which bytes are to be transferred; must be non-negative and no
larger than offset, final int dsts.lengthThe maximum number of buffers to be accessed; must be
non-negative and no larger than
length)dsts.length - offsetImplements java. Reads a sequence of bytes from this channel into a subsequence of the given buffers. |
| public long | read(final ByteBuffer[]
The buffers into which bytes are to be transferred dsts)Implements java. Reads a sequence of bytes from this channel into the given buffers. |
| public int | read(final ByteBuffer
The buffer into which bytes are to be transferred dst)Implements java. Reads a sequence of bytes from this channel into the given buffer. |
| public void | resumeReads()
Implements org. Resume reads on this channel. |
| public void | setCloseListener(final ChannelListener<? super FixedLengthStreamSourceChannel>
the close listener closeListener)Implements org. Set the close listener. |
| public <T> T | setOption(final Option<T>
the option to set option, final T the value of the option to set value)Implements org. Set an option for this channel. |
| public void | setReadListener(final ChannelListener<? super FixedLengthStreamSourceChannel>
the read listener readListener)Implements org. Set the read listener. |
| public void | shutdownReads()
Implements org. Places this readable channel at "end of stream". |
| public boolean | supportsOption(final Option<?>
the option option)Implements org. Determine whether an option is supported on this channel. |
| public void | suspendReads()
Implements org. Suspend further read notifications on this channel. |
| public long | transferTo(final long
the position within the file from which the transfer is to begin position, final long the number of bytes to be transferred count, final FileChannel the file to write to target)Implements org. Transfers bytes into the given file from this channel. |
| public long | transferTo(final long
the number of bytes to be transferred count, final ByteBuffer the buffer to copy through. throughBuffer, final StreamSinkChannel the destination to write to target)Implements org. Transfers bytes into the given channel target. |
| public void | wakeupReads()
Implements org.
|
| closeListener | back to summary |
|---|---|
| private ChannelListener<? super FixedLengthStreamSourceChannel> closeListener | |
| delegate | back to summary |
|---|---|
| private final StreamSourceChannel delegate | |
| finishListener | back to summary |
|---|---|
| private final ChannelListener<? super FixedLengthStreamSourceChannel> finishListener | |
| FLAG_CLOSED | back to summary |
|---|---|
| private static final int FLAG_CLOSED | |
| FLAG_CONFIGURABLE | back to summary |
|---|---|
| private static final int FLAG_CONFIGURABLE | |
| FLAG_FINISHED | back to summary |
|---|---|
| private static final int FLAG_FINISHED | |
| FLAG_PASS_CLOSE | back to summary |
|---|---|
| private static final int FLAG_PASS_CLOSE | |
| guard | back to summary |
|---|---|
| private final Object guard | |
| readListener | back to summary |
|---|---|
| private ChannelListener<? super FixedLengthStreamSourceChannel> readListener | |
| remaining | back to summary |
|---|---|
| private long remaining | |
| state | back to summary |
|---|---|
| private int state | |
| FixedLengthStreamSourceChannel | back to summary |
|---|---|
| public FixedLengthStreamSourceChannel(final StreamSourceChannel delegate, final long contentLength, final ChannelListener<? super FixedLengthStreamSourceChannel> finishListener, final Object guard) Construct a new instance. The given listener is called once all the bytes are read from the stream
or the stream is closed. This listener should cause the remaining data to be drained from the
underlying stream via the
Calling this constructor will replace the read listener of the underlying channel. The listener should be
restored from the
| |
| FixedLengthStreamSourceChannel | back to summary |
|---|---|
| public FixedLengthStreamSourceChannel(final StreamSourceChannel delegate, final long contentLength, final boolean configurable, final ChannelListener<? super FixedLengthStreamSourceChannel> finishListener, final Object guard) Construct a new instance. The given listener is called once all the bytes are read from the stream
or the stream is closed. This listener should cause the remaining data to be drained from the
underlying stream via the
Calling this constructor will replace the read listener of the underlying channel. The listener should be
restored from the
| |
| FixedLengthStreamSourceChannel | back to summary |
|---|---|
| public FixedLengthStreamSourceChannel(final StreamSourceChannel delegate, final long contentLength, final boolean configurable, final boolean propagateClose, final ChannelListener<? super FixedLengthStreamSourceChannel> finishListener, final Object guard) Construct a new instance. The given listener is called once all the bytes are read from the stream
or the stream is closed. This listener should cause the remaining data to be drained from the
underlying stream via the
Calling this constructor will replace the read listener of the underlying channel. The listener should be
restored from the
| |
| awaitReadable | back to summary |
|---|---|
| public void awaitReadable() throws IOException Implements org. Doc from org. Block until this channel becomes readable again. This method may return spuriously before the channel becomes readable.
| |
| awaitReadable | back to summary |
|---|---|
| public void awaitReadable(final long time, final TimeUnit timeUnit) throws IOException Implements org. Doc from org. Block until this channel becomes readable again, or until the timeout expires. This method may return spuriously before the channel becomes readable or the timeout expires.
| |
| callClosed | back to summary |
|---|---|
| private void callClosed() | |
| callFinish | back to summary |
|---|---|
| private void callFinish() | |
| close | back to summary |
|---|---|
| public void close() throws IOException Implements java. Doc from java. Closes this channel. After a channel is closed, any further attempt to invoke I/O
operations upon it will cause a If this channel is already closed then invoking this method has no effect. This method may be invoked at any time. If some other thread has already invoked it, however, then another invocation will block until the first invocation is complete, after which it will return without effect.
| |
| getChannel | back to summary |
|---|---|
| public StreamSourceChannel getChannel(final Object guard) Implements org. Doc from org. Get the channel which is wrapped by this object, or
| |
| getCloseListener | back to summary |
|---|---|
| public ChannelListener Implements org. Doc from org. Get the close listener.
| |
| getCloseSetter | back to summary |
|---|---|
| public ChannelListener. Implements org. Doc from org. Get the setter which can be used to change the close listener for this channel. If the channel is already closed, then the listener will not be called.
| |
| getIoThread | back to summary |
|---|---|
| public XnioIoThread getIoThread() Implements org. Doc from org. Get the I/O thread associated with this channel.
| |
| getOption | back to summary |
|---|---|
| public <T> T getOption(final Option<T> option) throws IOException Implements org. Doc from org. Get the value of a channel option.
| |
| getReadListener | back to summary |
|---|---|
| public ChannelListener Implements org. Doc from org. Get the read listener.
| |
| getReadSetter | back to summary |
|---|---|
| public ChannelListener. Implements org. Doc from org. Get the setter which can be used to change the read listener for this channel.
| |
| getReadThread | back to summary |
|---|---|
| public XnioExecutor getReadThread() Implements org. Doc from org. Deprecated
Get the read thread for this channel.
| |
| getRemaining | back to summary |
|---|---|
| public long getRemaining() Get the number of remaining bytes.
| |
| getWorker | back to summary |
|---|---|
| public XnioWorker getWorker() Implements org. Doc from org. Get the worker for this channel.
| |
| isOpen | back to summary |
|---|---|
| public boolean isOpen() Implements java. Doc from java. Tells whether or not this channel is open.
| |
| isReadResumed | back to summary |
|---|---|
| public boolean isReadResumed() Implements org. Doc from org. Determine whether reads are resumed.
| |
| read | back to summary |
|---|---|
| public long read(final ByteBuffer[] dsts, final int offset, final int length) throws IOException Implements java. Doc from java. Reads a sequence of bytes from this channel into a subsequence of the given buffers. An invocation of this method attempts to read up to r bytes from this channel, where r is the total number of bytes remaining in the specified subsequence of the given buffer array, that is, dsts[offset].remaining() + dsts[offset+1].remaining() + ... + dsts[offset+length-1].remaining() Suppose that a byte sequence of length n is read, where
This method may be invoked at any time. If another thread has already initiated a read operation upon this channel, however, then an invocation of this method will block until the first operation is complete.
| |
| read | back to summary |
|---|---|
| public long read(final ByteBuffer[] dsts) throws IOException Implements java. Doc from java. Reads a sequence of bytes from this channel into the given buffers. An invocation of this method of the form c.read(dsts, 0, dsts.length);
| |
| read | back to summary |
|---|---|
| public int read(final ByteBuffer dst) throws IOException Implements java. Doc from java. Reads a sequence of bytes from this channel into the given buffer. An attempt is made to read up to r bytes from the channel,
where r is the number of bytes remaining in the buffer, that is,
Suppose that a byte sequence of length n is read, where
A read operation might not fill the buffer, and in fact it might not read any bytes at all. Whether or not it does so depends upon the nature and state of the channel. A socket channel in non-blocking mode, for example, cannot read any more bytes than are immediately available from the socket's input buffer; similarly, a file channel cannot read any more bytes than remain in the file. It is guaranteed, however, that if a channel is in blocking mode and there is at least one byte remaining in the buffer then this method will block until at least one byte is read. This method may be invoked at any time. If another thread has already initiated a read operation upon this channel, however, then an invocation of this method will block until the first operation is complete.
| |
| resumeReads | back to summary |
|---|---|
| public void resumeReads() Implements org. Doc from org. Resume reads on this channel. The read listener will be called as soon as there is data available to be read. | |
| setCloseListener | back to summary |
|---|---|
| public void setCloseListener(final ChannelListener<? super FixedLengthStreamSourceChannel> closeListener) Implements org. Doc from org. Set the close listener.
| |
| setOption | back to summary |
|---|---|
| public <T> T setOption(final Option<T> option, final T value) throws IllegalArgumentException, IOException Implements org. Doc from org. Set an option for this channel. Unsupported options are ignored.
| |
| setReadListener | back to summary |
|---|---|
| public void setReadListener(final ChannelListener<? super FixedLengthStreamSourceChannel> readListener) Implements org. Doc from org. Set the read listener.
| |
| shutdownReads | back to summary |
|---|---|
| public void shutdownReads() throws IOException Implements org. Doc from org. Places this readable channel at "end of stream". Further reads will result in EOF.
Shutting down all directions of a channel will cause
| |
| supportsOption | back to summary |
|---|---|
| public boolean supportsOption(final Option<?> option) Implements org. Doc from org. Determine whether an option is supported on this channel.
| |
| suspendReads | back to summary |
|---|---|
| public void suspendReads() Implements org. Doc from org. Suspend further read notifications on this channel. | |
| transferTo | back to summary |
|---|---|
| public long transferTo(final long position, final long count, final FileChannel target) throws IOException Implements org. Doc from org. Transfers bytes into the given file from this channel. Using this method in preference to
If the current thread is interrupted when this method is called, it may throw a
| |
| transferTo | back to summary |
|---|---|
| public long transferTo(final long count, final ByteBuffer throughBuffer, final StreamSinkChannel target) throws IOException Implements org. Doc from org. Transfers bytes into the given channel target. On some platforms, this may avoid copying bytes between user
and kernel space. On other platforms, bytes are passed through the
If the current thread is interrupted when this method is called, it may throw a
| |
| wakeupReads | back to summary |
|---|---|
| public void wakeupReads() Implements org. Doc from org.
| |