public interface ProtocolReader
extends java.lang.AutoCloseable, java.io.Closeable
BytesReader
,
ValueReader
Modifier and Type | Field and Description |
---|---|
static int |
SCOPE_ARRAY
Indicates the reader is currently reading an array from the data source
|
static int |
SCOPE_NONE
Indicates the reader has either not begun reading or has finished reading all the data
and is currently not reading anything
|
static int |
SCOPE_OBJECT
Indicates the reader is currently reading an object from the data source
|
Modifier and Type | Method and Description |
---|---|
void |
beginArray()
Begin reading an array from the source
|
void |
beginObject()
Begin reading an object from the source
|
void |
close()
Close the data source
|
int |
currentScope()
Get the current scope of the reader
|
void |
endArray()
End reading an array from the source
|
void |
endObject()
End reading an object from the source
|
boolean |
hasNext()
Check if the source has more data to read
|
ProtocolReader |
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
|
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
|
static final int SCOPE_NONE
static final int SCOPE_OBJECT
static final int SCOPE_ARRAY
int currentScope()
Return values can be SCOPE_NONE, SCOPE_OBJECT, SCOPE_ARRAY, ProtocolResponseReader.SCOPE_RESPONSE
TypeToken peek() throws java.io.IOException
Return values can be TypeToken.BEGIN_OBJECT, TypeToken.BEGIN_ARRAY, TypeToken.END_OBJECT, TypeToken.END_ARRAY, TypeToken.STRING, TypeToken.BOOLEAN, TypeToken.NUMBER
void beginObject() throws java.io.IOException
java.io.IOException
- if the source has been exhaustedvoid beginArray() throws java.io.IOException
java.io.IOException
- if the source has been exhaustedvoid endArray() throws java.io.IOException
java.io.IOException
- if the source has been exhaustedvoid endObject() throws java.io.IOException
java.io.IOException
- if the source has been exhaustedboolean readBoolean() throws java.io.IOException
java.io.IOException
- if the source has been exhaustedjava.lang.String readString() throws java.io.IOException
java.io.IOException
- if the source is exhaustedlong readNumber() throws java.io.IOException
java.io.IOException
- if the source is exhaustedvoid close()
close
in interface java.lang.AutoCloseable
close
in interface java.io.Closeable
boolean hasNext() throws java.io.IOException
java.io.IOException
- if the source has been exhaustedvoid skipValue() throws java.io.IOException
java.io.IOException
- if the source has been exhaustedProtocolReader 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.