Top Description Inners Fields Constructors Methods
com.google.protobuf

public abstract Class CodedInputStream

extends Object
Class Inheritance
Known Direct Subclasses
com.google.protobuf.CodedInputStream.ArrayDecoder, com.google.protobuf.CodedInputStream.UnsafeDirectNioDecoder, com.google.protobuf.CodedInputStream.StreamDecoder, com.google.protobuf.CodedInputStream.IterableDirectByteBufferDecoder
Static Imports
com.google.protobuf.Internal.EMPTY_BYTE_ARRAY, .Internal.EMPTY_BYTE_BUFFER, .Internal.UTF_8, .Internal.checkNotNull, .WireFormat.FIXED32_SIZE, .WireFormat.FIXED64_SIZE, .WireFormat.MAX_VARINT_SIZE

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.

Author
[email protected] Kenton Varda

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
CodedInputStream.ArrayDecoder

A CodedInputStream implementation that uses a backing array as the input.

private static class
CodedInputStream.IterableDirectByteBufferDecoder

Implementation of CodedInputStream that uses an <ByteBuffer> as the data source.

private static class
CodedInputStream.StreamDecoder

Implementation of CodedInputStream that uses an InputStream as the data source.

private static class
CodedInputStream.UnsafeDirectNioDecoder

A CodedInputStream implementation that uses a backing direct ByteBuffer as the input.

Field Summary

Modifier and TypeField and Description
private static final int
private static final int
private static final int
pack-priv int
recursionDepth

Visible for subclasses.

pack-priv int
private boolean
pack-priv int
sizeLimit

Visible for subclasses.

Constructor Summary

AccessConstructor and Description
private
CodedInputStream()

Disable construction/inheritance outside of this class.

Method Summary

Modifier and TypeMethod and Description
public abstract void
checkLastTagWas(final int value)

Verifies that the last call to readTag() returned the given tag value.

public static int

Returns:

A signed 32-bit integer.
decodeZigZag32
(final int
An unsigned 32-bit integer, stored in a signed int because Java has no explicit unsigned support.
n
)

Decode a ZigZag-encoded 32-bit value.

public static long

Returns:

A signed 64-bit integer.
decodeZigZag64
(final long
An unsigned 64-bit integer, stored in a signed int because Java has no explicit unsigned support.
n
)

Decode a ZigZag-encoded 64-bit value.

pack-priv final void
discardUnknownFields()

Sets this CodedInputStream to discard unknown fields.

public abstract void
enableAliasing(boolean enabled)

Enables ByteString aliasing of the underlying buffer, trading off on buffer pinning for data copies.

public abstract int
getBytesUntilLimit()

Returns the number of bytes to be read before the current limit.

public abstract int
public abstract int
getTotalBytesRead()

The total bytes read up to the current position.

public abstract boolean
isAtEnd()

Returns true if the stream has reached the end of the input.

public static CodedInputStream
newInstance(final InputStream input)

Create a new CodedInputStream wrapping the given InputStream.

public static CodedInputStream
newInstance(final InputStream input, int bufferSize)

Create a new CodedInputStream wrapping the given InputStream, with a specified buffer size.

public static CodedInputStream
newInstance(final Iterable<ByteBuffer> input)

Create a new CodedInputStream wrapping the given Iterable <ByteBuffer>.

pack-priv static CodedInputStream
newInstance(final Iterable<ByteBuffer> bufs, final boolean bufferIsImmutable)

Create a new CodedInputStream wrapping the given Iterable <ByteBuffer>.

public static CodedInputStream
newInstance(final byte[] buf)

Create a new CodedInputStream wrapping the given byte array.

public static CodedInputStream
newInstance(final byte[] buf, final int off, final int len)

Create a new CodedInputStream wrapping the given byte array slice.

pack-priv static CodedInputStream
newInstance(final byte[] buf, final int off, final int len, final boolean bufferIsImmutable)

Create a new CodedInputStream wrapping the given byte array slice.

public static CodedInputStream
newInstance(ByteBuffer buf)

Create a new CodedInputStream wrapping the given ByteBuffer.

pack-priv static CodedInputStream
newInstance(ByteBuffer buf, boolean bufferIsImmutable)

Create a new CodedInputStream wrapping the given buffer.

public abstract void
popLimit(final int
The old limit, as returned by pushLimit.
oldLimit
)

Discards the current limit, returning to the previous limit.

public abstract int

Returns:

the old limit.
pushLimit
(int byteLimit)

Sets currentLimit to (current position) + byteLimit.

public abstract boolean
readBool()

Read a bool field value from the stream.

public abstract byte[]
readByteArray()

Read a bytes field value from the stream.

public abstract ByteBuffer
readByteBuffer()

Read a bytes field value from the stream.

public abstract ByteString
readBytes()

Read a bytes field value from the stream.

public abstract double
readDouble()

Read a double field value from the stream.

public abstract int
readEnum()

Read an enum field value from the stream.

public abstract int
readFixed32()

Read a fixed32 field value from the stream.

public abstract long
readFixed64()

Read a fixed64 field value from the stream.

public abstract float
readFloat()

Read a float field value from the stream.

public abstract void
readGroup(final int fieldNumber, final MessageLite.Builder builder, final ExtensionRegistryLite extensionRegistry)

Read a group field value from the stream.

public abstract <T extends MessageLite> T
readGroup(final int fieldNumber, final Parser<T> parser, final ExtensionRegistryLite extensionRegistry)

Read a group field value from the stream.

public abstract int
readInt32()

Read an int32 field value from the stream.

public abstract long
readInt64()

Read an int64 field value from the stream.

public abstract void
readMessage(final MessageLite.Builder builder, final ExtensionRegistryLite extensionRegistry)

Read an embedded message field value from the stream.

public abstract <T extends MessageLite> T
readMessage(final Parser<T> parser, final ExtensionRegistryLite extensionRegistry)

Read an embedded message field value from the stream.

public abstract byte
readRawByte()

Read one byte from the input.

public abstract byte[]
readRawBytes(final int size)

Read a fixed size of bytes from the input.

public abstract int
readRawLittleEndian32()

Read a 32-bit little-endian integer from the stream.

public abstract long
readRawLittleEndian64()

Read a 64-bit little-endian integer from the stream.

public abstract int
readRawVarint32()

Read a raw Varint from the stream.

public static int
readRawVarint32(final int firstByte, final InputStream input)

Like readRawVarint32(InputStream), but expects that the caller has already read one byte.

pack-priv static int
readRawVarint32(final InputStream input)

Reads a varint from the input one byte at a time, so that it does not read any bytes after the end of the varint.

public abstract long
readRawVarint64()

Read a raw Varint from the stream.

pack-priv abstract long
readRawVarint64SlowPath()

Variant of readRawVarint64 for when uncomfortably close to the limit.

public abstract int
readSFixed32()

Read an sfixed32 field value from the stream.

public abstract long
readSFixed64()

Read an sfixed64 field value from the stream.

public abstract int
readSInt32()

Read an sint32 field value from the stream.

public abstract long
readSInt64()

Read an sint64 field value from the stream.

public abstract String
readString()

Read a string field value from the stream.

public abstract String
readStringRequireUtf8()

Read a string field value from the stream.

public abstract int
readTag()

Attempt to read a field tag, returning zero if we have reached EOF.

public abstract int
readUInt32()

Read a uint32 field value from the stream.

public abstract long
readUInt64()

Read a uint64 field value from the stream.

public abstract void
readUnknownGroup(final int fieldNumber, final MessageLite.Builder builder)

Deprecated UnknownFieldSet.Builder now implements MessageLite.Builder, so you can just call readGroup.
Reads a group field value from the stream and merges it into the given UnknownFieldSet.
public abstract void
resetSizeCounter()

Resets the current size counter to zero (see setSizeLimit(int)).

public final int

Returns:

the old limit.
setRecursionLimit
(final int limit)

Set the maximum message recursion depth.

public final int

Returns:

the old limit.
setSizeLimit
(final int limit)

Only valid for InputStream-backed streams.

pack-priv final boolean
shouldDiscardUnknownFields()

Whether unknown fields in this input stream should be discarded during parsing into full runtime messages.

public abstract boolean

Returns:

false if the tag is an endgroup tag, in which case nothing is skipped. Otherwise, returns true.
skipField
(final int tag)

Reads and discards a single field, given its tag value.

public abstract boolean

Returns:

false if the tag is an endgroup tag, in which case nothing is skipped. Otherwise, returns true.
skipField
(final int tag, final CodedOutputStream output)

Deprecated use UnknownFieldSet or UnknownFieldSetLite to skip to an output stream.
Reads a single field and writes it to output in wire format, given its tag value.
public abstract void
skipMessage()

Reads and discards an entire message.

public abstract void
skipMessage(CodedOutputStream output)

Reads an entire message and writes it to output in wire format.

public abstract void
skipRawBytes(final int size)

Reads and discards size bytes.

pack-priv final void
unsetDiscardUnknownFields()

Reverts the unknown fields preservation behavior for Proto2 and Proto3 full runtime to their default.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait