public abstract class ForwardingProtocolReader extends java.lang.Object implements ProtocolReader
Useful for wrapping and subclassing without inheritance.
SCOPE_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
|
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
|
public int currentScope()
ProtocolReader
Return values can be ProtocolReader.SCOPE_NONE, ProtocolReader.SCOPE_OBJECT, ProtocolReader.SCOPE_ARRAY, ProtocolResponseReader.SCOPE_RESPONSE
currentScope
in interface ProtocolReader
public TypeToken peek() throws java.io.IOException
ProtocolReader
Return values can be TypeToken.BEGIN_OBJECT, TypeToken.BEGIN_ARRAY, TypeToken.END_OBJECT, TypeToken.END_ARRAY, TypeToken.STRING, TypeToken.BOOLEAN, TypeToken.NUMBER
peek
in interface ProtocolReader
java.io.IOException
- if the source is exhausted before the next bytes can be readTypeToken
public void beginObject() throws java.io.IOException
ProtocolReader
beginObject
in interface ProtocolReader
java.io.IOException
- if the source has been exhaustedpublic void beginArray() throws java.io.IOException
ProtocolReader
beginArray
in interface ProtocolReader
java.io.IOException
- if the source has been exhaustedpublic void endArray() throws java.io.IOException
ProtocolReader
endArray
in interface ProtocolReader
java.io.IOException
- if the source has been exhaustedpublic void endObject() throws java.io.IOException
ProtocolReader
endObject
in interface ProtocolReader
java.io.IOException
- if the source has been exhaustedpublic boolean readBoolean() throws java.io.IOException
ProtocolReader
readBoolean
in interface ProtocolReader
java.io.IOException
- if the source has been exhaustedpublic java.lang.String readString() throws java.io.IOException
ProtocolReader
readString
in interface ProtocolReader
java.io.IOException
- if the source is exhaustedpublic long readNumber() throws java.io.IOException
ProtocolReader
readNumber
in interface ProtocolReader
java.io.IOException
- if the source is exhaustedpublic void close()
ProtocolReader
close
in interface ProtocolReader
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
public boolean hasNext() throws java.io.IOException
ProtocolReader
hasNext
in interface ProtocolReader
java.io.IOException
- if the source has been exhaustedpublic void skipValue() throws java.io.IOException
ProtocolReader
skipValue
in interface ProtocolReader
java.io.IOException
- if the source has been exhaustedpublic ProtocolReader newPeekingReader()
ProtocolReader
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