close() and EOF.
Primarily used to auto-release an underlying managed connection when the response
body is consumed or no longer needed.
EofSensorWatcher
| Modifier and Type | Field and Description |
|---|---|
| private final EofSensorWatcher | eofWatcher
The watcher to be notified, if any. |
| private boolean | selfClosed
Indicates whether this stream itself is closed. |
| private InputStream | wrappedStream
The wrapped input stream, while accessible. |
| Access | Constructor and Description |
|---|---|
| public | EofSensorInputStream(final InputStream
the wrapped stream in, final EofSensorWatcher the watcher for events, or watcher)null for
auto-close behavior without notificationCreates a new EOF sensor. |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public int | available()
Overrides java. |
| private void | |
| private void | |
| private void | checkEOF(final int
the result of the calling read operation.
A negative value indicates that EOF is reached. eof)Detects EOF and notifies the watcher. |
| public void | close()
Overrides java. Implements java. |
| pack-priv InputStream | |
| private boolean | Returns: true if the underlying stream is accessible,
false if this stream is in EOF mode and
detached from the underlying streamChecks whether the underlying stream can be read from. |
| pack-priv boolean | |
| public int | read()
Implements abstract java. |
| public int | read(final byte[]
the buffer into which the data is read. b, final int the start offset in array off, final int b
at which the data is written.the maximum number of bytes to read. len)Overrides java. len bytes of data from the input stream into
an array of bytes.
|
| public int | read(final byte[]
the buffer into which the data is read. b)Overrides java. b.
|
| eofWatcher | back to summary |
|---|---|
| private final EofSensorWatcher eofWatcher The watcher to be notified, if any. | |
| selfClosed | back to summary |
|---|---|
| private boolean selfClosed Indicates whether this stream itself is closed.
If it isn't, but
| |
| wrappedStream | back to summary |
|---|---|
| private InputStream wrappedStream The wrapped input stream, while accessible.
The value changes to | |
| EofSensorInputStream | back to summary |
|---|---|
| public EofSensorInputStream(final InputStream in, final EofSensorWatcher watcher) Creates a new EOF sensor.
If no watcher is passed, the underlying stream will simply be
closed when EOF is detected or
| |
| abort | back to summary |
|---|---|
| public void abort() throws IOException Aborts this stream.
This is a special version of
| |
| available | back to summary |
|---|---|
| public int available() throws IOException Overrides java. Doc from java. Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking, which may be 0, or 0 when end of stream is detected. The read might be on the same thread or another thread. A single read or skip of this many bytes will not block, but may read or skip fewer bytes. Note that while some implementations of A subclass's implementation of this method may choose to throw an
| |
| checkAbort | back to summary |
|---|---|
| private void checkAbort() throws IOException Detects stream abort and notifies the watcher.
There's not much to detect since this is called by
| |
| checkClose | back to summary |
|---|---|
| private void checkClose() throws IOException Detects stream close and notifies the watcher.
There's not much to detect since this is called by
| |
| checkEOF | back to summary |
|---|---|
| private void checkEOF(final int eof) throws IOException Detects EOF and notifies the watcher.
This method should only be called while the underlying stream is
still accessible. Use If EOF is detected, the watcher will be notified and this stream is detached from the underlying stream. This prevents multiple notifications from this stream.
| |
| close | back to summary |
|---|---|
| public void close() throws IOException Overrides java. Implements java. Doc from java. Closes this input stream and releases any system resources associated with the stream.
| |
| getWrappedStream | back to summary |
|---|---|
| pack-priv InputStream getWrappedStream() | |
| isReadAllowed | back to summary |
|---|---|
| private boolean isReadAllowed() throws IOException Checks whether the underlying stream can be read from.
| |
| isSelfClosed | back to summary |
|---|---|
| pack-priv boolean isSelfClosed() | |
| read | back to summary |
|---|---|
| public int read() throws IOException Implements abstract java. Doc from java. Reads the next byte of data from the input stream. The value byte is
returned as an
| |
| read | back to summary |
|---|---|
| public int read(final byte[] b, final int off, final int len) throws IOException Overrides java. Doc from java. Reads up to This method blocks until input data is available, end of file is detected, or an exception is thrown. If The first byte read is stored into element In every case, elements
| |
| read | back to summary |
|---|---|
| public int read(final byte[] b) throws IOException Overrides java. Doc from java. Reads some number of bytes from the input stream and stores them into
the buffer array If the length of The first byte read is stored into element
| |