public final class CodedInputStream
extends java.io.FilterInputStream
readTag() and
readInt32()) and methods that read low-level values (e.g.
readRawVarint32() and readRawBytes(int)). If you are reading
encoded protocol messages, you should use the former methods, but if you are
reading some other format of your own design, use the latter.| Constructor and Description |
|---|
CodedInputStream(Buffer data) |
CodedInputStream(byte[] data) |
CodedInputStream(java.io.InputStream in) |
| Modifier and Type | Method and Description |
|---|---|
void |
checkLastTagWas(int value)
Verifies that the last call to readTag() returned the given tag value.
|
static int |
decodeZigZag32(int n)
Decode a ZigZag-encoded 32-bit value.
|
static long |
decodeZigZag64(long n)
Decode a ZigZag-encoded 64-bit value.
|
void |
popLimit(int limit) |
int |
pushLimit(int limit) |
boolean |
readBool()
Read a
bool field value from the stream. |
Buffer |
readBytes()
Read a
bytes field value from the stream. |
double |
readDouble()
Read a
double field value from the stream. |
int |
readEnum()
Read an enum field value from the stream.
|
int |
readFixed32()
Read a
fixed32 field value from the stream. |
long |
readFixed64()
Read a
fixed64 field value from the stream. |
float |
readFloat()
Read a
float field value from the stream. |
int |
readInt32()
Read an
int32 field value from the stream. |
long |
readInt64()
Read an
int64 field value from the stream. |
byte |
readRawByte()
Read one byte from the input.
|
Buffer |
readRawBytes(int size)
Read a fixed size of bytes from the input.
|
int |
readRawLittleEndian32()
Read a 32-bit little-endian integer from the stream.
|
long |
readRawLittleEndian64()
Read a 64-bit little-endian integer from the stream.
|
int |
readRawVarint32()
Read a raw Varint from the stream.
|
long |
readRawVarint64()
Read a raw Varint from the stream.
|
int |
readSFixed32()
Read an
sfixed32 field value from the stream. |
long |
readSFixed64()
Read an
sfixed64 field value from the stream. |
int |
readSInt32()
Read an
sint32 field value from the stream. |
long |
readSInt64()
Read an
sint64 field value from the stream. |
java.lang.String |
readString()
Read a
string field value from the stream. |
int |
readTag()
Attempt to read a field tag, returning zero if we have reached EOF.
|
int |
readUInt32()
Read a
uint32 field value from the stream. |
long |
readUInt64()
Read a
uint64 field value from the stream. |
boolean |
skipField(int tag)
Reads and discards a single field, given its tag value.
|
void |
skipMessage()
Reads and discards an entire message.
|
void |
skipRawBytes(int size)
Reads and discards
size bytes. |
public CodedInputStream(java.io.InputStream in)
public CodedInputStream(Buffer data)
public CodedInputStream(byte[] data)
public int readTag()
throws java.io.IOException
java.io.IOExceptionpublic void checkLastTagWas(int value)
throws InvalidProtocolBufferException
InvalidProtocolBufferException - value does not match the last tag.public boolean skipField(int tag)
throws java.io.IOException
false if the tag is an endgroup tag, in which case
nothing is skipped. Otherwise, returns true.java.io.IOExceptionpublic void skipMessage()
throws java.io.IOException
java.io.IOExceptionpublic double readDouble()
throws java.io.IOException
double field value from the stream.java.io.IOExceptionpublic float readFloat()
throws java.io.IOException
float field value from the stream.java.io.IOExceptionpublic long readUInt64()
throws java.io.IOException
uint64 field value from the stream.java.io.IOExceptionpublic long readInt64()
throws java.io.IOException
int64 field value from the stream.java.io.IOExceptionpublic int readInt32()
throws java.io.IOException
int32 field value from the stream.java.io.IOExceptionpublic long readFixed64()
throws java.io.IOException
fixed64 field value from the stream.java.io.IOExceptionpublic int readFixed32()
throws java.io.IOException
fixed32 field value from the stream.java.io.IOExceptionpublic boolean readBool()
throws java.io.IOException
bool field value from the stream.java.io.IOExceptionpublic java.lang.String readString()
throws java.io.IOException
string field value from the stream.java.io.IOExceptionpublic Buffer readBytes() throws java.io.IOException
bytes field value from the stream.java.io.IOExceptionpublic int readUInt32()
throws java.io.IOException
uint32 field value from the stream.java.io.IOExceptionpublic int readEnum()
throws java.io.IOException
java.io.IOExceptionpublic int readSFixed32()
throws java.io.IOException
sfixed32 field value from the stream.java.io.IOExceptionpublic long readSFixed64()
throws java.io.IOException
sfixed64 field value from the stream.java.io.IOExceptionpublic int readSInt32()
throws java.io.IOException
sint32 field value from the stream.java.io.IOExceptionpublic long readSInt64()
throws java.io.IOException
sint64 field value from the stream.java.io.IOExceptionpublic int readRawVarint32()
throws java.io.IOException
java.io.IOExceptionpublic long readRawVarint64()
throws java.io.IOException
java.io.IOExceptionpublic int readRawLittleEndian32()
throws java.io.IOException
java.io.IOExceptionpublic long readRawLittleEndian64()
throws java.io.IOException
java.io.IOExceptionpublic static int decodeZigZag32(int n)
n - An unsigned 32-bit integer, stored in a signed int because
Java has no explicit unsigned support.public static long decodeZigZag64(long n)
n - An unsigned 64-bit integer, stored in a signed int because
Java has no explicit unsigned support.public byte readRawByte()
throws java.io.IOException
InvalidProtocolBufferException - The end of the stream or the current limit was reached.java.io.IOExceptionpublic Buffer readRawBytes(int size) throws java.io.IOException
InvalidProtocolBufferException - The end of the stream or the current limit was reached.java.io.IOExceptionpublic void skipRawBytes(int size)
throws java.io.IOException
size bytes.InvalidProtocolBufferException - The end of the stream or the current limit was reached.java.io.IOExceptionpublic int pushLimit(int limit)
public void popLimit(int limit)
Copyright © 2010-2014 FuseSource, Corp.. All Rights Reserved.