Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
com.google.protobuf.CodedInputStream Class Referenceabstract
Inheritance diagram for com.google.protobuf.CodedInputStream:
Inheritance graph
[legend]

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
 

Detailed Description

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
kento.nosp@m.n@go.nosp@m.ogle..nosp@m.com Kenton Varda

Definition at line 61 of file CodedInputStream.java.

Constructor & Destructor Documentation

◆ CodedInputStream()

com.google.protobuf.CodedInputStream.CodedInputStream ( )
inlineprivate

Disable construction/inheritance outside of this class.

Definition at line 198 of file CodedInputStream.java.

Member Function Documentation

◆ checkLastTagWas()

abstract void com.google.protobuf.CodedInputStream.checkLastTagWas ( final int  value) throws InvalidProtocolBufferException
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.

Exceptions
InvalidProtocolBufferException

Reimplemented in com.google.protobuf.CodedInputStream.IterableDirectByteBufferDecoder, com.google.protobuf.CodedInputStream.StreamDecoder, com.google.protobuf.CodedInputStream.UnsafeDirectNioDecoder, and com.google.protobuf.CodedInputStream.ArrayDecoder.

◆ decodeZigZag32()

static int com.google.protobuf.CodedInputStream.decodeZigZag32 ( final int  n)
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.)

Parameters
nAn unsigned 32-bit integer, stored in a signed int because Java has no explicit unsigned support.
Returns
A signed 32-bit integer.

Definition at line 526 of file CodedInputStream.java.

◆ decodeZigZag64()

static long com.google.protobuf.CodedInputStream.decodeZigZag64 ( final long  n)
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.)

Parameters
nAn unsigned 64-bit integer, stored in a signed int because Java has no explicit unsigned support.
Returns
A signed 64-bit integer.

Definition at line 539 of file CodedInputStream.java.

◆ enableAliasing()

abstract void com.google.protobuf.CodedInputStream.enableAliasing ( boolean  enabled)
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.

◆ getBytesUntilLimit()

abstract int com.google.protobuf.CodedInputStream.getBytesUntilLimit ( )
abstract

◆ getLastTag()

abstract int com.google.protobuf.CodedInputStream.getLastTag ( )
abstract

◆ getTotalBytesRead()

abstract int com.google.protobuf.CodedInputStream.getTotalBytesRead ( )
abstract

◆ isAtEnd()

abstract boolean com.google.protobuf.CodedInputStream.isAtEnd ( ) throws IOException
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.

◆ newInstance() [1/6]

static CodedInputStream com.google.protobuf.CodedInputStream.newInstance ( ByteBuffer  buf)
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.

◆ newInstance() [2/6]

static CodedInputStream com.google.protobuf.CodedInputStream.newInstance ( final byte[]  buf)
inlinestatic

Create a new CodedInputStream wrapping the given byte array.

Definition at line 133 of file CodedInputStream.java.

◆ newInstance() [3/6]

static CodedInputStream com.google.protobuf.CodedInputStream.newInstance ( final byte[]  buf,
final int  off,
final int  len 
)
inlinestatic

Create a new CodedInputStream wrapping the given byte array slice.

Definition at line 138 of file CodedInputStream.java.

◆ newInstance() [4/6]

static CodedInputStream com.google.protobuf.CodedInputStream.newInstance ( final InputStream  input)
inlinestatic

Create a new CodedInputStream wrapping the given InputStream.

Definition at line 79 of file CodedInputStream.java.

◆ newInstance() [5/6]

static CodedInputStream com.google.protobuf.CodedInputStream.newInstance ( final InputStream  input,
int  bufferSize 
)
inlinestatic

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

Definition at line 84 of file CodedInputStream.java.

◆ newInstance() [6/6]

static CodedInputStream com.google.protobuf.CodedInputStream.newInstance ( final Iterable< ByteBuffer >  input)
inlinestatic

Create a new CodedInputStream wrapping the given

Iterable <ByteBuffer>

.

Definition at line 96 of file CodedInputStream.java.

◆ popLimit()

abstract void com.google.protobuf.CodedInputStream.popLimit ( final int  oldLimit)
abstract

◆ pushLimit()

abstract int com.google.protobuf.CodedInputStream.pushLimit ( int  byteLimit) throws InvalidProtocolBufferException
abstract

Sets

currentLimit

to (current position) +

byteLimit

. This is called when descending into a length-delimited embedded message.

Note that

does NOT affect how many bytes the

reads from an underlying

InputStream

when refreshing its buffer. If you need to prevent reading past a certain point in the underlying

InputStream

(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

InputStream

which limits the amount of data that can be read from it.

Returns
the old limit.

Reimplemented in com.google.protobuf.CodedInputStream.IterableDirectByteBufferDecoder, com.google.protobuf.CodedInputStream.StreamDecoder, com.google.protobuf.CodedInputStream.UnsafeDirectNioDecoder, and com.google.protobuf.CodedInputStream.ArrayDecoder.

◆ readBool()

abstract boolean com.google.protobuf.CodedInputStream.readBool ( ) throws IOException
abstract

◆ readByteArray()

abstract byte [] com.google.protobuf.CodedInputStream.readByteArray ( ) throws IOException
abstract

◆ readByteBuffer()

abstract ByteBuffer com.google.protobuf.CodedInputStream.readByteBuffer ( ) throws IOException
abstract

◆ readBytes()

abstract ByteString com.google.protobuf.CodedInputStream.readBytes ( ) throws IOException
abstract

◆ readDouble()

abstract double com.google.protobuf.CodedInputStream.readDouble ( ) throws IOException
abstract

◆ readEnum()

abstract int com.google.protobuf.CodedInputStream.readEnum ( ) throws IOException
abstract

◆ readFixed32()

abstract int com.google.protobuf.CodedInputStream.readFixed32 ( ) throws IOException
abstract

◆ readFixed64()

abstract long com.google.protobuf.CodedInputStream.readFixed64 ( ) throws IOException
abstract

◆ readFloat()

abstract float com.google.protobuf.CodedInputStream.readFloat ( ) throws IOException
abstract

◆ readGroup() [1/2]

abstract void com.google.protobuf.CodedInputStream.readGroup ( final int  fieldNumber,
final MessageLite.Builder  builder,
final ExtensionRegistryLite  extensionRegistry 
) throws IOException
abstract

◆ readGroup() [2/2]

abstract <T extends MessageLite> T com.google.protobuf.CodedInputStream.readGroup ( final int  fieldNumber,
final Parser< T parser,
final ExtensionRegistryLite  extensionRegistry 
) throws IOException
abstract

Read a

field value from the stream.

◆ readInt32()

abstract int com.google.protobuf.CodedInputStream.readInt32 ( ) throws IOException
abstract

◆ readInt64()

abstract long com.google.protobuf.CodedInputStream.readInt64 ( ) throws IOException
abstract

◆ readMessage() [1/2]

abstract void com.google.protobuf.CodedInputStream.readMessage ( final MessageLite.Builder  builder,
final ExtensionRegistryLite  extensionRegistry 
) throws IOException
abstract

◆ readMessage() [2/2]

abstract <T extends MessageLite> T com.google.protobuf.CodedInputStream.readMessage ( final Parser< T parser,
final ExtensionRegistryLite  extensionRegistry 
) throws IOException
abstract

Read an embedded message field value from the stream.

◆ readRawByte()

abstract byte com.google.protobuf.CodedInputStream.readRawByte ( ) throws IOException
abstract

◆ readRawBytes()

abstract byte [] com.google.protobuf.CodedInputStream.readRawBytes ( final int  size) throws IOException
abstract

◆ readRawLittleEndian32()

abstract int com.google.protobuf.CodedInputStream.readRawLittleEndian32 ( ) throws IOException
abstract

◆ readRawLittleEndian64()

abstract long com.google.protobuf.CodedInputStream.readRawLittleEndian64 ( ) throws IOException
abstract

◆ readRawVarint32() [1/2]

abstract int com.google.protobuf.CodedInputStream.readRawVarint32 ( ) throws IOException
abstract

◆ readRawVarint32() [2/2]

static int com.google.protobuf.CodedInputStream.readRawVarint32 ( final int  firstByte,
final InputStream  input 
) throws IOException
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.

◆ readRawVarint64()

abstract long com.google.protobuf.CodedInputStream.readRawVarint64 ( ) throws IOException
abstract

◆ readSFixed32()

abstract int com.google.protobuf.CodedInputStream.readSFixed32 ( ) throws IOException
abstract

◆ readSFixed64()

abstract long com.google.protobuf.CodedInputStream.readSFixed64 ( ) throws IOException
abstract

◆ readSInt32()

abstract int com.google.protobuf.CodedInputStream.readSInt32 ( ) throws IOException
abstract

◆ readSInt64()

abstract long com.google.protobuf.CodedInputStream.readSInt64 ( ) throws IOException
abstract

◆ readString()

abstract String com.google.protobuf.CodedInputStream.readString ( ) throws IOException
abstract

Read a

string

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.

◆ readStringRequireUtf8()

abstract String com.google.protobuf.CodedInputStream.readStringRequireUtf8 ( ) throws IOException
abstract

◆ readTag()

abstract int com.google.protobuf.CodedInputStream.readTag ( ) throws IOException
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.

◆ readUInt32()

abstract int com.google.protobuf.CodedInputStream.readUInt32 ( ) throws IOException
abstract

◆ readUInt64()

abstract long com.google.protobuf.CodedInputStream.readUInt64 ( ) throws IOException
abstract

◆ readUnknownGroup()

abstract void com.google.protobuf.CodedInputStream.readUnknownGroup ( final int  fieldNumber,
final MessageLite.Builder  builder 
) throws IOException
abstract

◆ resetSizeCounter()

abstract void com.google.protobuf.CodedInputStream.resetSizeCounter ( )
abstract

◆ setRecursionLimit()

final int com.google.protobuf.CodedInputStream.setRecursionLimit ( final int  limit)
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.

Returns
the old limit.

Definition at line 387 of file CodedInputStream.java.

◆ setSizeLimit()

final int com.google.protobuf.CodedInputStream.setSizeLimit ( final int  limit)
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

Integer.MAX_INT

. 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

InputStream

, 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.

◆ skipField() [1/2]

abstract boolean com.google.protobuf.CodedInputStream.skipField ( final int  tag) throws IOException
abstract

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

Returns
false
if the tag is an endgroup tag, in which case nothing is skipped. Otherwise, returns
true
.

Reimplemented in com.google.protobuf.CodedInputStream.IterableDirectByteBufferDecoder, com.google.protobuf.CodedInputStream.StreamDecoder, com.google.protobuf.CodedInputStream.UnsafeDirectNioDecoder, and com.google.protobuf.CodedInputStream.ArrayDecoder.

◆ skipField() [2/2]

abstract boolean com.google.protobuf.CodedInputStream.skipField ( final int  tag,
final CodedOutputStream  output 
) throws IOException
abstract

Reads a single field and writes it to output in wire format, given its tag value.

Returns
false
if the tag is an endgroup tag, in which case nothing is skipped. Otherwise, returns
true
.
Deprecated:
use

or

UnknownFieldSetLite

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.

◆ skipMessage() [1/2]

abstract void com.google.protobuf.CodedInputStream.skipMessage ( ) throws IOException
abstract

◆ skipMessage() [2/2]

abstract void com.google.protobuf.CodedInputStream.skipMessage ( CodedOutputStream  output) throws IOException
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.

◆ skipRawBytes()

abstract void com.google.protobuf.CodedInputStream.skipRawBytes ( final int  size) throws IOException
abstract

Member Data Documentation

◆ DEFAULT_BUFFER_SIZE

final int com.google.protobuf.CodedInputStream.DEFAULT_BUFFER_SIZE = 4096
staticprivate

Definition at line 62 of file CodedInputStream.java.

◆ DEFAULT_RECURSION_LIMIT

final int com.google.protobuf.CodedInputStream.DEFAULT_RECURSION_LIMIT = 100
staticprivate

Definition at line 63 of file CodedInputStream.java.

◆ DEFAULT_SIZE_LIMIT

final int com.google.protobuf.CodedInputStream.DEFAULT_SIZE_LIMIT = Integer.MAX_VALUE
staticprivate

Definition at line 65 of file CodedInputStream.java.

◆ shouldDiscardUnknownFields

boolean com.google.protobuf.CodedInputStream.shouldDiscardUnknownFields = false
private

Definition at line 419 of file CodedInputStream.java.


The documentation for this class was generated from the following file:
google::protobuf::int64
int64_t int64
Definition: protobuf/src/google/protobuf/stubs/port.h:151
google::protobuf::uint32
uint32_t uint32
Definition: protobuf/src/google/protobuf/stubs/port.h:155
google::protobuf::python::cmessage::UnknownFieldSet
static PyObject * UnknownFieldSet(CMessage *self)
Definition: python/google/protobuf/pyext/message.cc:2501
bytes
uint8 bytes[10]
Definition: coded_stream_unittest.cc:153
com.google.protobuf.CodedInputStream.CodedInputStream
CodedInputStream()
Definition: CodedInputStream.java:198
google::protobuf::int32
int32_t int32
Definition: protobuf/src/google/protobuf/stubs/port.h:150
google::protobuf::uint64
uint64_t uint64
Definition: protobuf/src/google/protobuf/stubs/port.h:156
size
GLsizeiptr size
Definition: glcorearb.h:2943
com.google.protobuf.CodedInputStream.pushLimit
abstract int pushLimit(int byteLimit)
group
static uint32_t * group(tarjan *t, upb_refcounted *r)
Definition: ruby/ext/google/protobuf_c/upb.c:5943


libaditof
Author(s):
autogenerated on Wed May 21 2025 02:07:06