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.IOException
public void endMessage(long token) throws IOException
beginMessage()
.token
- value returned from the corresponding call to beginMessage()
.IOException
public int nextTag() throws IOException
peekFieldEncoding()
after calling this method to query its encoding. This silently skips
groups.IOException
public FieldEncoding peekFieldEncoding()
nextTag()
must be called before
this method.public void skip() throws IOException
nextTag()
.IOException
public okio.ByteString readBytes() throws IOException
bytes
field value from the stream. The length is read from the
stream prior to the actual data.IOException
public String readString() throws IOException
string
field value from the stream.IOException
public int readVarint32() throws IOException
IOException
public long readVarint64() throws IOException
IOException
public int readFixed32() throws IOException
IOException
public long readFixed64() throws IOException
IOException
Copyright © 2013–2016 Square, Inc.. All rights reserved.