webkit  2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
Classes | Public Member Functions | Static Public Member Functions | List of all members
com.google.protobuf.CodedInputStream Class Reference

Public Member Functions

int readTag () throws IOException
 
void checkLastTagWas (final int value) throws InvalidProtocolBufferException
 
int getLastTag ()
 
boolean skipField (final int tag) throws IOException
 
boolean skipField (final int tag, final CodedOutputStream output) throws IOException
 
void skipMessage () throws IOException
 
void skipMessage (CodedOutputStream output) throws IOException
 
double readDouble () throws IOException
 
float readFloat () throws IOException
 
long readUInt64 () throws IOException
 
long readInt64 () throws IOException
 
int readInt32 () throws IOException
 
long readFixed64 () throws IOException
 
int readFixed32 () throws IOException
 
boolean readBool () throws IOException
 
String readString () throws IOException
 
String readStringRequireUtf8 () throws IOException
 
void readGroup (final int fieldNumber, final MessageLite.Builder builder, final ExtensionRegistryLite extensionRegistry) throws IOException
 
void readUnknownGroup (final int fieldNumber, final MessageLite.Builder builder) throws IOException
 
void readMessage (final MessageLite.Builder builder, final ExtensionRegistryLite extensionRegistry) throws IOException
 
ByteString readBytes () throws IOException
 
byte [] readByteArray () throws IOException
 
ByteBuffer readByteBuffer () throws IOException
 
int readUInt32 () throws IOException
 
int readEnum () throws IOException
 
int readSFixed32 () throws IOException
 
long readSFixed64 () throws IOException
 
int readSInt32 () throws IOException
 
long readSInt64 () throws IOException
 
int readRawVarint32 () throws IOException
 
long readRawVarint64 () throws IOException
 
int readRawLittleEndian32 () throws IOException
 
long readRawLittleEndian64 () throws IOException
 
void enableAliasing (boolean enabled)
 
int setRecursionLimit (final int limit)
 
int setSizeLimit (final int limit)
 
void resetSizeCounter ()
 
int pushLimit (int byteLimit) throws InvalidProtocolBufferException
 
void popLimit (final int oldLimit)
 
int getBytesUntilLimit ()
 
boolean isAtEnd () throws IOException
 
int getTotalBytesRead ()
 
byte readRawByte () throws IOException
 
byte [] readRawBytes (final int size) throws IOException
 
void skipRawBytes (final int size) throws IOException
 

Static Public Member Functions

static CodedInputStream newInstance (final InputStream input)
 
static CodedInputStream newInstance (final byte[] buf)
 
static CodedInputStream newInstance (final byte[] buf, final int off, final int len)
 
static CodedInputStream newInstance (ByteBuffer buf)
 
static int readRawVarint32 (final int firstByte, final InputStream input) throws IOException
 
static int decodeZigZag32 (final int n)
 
static long decodeZigZag64 (final long n)
 

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

Member Function Documentation

◆ checkLastTagWas()

void com.google.protobuf.CodedInputStream.checkLastTagWas ( final int  value) throws InvalidProtocolBufferException
inline

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

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

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

◆ enableAliasing()

void com.google.protobuf.CodedInputStream.enableAliasing ( boolean  enabled)
inline

◆ getBytesUntilLimit()

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

Returns the number of bytes to be read before the current limit. If no limit is set, returns -1.

◆ getLastTag()

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

◆ getTotalBytesRead()

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

The total bytes read up to the current position. Calling resetSizeCounter() resets this value to zero.

◆ isAtEnd()

boolean com.google.protobuf.CodedInputStream.isAtEnd ( ) throws IOException
inline

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

◆ newInstance() [1/4]

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

Create a new CodedInputStream wrapping the given InputStream.

◆ newInstance() [2/4]

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

Create a new CodedInputStream wrapping the given byte array.

◆ newInstance() [3/4]

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.

◆ newInstance() [4/4]

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.

◆ popLimit()

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

Discards the current limit, returning to the previous limit.

Parameters
oldLimitThe old limit, as returned by .

◆ pushLimit()

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

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

CodedInputStream

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.

◆ readBool()

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

Read a

bool

field value from the stream.

◆ readByteArray()

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

Read a

field value from the stream.

◆ readByteBuffer()

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

Read a

field value from the stream.

◆ readBytes()

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

Read a

field value from the stream.

◆ readDouble()

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

Read a

double

field value from the stream.

◆ readEnum()

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

Read an enum field value from the stream. Caller is responsible for converting the numeric value to an actual enum.

◆ readFixed32()

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

Read a

fixed32

field value from the stream.

◆ readFixed64()

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

Read a

fixed64

field value from the stream.

◆ readFloat()

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

Read a

float

field value from the stream.

◆ readGroup()

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

Read a

field value from the stream.

◆ readInt32()

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

Read an

field value from the stream.

◆ readInt64()

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

Read an

field value from the stream.

◆ readMessage()

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

Read an embedded message field value from the stream.

◆ readRawByte()

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

Read one byte from the input.

Exceptions
InvalidProtocolBufferExceptionThe end of the stream or the current limit was reached.

◆ readRawBytes()

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

Read a fixed size of bytes from the input.

Exceptions
InvalidProtocolBufferExceptionThe end of the stream or the current limit was reached.

◆ readRawLittleEndian32()

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

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

◆ readRawLittleEndian64()

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

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

◆ readRawVarint32() [1/2]

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

Read a raw Varint from the stream. If larger than 32 bits, discard the upper bits.

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

◆ readRawVarint64()

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

Read a raw Varint from the stream.

◆ readSFixed32()

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

Read an

sfixed32

field value from the stream.

◆ readSFixed64()

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

Read an

sfixed64

field value from the stream.

◆ readSInt32()

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

Read an

sint32

field value from the stream.

◆ readSInt64()

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

Read an

sint64

field value from the stream.

◆ readString()

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

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.

◆ readStringRequireUtf8()

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

Read a

string

field value from the stream. If the stream contains malformed UTF-8, throw exception InvalidProtocolBufferException.

◆ readTag()

int com.google.protobuf.CodedInputStream.readTag ( ) throws IOException
inline

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.

◆ readUInt32()

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

Read a

field value from the stream.

◆ readUInt64()

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

Read a

field value from the stream.

◆ readUnknownGroup()

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

Reads a

field value from the stream and merges it into the given UnknownFieldSet.

Deprecated:
UnknownFieldSet.Builder now implements MessageLite.Builder, so you can just call readGroup.

◆ resetSizeCounter()

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

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

◆ setRecursionLimit()

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,

CodedInputStream

limits how deeply messages may be nested. The default limit is 64.

Returns
the old limit.

◆ setSizeLimit()

int com.google.protobuf.CodedInputStream.setSizeLimit ( final int  limit)
inline

Set the maximum message size. In order to prevent malicious messages from exhausting memory or causing integer overflows,

CodedInputStream

limits how large a message may be. The default limit is 64MB. 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 (nor with ByteString#newCodedInput).

If you want to read several messages from a single CodedInputStream, you could call resetSizeCounter() after each one to avoid hitting the size limit.

Returns
the old limit.

◆ skipField() [1/2]

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

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
.

◆ skipField() [2/2]

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

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
.

◆ skipMessage() [1/2]

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

Reads and discards an entire message. This will read either until EOF or until an endgroup tag, whichever comes first.

◆ skipMessage() [2/2]

void com.google.protobuf.CodedInputStream.skipMessage ( CodedOutputStream  output) throws IOException
inline

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.

◆ skipRawBytes()

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

Reads and discards

bytes.

Exceptions
InvalidProtocolBufferExceptionThe end of the stream or the current limit was reached.

The documentation for this class was generated from the following file: