public final class ProtoReader extends Object
| Constructor and Description |
|---|
ProtoReader(okio.BufferedSource source) |
| Modifier and Type | Method and Description |
|---|---|
long |
beginMessage()
Begin a nested message.
|
void |
endMessage(long token)
End a length-delimited nested message.
|
int |
nextTag()
Reads and returns the next tag of the message, or -1 if there are no further tags.
|
FieldEncoding |
peekFieldEncoding()
Returns the encoding of the next field value.
|
okio.ByteString |
readBytes()
Reads a
bytes field value from the stream. |
int |
readFixed32()
Reads a 32-bit little-endian integer from the stream.
|
long |
readFixed64()
Reads a 64-bit little-endian integer from the stream.
|
String |
readString()
Reads a
string field value from the stream. |
int |
readVarint32()
Reads a raw varint from the stream.
|
long |
readVarint64()
Reads a raw varint up to 64 bits in length from the stream.
|
void |
skip()
Skips the current field's value.
|
public long beginMessage()
throws IOException
nextTag() returns -1 when the message is complete. An accompanying call to endMessage(long) must then occur with the opaque token returned from this method.IOExceptionpublic void endMessage(long token)
throws IOException
beginMessage().token - value returned from the corresponding call to beginMessage().IOExceptionpublic int nextTag()
throws IOException
peekFieldEncoding() after calling this method to query its encoding. This silently skips
groups.IOExceptionpublic FieldEncoding peekFieldEncoding()
nextTag() must be called before
this method.public void skip()
throws IOException
nextTag().IOExceptionpublic okio.ByteString readBytes()
throws IOException
bytes field value from the stream. The length is read from the
stream prior to the actual data.IOExceptionpublic String readString() throws IOException
string field value from the stream.IOExceptionpublic int readVarint32()
throws IOException
IOExceptionpublic long readVarint64()
throws IOException
IOExceptionpublic int readFixed32()
throws IOException
IOExceptionpublic long readFixed64()
throws IOException
IOExceptionCopyright © 2013–2017 Square, Inc.. All rights reserved.