public abstract class ForwardingProtocolResponseReader extends java.lang.Object implements ProtocolResponseReader
Useful for wrapping and subclassing without inheritance.
SCOPE_DATA, SCOPE_RESPONSE, UNKNOWN_SIZESCOPE_ARRAY, SCOPE_NONE, SCOPE_OBJECT| Modifier and Type | Method and Description |
|---|---|
void |
beginArray()
Begin reading an array from the source
|
void |
beginObject()
Begin reading an object from the source
|
long |
beginResponse()
Begin reading a response from the data source
|
void |
close()
Close the data source
|
int |
currentScope()
Get the current scope of the reader
|
long |
dataContentLength()
Get the length of the data that follows the response
|
void |
endArray()
End reading an array from the source
|
void |
endObject()
End reading an object from the source
|
boolean |
endResponse()
End reading a response from the data source
|
boolean |
hasNext()
Check if the source has more data to read
|
ProtocolResponseReader |
newPeekingReader()
Get a new instance peeking instance of this reader.
|
TypeToken |
peek()
Peek the data and check what is the type of the data that follows
|
boolean |
readBoolean()
Read a boolean value from the source
|
void |
readData(okio.BufferedSink sink)
Read the data after a response.
|
void |
readData(java.io.OutputStream outputStream)
Read the data after a response.
|
long |
readNumber()
Read a number from the source
|
java.lang.String |
readString()
Read a String from the source
|
void |
skipValue()
Consume and discard the next value
|
public long beginResponse()
throws java.io.IOException
ProtocolResponseReaderbeginResponse in interface ProtocolResponseReaderjava.io.IOException - if the source has been exhausted prior to this operationpublic boolean endResponse()
throws java.io.IOException
ProtocolResponseReaderendResponse in interface ProtocolResponseReaderjava.io.IOException - if the source has been exhausted prior to this operationpublic long dataContentLength()
ProtocolResponseReaderdataContentLength in interface ProtocolResponseReaderpublic void readData(okio.BufferedSink sink)
throws java.io.IOException
ProtocolResponseReaderUse this method to red the data after reading a data-enriched response. Calling this method when the scope returned by ProtocolReader.currentScope() is not ProtocolResponseReader.SCOPE_DATA will result in a IllegalStateException error.
readData in interface ProtocolResponseReadersink - the non-null recipient of datajava.io.IOException - or read or write errors.public void readData(java.io.OutputStream outputStream)
throws java.io.IOException
ProtocolResponseReaderUse this method to red the data after reading a data-enriched response. Calling this method when the scope returned by ProtocolReader.currentScope() is not ProtocolResponseReader.SCOPE_DATA will result in a IllegalStateException error.
readData in interface ProtocolResponseReaderoutputStream - the non-null recipient of datajava.io.IOException - or read or write errors.public int currentScope()
ProtocolReaderReturn values can be ProtocolReader.SCOPE_NONE, ProtocolReader.SCOPE_OBJECT, ProtocolReader.SCOPE_ARRAY, ProtocolResponseReader.SCOPE_RESPONSE
currentScope in interface ProtocolReaderpublic TypeToken peek() throws java.io.IOException
ProtocolReaderReturn values can be TypeToken.BEGIN_OBJECT, TypeToken.BEGIN_ARRAY, TypeToken.END_OBJECT, TypeToken.END_ARRAY, TypeToken.STRING, TypeToken.BOOLEAN, TypeToken.NUMBER
peek in interface ProtocolReaderjava.io.IOException - if the source is exhausted before the next bytes can be readTypeTokenpublic void beginObject()
throws java.io.IOException
ProtocolReaderbeginObject in interface ProtocolReaderjava.io.IOException - if the source has been exhaustedpublic void beginArray()
throws java.io.IOException
ProtocolReaderbeginArray in interface ProtocolReaderjava.io.IOException - if the source has been exhaustedpublic void endArray()
throws java.io.IOException
ProtocolReaderendArray in interface ProtocolReaderjava.io.IOException - if the source has been exhaustedpublic void endObject()
throws java.io.IOException
ProtocolReaderendObject in interface ProtocolReaderjava.io.IOException - if the source has been exhaustedpublic boolean readBoolean()
throws java.io.IOException
ProtocolReaderreadBoolean in interface ProtocolReaderjava.io.IOException - if the source has been exhaustedpublic java.lang.String readString()
throws java.io.IOException
ProtocolReaderreadString in interface ProtocolReaderjava.io.IOException - if the source is exhaustedpublic long readNumber()
throws java.io.IOException
ProtocolReaderreadNumber in interface ProtocolReaderjava.io.IOException - if the source is exhaustedpublic void close()
ProtocolReaderclose in interface ProtocolReaderclose in interface java.io.Closeableclose in interface java.lang.AutoCloseablepublic boolean hasNext()
throws java.io.IOException
ProtocolReaderhasNext in interface ProtocolReaderjava.io.IOException - if the source has been exhaustedpublic void skipValue()
throws java.io.IOException
ProtocolReaderskipValue in interface ProtocolReaderjava.io.IOException - if the source has been exhaustedpublic ProtocolResponseReader newPeekingReader()
ProtocolResponseReaderThe 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 ProtocolReadernewPeekingReader in interface ProtocolResponseReader