Classes | |
class | ArrayDecoder |
class | IterableDirectByteBufferDecoder |
class | StreamDecoder |
class | UnsafeDirectNioDecoder |
Public Member Functions | |
abstract void | checkLastTagWas (final int value) throws InvalidProtocolBufferException |
abstract void | enableAliasing (boolean enabled) |
abstract int | getBytesUntilLimit () |
abstract int | getLastTag () |
abstract int | getTotalBytesRead () |
abstract boolean | isAtEnd () throws IOException |
abstract void | popLimit (final int oldLimit) |
abstract int | pushLimit (int byteLimit) throws InvalidProtocolBufferException |
abstract boolean | readBool () throws IOException |
abstract byte[] | readByteArray () throws IOException |
abstract ByteBuffer | readByteBuffer () throws IOException |
abstract ByteString | readBytes () throws IOException |
abstract double | readDouble () throws IOException |
abstract int | readEnum () throws IOException |
abstract int | readFixed32 () throws IOException |
abstract long | readFixed64 () throws IOException |
abstract float | readFloat () throws IOException |
abstract void | readGroup (final int fieldNumber, final MessageLite.Builder builder, final ExtensionRegistryLite extensionRegistry) throws IOException |
abstract< T extends MessageLite > T | readGroup (final int fieldNumber, final Parser< T > parser, final ExtensionRegistryLite extensionRegistry) throws IOException |
abstract int | readInt32 () throws IOException |
abstract long | readInt64 () throws IOException |
abstract void | readMessage (final MessageLite.Builder builder, final ExtensionRegistryLite extensionRegistry) throws IOException |
abstract< T extends MessageLite > T | readMessage (final Parser< T > parser, final ExtensionRegistryLite extensionRegistry) throws IOException |
abstract byte | readRawByte () throws IOException |
abstract byte[] | readRawBytes (final int size) throws IOException |
abstract int | readRawLittleEndian32 () throws IOException |
abstract long | readRawLittleEndian64 () throws IOException |
abstract int | readRawVarint32 () throws IOException |
abstract long | readRawVarint64 () throws IOException |
abstract int | readSFixed32 () throws IOException |
abstract long | readSFixed64 () throws IOException |
abstract int | readSInt32 () throws IOException |
abstract long | readSInt64 () throws IOException |
abstract String | readString () throws IOException |
abstract String | readStringRequireUtf8 () throws IOException |
abstract int | readTag () throws IOException |
abstract int | readUInt32 () throws IOException |
abstract long | readUInt64 () throws IOException |
abstract void | readUnknownGroup (final int fieldNumber, final MessageLite.Builder builder) throws IOException |
abstract void | resetSizeCounter () |
final int | setRecursionLimit (final int limit) |
final int | setSizeLimit (final int limit) |
abstract boolean | skipField (final int tag) throws IOException |
abstract boolean | skipField (final int tag, final CodedOutputStream output) throws IOException |
abstract void | skipMessage () throws IOException |
abstract void | skipMessage (CodedOutputStream output) throws IOException |
abstract void | skipRawBytes (final int size) throws IOException |
Static Public Member Functions | |
static int | decodeZigZag32 (final int n) |
static long | decodeZigZag64 (final long n) |
static CodedInputStream | newInstance (ByteBuffer buf) |
static CodedInputStream | newInstance (final byte[] buf) |
static CodedInputStream | newInstance (final byte[] buf, final int off, final int len) |
static CodedInputStream | newInstance (final InputStream input) |
static CodedInputStream | newInstance (final InputStream input, int bufferSize) |
static CodedInputStream | newInstance (final Iterable< ByteBuffer > input) |
static int | readRawVarint32 (final int firstByte, final InputStream input) throws IOException |
Private Member Functions | |
CodedInputStream () | |
Private Attributes | |
boolean | shouldDiscardUnknownFields = false |
Static Private Attributes | |
static final int | DEFAULT_BUFFER_SIZE = 4096 |
static final int | DEFAULT_RECURSION_LIMIT = 100 |
static final int | DEFAULT_SIZE_LIMIT = Integer.MAX_VALUE |
Reads and decodes protocol message fields.
This class contains two kinds of methods: methods that read specific protocol message constructs and field types (e.g. readTag() and readInt32()) and methods that read low-level values (e.g. readRawVarint32() and readRawBytes). 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.
Definition at line 61 of file CodedInputStream.java.
|
inlineprivate |
Disable construction/inheritance outside of this class.
Definition at line 198 of file CodedInputStream.java.
|
abstract |
Verifies that the last call to readTag() returned the given tag value. This is used to verify that a nested group ended with the correct end tag.
InvalidProtocolBufferException |
Reimplemented in com.google.protobuf.CodedInputStream.IterableDirectByteBufferDecoder, com.google.protobuf.CodedInputStream.StreamDecoder, com.google.protobuf.CodedInputStream.UnsafeDirectNioDecoder, and com.google.protobuf.CodedInputStream.ArrayDecoder.
|
inlinestatic |
Decode a ZigZag-encoded 32-bit value. ZigZag encodes signed integers into values that can be efficiently encoded with varint. (Otherwise, negative values must be sign-extended to 64 bits to be varint encoded, thus always taking 10 bytes on the wire.)
n | An unsigned 32-bit integer, stored in a signed int because Java has no explicit unsigned support. |
Definition at line 526 of file CodedInputStream.java.
|
inlinestatic |
Decode a ZigZag-encoded 64-bit value. ZigZag encodes signed integers into values that can be efficiently encoded with varint. (Otherwise, negative values must be sign-extended to 64 bits to be varint encoded, thus always taking 10 bytes on the wire.)
n | An unsigned 64-bit integer, stored in a signed int because Java has no explicit unsigned support. |
Definition at line 539 of file CodedInputStream.java.
|
abstract |
Enables ByteString aliasing of the underlying buffer, trading off on buffer pinning for data copies. Only valid for buffer-backed streams.
Reimplemented in com.google.protobuf.CodedInputStream.IterableDirectByteBufferDecoder, com.google.protobuf.CodedInputStream.StreamDecoder, com.google.protobuf.CodedInputStream.UnsafeDirectNioDecoder, and com.google.protobuf.CodedInputStream.ArrayDecoder.
|
abstract |
Returns the number of bytes to be read before the current limit. If no limit is set, returns -1.
Reimplemented in com.google.protobuf.CodedInputStream.IterableDirectByteBufferDecoder, com.google.protobuf.CodedInputStream.StreamDecoder, com.google.protobuf.CodedInputStream.UnsafeDirectNioDecoder, and com.google.protobuf.CodedInputStream.ArrayDecoder.
|
abstract |
|
abstract |
The total bytes read up to the current position. Calling resetSizeCounter() resets this value to zero.
Reimplemented in com.google.protobuf.CodedInputStream.IterableDirectByteBufferDecoder, com.google.protobuf.CodedInputStream.StreamDecoder, com.google.protobuf.CodedInputStream.UnsafeDirectNioDecoder, and com.google.protobuf.CodedInputStream.ArrayDecoder.
|
abstract |
Returns true if the stream has reached the end of the input. This is the case if either the end of the underlying input source has been reached or if the stream has reached a limit created using pushLimit(int).
Reimplemented in com.google.protobuf.CodedInputStream.IterableDirectByteBufferDecoder, com.google.protobuf.CodedInputStream.StreamDecoder, com.google.protobuf.CodedInputStream.UnsafeDirectNioDecoder, and com.google.protobuf.CodedInputStream.ArrayDecoder.
|
inlinestatic |
Create a new CodedInputStream wrapping the given ByteBuffer. The data starting from the ByteBuffer's current position to its limit will be read. The returned CodedInputStream may or may not share the underlying data in the ByteBuffer, therefore the ByteBuffer cannot be changed while the CodedInputStream is in use. Note that the ByteBuffer's position won't be changed by this function. Concurrent calls with the same ByteBuffer object are safe if no other thread is trying to alter the ByteBuffer's status.
Definition at line 174 of file CodedInputStream.java.
|
inlinestatic |
Create a new CodedInputStream wrapping the given byte array.
Definition at line 133 of file CodedInputStream.java.
|
inlinestatic |
Create a new CodedInputStream wrapping the given byte array slice.
Definition at line 138 of file CodedInputStream.java.
|
inlinestatic |
Create a new CodedInputStream wrapping the given InputStream.
Definition at line 79 of file CodedInputStream.java.
|
inlinestatic |
Create a new CodedInputStream wrapping the given InputStream, with a specified buffer size.
Definition at line 84 of file CodedInputStream.java.
|
inlinestatic |
Create a new CodedInputStream wrapping the given
.
Definition at line 96 of file CodedInputStream.java.
|
abstract |
Discards the current limit, returning to the previous limit.
oldLimit | The old limit, as returned by . |
Reimplemented in com.google.protobuf.CodedInputStream.IterableDirectByteBufferDecoder, com.google.protobuf.CodedInputStream.StreamDecoder, com.google.protobuf.CodedInputStream.UnsafeDirectNioDecoder, and com.google.protobuf.CodedInputStream.ArrayDecoder.
|
abstract |
Sets
to (current position) +
. This is called when descending into a length-delimited embedded message.
Note that
does NOT affect how many bytes the
reads from an underlying
when refreshing its buffer. If you need to prevent reading past a certain point in the underlying
(e.g. because you expect it to contain more data after the end of the message which you need to handle differently) then you must place a wrapper around your
which limits the amount of data that can be read from it.
Reimplemented in com.google.protobuf.CodedInputStream.IterableDirectByteBufferDecoder, com.google.protobuf.CodedInputStream.StreamDecoder, com.google.protobuf.CodedInputStream.UnsafeDirectNioDecoder, and com.google.protobuf.CodedInputStream.ArrayDecoder.
|
abstract |
Read a
field value from the stream.
Reimplemented in com.google.protobuf.CodedInputStream.IterableDirectByteBufferDecoder, com.google.protobuf.CodedInputStream.StreamDecoder, com.google.protobuf.CodedInputStream.UnsafeDirectNioDecoder, and com.google.protobuf.CodedInputStream.ArrayDecoder.
|
abstract |
Read a
field value from the stream.
Reimplemented in com.google.protobuf.CodedInputStream.IterableDirectByteBufferDecoder, com.google.protobuf.CodedInputStream.StreamDecoder, com.google.protobuf.CodedInputStream.UnsafeDirectNioDecoder, and com.google.protobuf.CodedInputStream.ArrayDecoder.
|
abstract |
Read a
field value from the stream.
Reimplemented in com.google.protobuf.CodedInputStream.IterableDirectByteBufferDecoder, com.google.protobuf.CodedInputStream.StreamDecoder, com.google.protobuf.CodedInputStream.UnsafeDirectNioDecoder, and com.google.protobuf.CodedInputStream.ArrayDecoder.
|
abstract |
Read a
field value from the stream.
Reimplemented in com.google.protobuf.CodedInputStream.IterableDirectByteBufferDecoder, com.google.protobuf.CodedInputStream.StreamDecoder, com.google.protobuf.CodedInputStream.UnsafeDirectNioDecoder, and com.google.protobuf.CodedInputStream.ArrayDecoder.
|
abstract |
Read a
field value from the stream.
Reimplemented in com.google.protobuf.CodedInputStream.IterableDirectByteBufferDecoder, com.google.protobuf.CodedInputStream.StreamDecoder, com.google.protobuf.CodedInputStream.UnsafeDirectNioDecoder, and com.google.protobuf.CodedInputStream.ArrayDecoder.
|
abstract |
Read an enum field value from the stream. Caller is responsible for converting the numeric value to an actual enum.
Reimplemented in com.google.protobuf.CodedInputStream.IterableDirectByteBufferDecoder, com.google.protobuf.CodedInputStream.StreamDecoder, com.google.protobuf.CodedInputStream.UnsafeDirectNioDecoder, and com.google.protobuf.CodedInputStream.ArrayDecoder.
|
abstract |
Read a
field value from the stream.
Reimplemented in com.google.protobuf.CodedInputStream.IterableDirectByteBufferDecoder, com.google.protobuf.CodedInputStream.StreamDecoder, com.google.protobuf.CodedInputStream.UnsafeDirectNioDecoder, and com.google.protobuf.CodedInputStream.ArrayDecoder.
|
abstract |
Read a
field value from the stream.
Reimplemented in com.google.protobuf.CodedInputStream.IterableDirectByteBufferDecoder, com.google.protobuf.CodedInputStream.StreamDecoder, com.google.protobuf.CodedInputStream.UnsafeDirectNioDecoder, and com.google.protobuf.CodedInputStream.ArrayDecoder.
|
abstract |
Read a
field value from the stream.
Reimplemented in com.google.protobuf.CodedInputStream.IterableDirectByteBufferDecoder, com.google.protobuf.CodedInputStream.StreamDecoder, com.google.protobuf.CodedInputStream.UnsafeDirectNioDecoder, and com.google.protobuf.CodedInputStream.ArrayDecoder.
|
abstract |
Read a
field value from the stream.
Reimplemented in com.google.protobuf.CodedInputStream.IterableDirectByteBufferDecoder, com.google.protobuf.CodedInputStream.StreamDecoder, com.google.protobuf.CodedInputStream.UnsafeDirectNioDecoder, and com.google.protobuf.CodedInputStream.ArrayDecoder.
|
abstract |
|
abstract |
Read an
field value from the stream.
Reimplemented in com.google.protobuf.CodedInputStream.IterableDirectByteBufferDecoder, com.google.protobuf.CodedInputStream.StreamDecoder, com.google.protobuf.CodedInputStream.UnsafeDirectNioDecoder, and com.google.protobuf.CodedInputStream.ArrayDecoder.
|
abstract |
Read an
field value from the stream.
Reimplemented in com.google.protobuf.CodedInputStream.IterableDirectByteBufferDecoder, com.google.protobuf.CodedInputStream.StreamDecoder, com.google.protobuf.CodedInputStream.UnsafeDirectNioDecoder, and com.google.protobuf.CodedInputStream.ArrayDecoder.
|
abstract |
Read an embedded message field value from the stream.
Reimplemented in com.google.protobuf.CodedInputStream.IterableDirectByteBufferDecoder, com.google.protobuf.CodedInputStream.StreamDecoder, com.google.protobuf.CodedInputStream.UnsafeDirectNioDecoder, and com.google.protobuf.CodedInputStream.ArrayDecoder.
|
abstract |
Read an embedded message field value from the stream.
|
abstract |
Read one byte from the input.
InvalidProtocolBufferException | The end of the stream or the current limit was reached. |
Reimplemented in com.google.protobuf.CodedInputStream.IterableDirectByteBufferDecoder, com.google.protobuf.CodedInputStream.StreamDecoder, com.google.protobuf.CodedInputStream.UnsafeDirectNioDecoder, and com.google.protobuf.CodedInputStream.ArrayDecoder.
|
abstract |
Read a fixed size of bytes from the input.
InvalidProtocolBufferException | The end of the stream or the current limit was reached. |
Reimplemented in com.google.protobuf.CodedInputStream.StreamDecoder, com.google.protobuf.CodedInputStream.IterableDirectByteBufferDecoder, com.google.protobuf.CodedInputStream.UnsafeDirectNioDecoder, and com.google.protobuf.CodedInputStream.ArrayDecoder.
|
abstract |
Read a 32-bit little-endian integer from the stream.
Reimplemented in com.google.protobuf.CodedInputStream.IterableDirectByteBufferDecoder, com.google.protobuf.CodedInputStream.StreamDecoder, com.google.protobuf.CodedInputStream.UnsafeDirectNioDecoder, and com.google.protobuf.CodedInputStream.ArrayDecoder.
|
abstract |
Read a 64-bit little-endian integer from the stream.
Reimplemented in com.google.protobuf.CodedInputStream.IterableDirectByteBufferDecoder, com.google.protobuf.CodedInputStream.StreamDecoder, com.google.protobuf.CodedInputStream.UnsafeDirectNioDecoder, and com.google.protobuf.CodedInputStream.ArrayDecoder.
|
abstract |
Read a raw Varint from the stream. If larger than 32 bits, discard the upper bits.
Reimplemented in com.google.protobuf.CodedInputStream.IterableDirectByteBufferDecoder, com.google.protobuf.CodedInputStream.StreamDecoder, com.google.protobuf.CodedInputStream.UnsafeDirectNioDecoder, and com.google.protobuf.CodedInputStream.ArrayDecoder.
|
inlinestatic |
Like readRawVarint32(InputStream), but expects that the caller has already read one byte. This allows the caller to determine if EOF has been reached before attempting to read.
Definition at line 547 of file CodedInputStream.java.
|
abstract |
Read a raw Varint from the stream.
Reimplemented in com.google.protobuf.CodedInputStream.IterableDirectByteBufferDecoder, com.google.protobuf.CodedInputStream.StreamDecoder, com.google.protobuf.CodedInputStream.UnsafeDirectNioDecoder, and com.google.protobuf.CodedInputStream.ArrayDecoder.
|
abstract |
Read an
field value from the stream.
Reimplemented in com.google.protobuf.CodedInputStream.IterableDirectByteBufferDecoder, com.google.protobuf.CodedInputStream.StreamDecoder, com.google.protobuf.CodedInputStream.UnsafeDirectNioDecoder, and com.google.protobuf.CodedInputStream.ArrayDecoder.
|
abstract |
Read an
field value from the stream.
Reimplemented in com.google.protobuf.CodedInputStream.IterableDirectByteBufferDecoder, com.google.protobuf.CodedInputStream.StreamDecoder, com.google.protobuf.CodedInputStream.UnsafeDirectNioDecoder, and com.google.protobuf.CodedInputStream.ArrayDecoder.
|
abstract |
Read an
field value from the stream.
Reimplemented in com.google.protobuf.CodedInputStream.IterableDirectByteBufferDecoder, com.google.protobuf.CodedInputStream.StreamDecoder, com.google.protobuf.CodedInputStream.UnsafeDirectNioDecoder, and com.google.protobuf.CodedInputStream.ArrayDecoder.
|
abstract |
Read an
field value from the stream.
Reimplemented in com.google.protobuf.CodedInputStream.IterableDirectByteBufferDecoder, com.google.protobuf.CodedInputStream.StreamDecoder, com.google.protobuf.CodedInputStream.UnsafeDirectNioDecoder, and com.google.protobuf.CodedInputStream.ArrayDecoder.
|
abstract |
Read a
field value from the stream. If the stream contains malformed UTF-8, replace the offending bytes with the standard UTF-8 replacement character.
Reimplemented in com.google.protobuf.CodedInputStream.IterableDirectByteBufferDecoder, com.google.protobuf.CodedInputStream.StreamDecoder, com.google.protobuf.CodedInputStream.UnsafeDirectNioDecoder, and com.google.protobuf.CodedInputStream.ArrayDecoder.
|
abstract |
Read a
field value from the stream. If the stream contains malformed UTF-8, throw exception InvalidProtocolBufferException.
Reimplemented in com.google.protobuf.CodedInputStream.IterableDirectByteBufferDecoder, com.google.protobuf.CodedInputStream.StreamDecoder, com.google.protobuf.CodedInputStream.UnsafeDirectNioDecoder, and com.google.protobuf.CodedInputStream.ArrayDecoder.
|
abstract |
Attempt to read a field tag, returning zero if we have reached EOF. Protocol message parsers use this to read tags, since a protocol message may legally end wherever a tag occurs, and zero is not a valid tag number.
Reimplemented in com.google.protobuf.CodedInputStream.IterableDirectByteBufferDecoder, com.google.protobuf.CodedInputStream.StreamDecoder, com.google.protobuf.CodedInputStream.UnsafeDirectNioDecoder, and com.google.protobuf.CodedInputStream.ArrayDecoder.
|
abstract |
Read a
field value from the stream.
Reimplemented in com.google.protobuf.CodedInputStream.IterableDirectByteBufferDecoder, com.google.protobuf.CodedInputStream.StreamDecoder, com.google.protobuf.CodedInputStream.UnsafeDirectNioDecoder, and com.google.protobuf.CodedInputStream.ArrayDecoder.
|
abstract |
Read a
field value from the stream.
Reimplemented in com.google.protobuf.CodedInputStream.IterableDirectByteBufferDecoder, com.google.protobuf.CodedInputStream.StreamDecoder, com.google.protobuf.CodedInputStream.UnsafeDirectNioDecoder, and com.google.protobuf.CodedInputStream.ArrayDecoder.
|
abstract |
Reads a
field value from the stream and merges it into the given {}. deprecated 16.
Reimplemented in com.google.protobuf.CodedInputStream.IterableDirectByteBufferDecoder, com.google.protobuf.CodedInputStream.StreamDecoder, com.google.protobuf.CodedInputStream.UnsafeDirectNioDecoder, and com.google.protobuf.CodedInputStream.ArrayDecoder.
|
abstract |
Resets the current size counter to zero (see setSizeLimit(int)). Only valid for {}-backed streams.
Reimplemented in com.google.protobuf.CodedInputStream.IterableDirectByteBufferDecoder, com.google.protobuf.CodedInputStream.StreamDecoder, com.google.protobuf.CodedInputStream.UnsafeDirectNioDecoder, and com.google.protobuf.CodedInputStream.ArrayDecoder.
|
inline |
Set the maximum message recursion depth. In order to prevent malicious messages from causing stack overflows,
limits how deeply messages may be nested. The default limit is 100.
Definition at line 387 of file CodedInputStream.java.
|
inline |
Only valid for InputStream-backed streams.
Set the maximum message size. In order to prevent malicious messages from exhausting memory or causing integer overflows,
limits how large a message may be. The default limit is
. You should set this limit as small as you can without harming your app's functionality. Note that size limits only apply when reading from an
, not when constructed around a raw byte array.
If you want to read several messages from a single CodedInputStream, you could call {} after each one to avoid hitting the size limit. the old limit.
Definition at line 410 of file CodedInputStream.java.
|
abstract |
Reads and discards a single field, given its tag value.
Reimplemented in com.google.protobuf.CodedInputStream.IterableDirectByteBufferDecoder, com.google.protobuf.CodedInputStream.StreamDecoder, com.google.protobuf.CodedInputStream.UnsafeDirectNioDecoder, and com.google.protobuf.CodedInputStream.ArrayDecoder.
|
abstract |
Reads a single field and writes it to output in wire format, given its tag value.
or
to skip to an output stream.
Reimplemented in com.google.protobuf.CodedInputStream.IterableDirectByteBufferDecoder, com.google.protobuf.CodedInputStream.StreamDecoder, com.google.protobuf.CodedInputStream.UnsafeDirectNioDecoder, and com.google.protobuf.CodedInputStream.ArrayDecoder.
|
abstract |
Reads and discards an entire message. This will read either until EOF or until an endgroup tag, whichever comes first.
Reimplemented in com.google.protobuf.CodedInputStream.IterableDirectByteBufferDecoder, com.google.protobuf.CodedInputStream.StreamDecoder, com.google.protobuf.CodedInputStream.UnsafeDirectNioDecoder, and com.google.protobuf.CodedInputStream.ArrayDecoder.
|
abstract |
Reads an entire message and writes it to output in wire format. This will read either until EOF or until an endgroup tag, whichever comes first.
Reimplemented in com.google.protobuf.CodedInputStream.IterableDirectByteBufferDecoder, com.google.protobuf.CodedInputStream.StreamDecoder, com.google.protobuf.CodedInputStream.UnsafeDirectNioDecoder, and com.google.protobuf.CodedInputStream.ArrayDecoder.
|
abstract |
Reads and discards
bytes.
InvalidProtocolBufferException | The end of the stream or the current limit was reached. |
Reimplemented in com.google.protobuf.CodedInputStream.StreamDecoder, com.google.protobuf.CodedInputStream.IterableDirectByteBufferDecoder, com.google.protobuf.CodedInputStream.UnsafeDirectNioDecoder, and com.google.protobuf.CodedInputStream.ArrayDecoder.
|
staticprivate |
Definition at line 62 of file CodedInputStream.java.
|
staticprivate |
Definition at line 63 of file CodedInputStream.java.
|
staticprivate |
Definition at line 65 of file CodedInputStream.java.
|
private |
Definition at line 419 of file CodedInputStream.java.