public interface ProtocolResponseReader extends ProtocolReader
ProtocolReader
,
BytesReader
Modifier and Type | Field and Description |
---|---|
static int |
SCOPE_DATA
Indicated the reading is at the beginning of a response's attached byte data.
|
static int |
SCOPE_RESPONSE
Indicates the reader has begun reading a response
|
static int |
UNKNOWN_SIZE
A value to indicate the data content length is unknown
|
SCOPE_ARRAY, SCOPE_NONE, SCOPE_OBJECT
Modifier and Type | Method and Description |
---|---|
long |
beginResponse()
Begin reading a response from the data source
|
long |
dataContentLength()
Get the length of the data that follows the response
|
boolean |
endResponse()
End reading a response from the data source
|
ProtocolResponseReader |
newPeekingReader()
Get a new instance peeking instance of this reader.
|
void |
readData(okio.BufferedSink sink)
Read the data after a response.
|
void |
readData(java.io.OutputStream outputStream)
Read the data after a response.
|
beginArray, beginObject, close, currentScope, endArray, endObject, hasNext, peek, readBoolean, readNumber, readString, skipValue
static final int SCOPE_RESPONSE
static final int SCOPE_DATA
static final int UNKNOWN_SIZE
long beginResponse() throws java.io.IOException
java.io.IOException
- if the source has been exhausted prior to this operationboolean endResponse() throws java.io.IOException
java.io.IOException
- if the source has been exhausted prior to this operationlong dataContentLength()
void readData(okio.BufferedSink sink) throws java.io.IOException
Use this method to red the data after reading a data-enriched response. Calling this method when the scope returned by ProtocolReader.currentScope() is not SCOPE_DATA will result in a IllegalStateException error.
sink
- the non-null recipient of datajava.io.IOException
- or read or write errors.java.lang.IllegalStateException
- if called in scope other than @SCOPE_DATAvoid readData(java.io.OutputStream outputStream) throws java.io.IOException
Use this method to red the data after reading a data-enriched response. Calling this method when the scope returned by ProtocolReader.currentScope() is not SCOPE_DATA will result in a IllegalStateException error.
outputStream
- the non-null recipient of datajava.io.IOException
- or read or write errors.java.lang.IllegalStateException
- if called in scope other than @SCOPE_DATAProtocolResponseReader newPeekingReader()
The peeking reader can read data without consuming it. It inherits all the fields of the current instance such as the data source and the scope. Any operations with the peeking reader will not exhaust the data source.
newPeekingReader
in interface ProtocolReader