private class InputStreamContentProvider.InputStreamContentProviderIterator
extends java.lang.Object
implements java.util.Iterator<java.nio.ByteBuffer>, java.io.Closeable
InputStream is tricky, because hasNext() must return false
if the stream reads -1. However, we don't know what to return until we read the stream, which
means that stream reading must be performed by hasNext(), which introduces a side-effect
on what is supposed to be a simple query method (with respect to the Query Command Separation
Principle).
Alternatively, we could return true from hasNext() even if we don't know that
we will read -1, but then when next() reads -1 it must return an empty buffer.
However this is problematic, since GETs with no content indication would become GET with chunked
content, and not understood by servers.
Therefore we need to make sure that hasNext() does not perform any side effect (so that
it can be called multiple times) until next() is called.
| Modifier and Type | Field and Description |
|---|---|
private java.nio.ByteBuffer |
buffer |
private java.lang.Throwable |
failure |
private java.lang.Boolean |
hasNext |
| Modifier | Constructor and Description |
|---|---|
private |
InputStreamContentProviderIterator() |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
boolean |
hasNext() |
java.nio.ByteBuffer |
next() |
void |
remove() |
private java.lang.Throwable failure
private java.nio.ByteBuffer buffer
private java.lang.Boolean hasNext
public boolean hasNext()
hasNext in interface java.util.Iterator<java.nio.ByteBuffer>public java.nio.ByteBuffer next()
next in interface java.util.Iterator<java.nio.ByteBuffer>public void remove()
remove in interface java.util.Iterator<java.nio.ByteBuffer>public void close()
close in interface java.io.Closeableclose in interface java.lang.AutoCloseable