Classes | Public Member Functions | List of all members
com.google.protobuf.MessageLite Interface Reference
Inheritance diagram for com.google.protobuf.MessageLite:
Inheritance graph
[legend]

Classes

interface  Builder
 

Public Member Functions

Parser<? extends MessageLitegetParserForType ()
 
Parser<? extends MessageLitegetParserForType ()
 
int getSerializedSize ()
 
int getSerializedSize ()
 
Builder newBuilderForType ()
 
Builder newBuilderForType ()
 
Builder toBuilder ()
 
Builder toBuilder ()
 
byte[] toByteArray ()
 
byte[] toByteArray ()
 
ByteString toByteString ()
 
ByteString toByteString ()
 
void writeDelimitedTo (OutputStream output) throws IOException
 
void writeDelimitedTo (OutputStream output) throws IOException
 
void writeTo (CodedOutputStream output) throws IOException
 
void writeTo (CodedOutputStream output) throws IOException
 
void writeTo (OutputStream output) throws IOException
 
void writeTo (OutputStream output) throws IOException
 
- Public Member Functions inherited from com.google.protobuf.MessageLiteOrBuilder
MessageLite getDefaultInstanceForType ()
 
MessageLite getDefaultInstanceForType ()
 
boolean isInitialized ()
 
boolean isInitialized ()
 

Detailed Description

Abstract interface implemented by Protocol Message objects.

This interface is implemented by all protocol message objects. Non-lite messages additionally implement the Message interface, which is a subclass of MessageLite. Use MessageLite instead when you only need the subset of features which it supports – namely, nothing that uses descriptors or reflection. You can instruct the protocol compiler to generate classes which implement only MessageLite, not the full Message interface, by adding the follow line to the .proto file:

  option optimize_for = LITE_RUNTIME;

This is particularly useful on resource-constrained systems where the full protocol buffers runtime library is too big.

Note that on non-constrained systems (e.g. servers) when you need to link in lots of protocol definitions, a better way to reduce total code footprint is to use

optimize_for =
CODE_SIZE

. This will make the generated code smaller while still supporting all the same features (at the expense of speed).

optimize_for = LITE_RUNTIME

is best when you only have a small number of message types linked into your binary, in which case the size of the protocol buffers runtime itself is the biggest problem.

Author
kento.nosp@m.n@go.nosp@m.ogle..nosp@m.com Kenton Varda

Definition at line 65 of file bloaty/third_party/protobuf/java/core/src/main/java/com/google/protobuf/MessageLite.java.

Member Function Documentation

◆ getParserForType() [1/2]

Parser<? extends MessageLite> com.google.protobuf.MessageLite.getParserForType ( )

◆ getParserForType() [2/2]

Parser<? extends MessageLite> com.google.protobuf.MessageLite.getParserForType ( )

◆ getSerializedSize() [1/2]

int com.google.protobuf.MessageLite.getSerializedSize ( )

◆ getSerializedSize() [2/2]

int com.google.protobuf.MessageLite.getSerializedSize ( )

Get the number of bytes required to encode this message. The result is only computed on the first call and memoized after that.

If this message requires more than Integer.MAX_VALUE bytes to encode, the return value will be smaller than the actual number of bytes required and might be negative.

Implemented in com.google.protobuf.GeneratedMessageV3, com.google.protobuf.GeneratedMessageV3, com.google.protobuf.GeneratedMessage, com.google.protobuf.GeneratedMessage, com.google.protobuf.DynamicMessage, com.google.protobuf.DynamicMessage, com.google.protobuf.UnknownFieldSet, com.google.protobuf.UnknownFieldSet, com.google.protobuf.MapEntry< K, V >, com.google.protobuf.MapEntry< K, V >, com.google.protobuf.AbstractMessage, and com.google.protobuf.AbstractMessage.

◆ newBuilderForType() [1/2]

Builder com.google.protobuf.MessageLite.newBuilderForType ( )

◆ newBuilderForType() [2/2]

Builder com.google.protobuf.MessageLite.newBuilderForType ( )

◆ toBuilder() [1/2]

Builder com.google.protobuf.MessageLite.toBuilder ( )

◆ toBuilder() [2/2]

Builder com.google.protobuf.MessageLite.toBuilder ( )

◆ toByteArray() [1/2]

byte [] com.google.protobuf.MessageLite.toByteArray ( )

◆ toByteArray() [2/2]

byte [] com.google.protobuf.MessageLite.toByteArray ( )

◆ toByteString() [1/2]

ByteString com.google.protobuf.MessageLite.toByteString ( )

◆ toByteString() [2/2]

ByteString com.google.protobuf.MessageLite.toByteString ( )

◆ writeDelimitedTo() [1/2]

void com.google.protobuf.MessageLite.writeDelimitedTo ( OutputStream  output) throws IOException

◆ writeDelimitedTo() [2/2]

void com.google.protobuf.MessageLite.writeDelimitedTo ( OutputStream  output) throws IOException

◆ writeTo() [1/4]

void com.google.protobuf.MessageLite.writeTo ( CodedOutputStream  output) throws IOException

◆ writeTo() [2/4]

void com.google.protobuf.MessageLite.writeTo ( CodedOutputStream  output) throws IOException

◆ writeTo() [3/4]

void com.google.protobuf.MessageLite.writeTo ( OutputStream  output) throws IOException

Serializes the message and writes it to

. This is just a trivial wrapper around writeTo(CodedOutputStream). This does not flush or close the stream.

NOTE: Protocol Buffers are not self-delimiting. Therefore, if you write any more data to the stream after the message, you must somehow ensure that the parser on the receiving end does not interpret this as being part of the protocol message. This can be done e.g. by writing the size of the message before the data, then making sure to limit the input to that size on the receiving end (e.g. by wrapping the InputStream in one which limits the input). Alternatively, just use writeDelimitedTo(OutputStream).

Implemented in com.google.protobuf.UnknownFieldSet, com.google.protobuf.UnknownFieldSet, com.google.protobuf.AbstractMessageLite< MessageType extends AbstractMessageLite< MessageType, BuilderType, BuilderType extends AbstractMessageLite.Builder< MessageType, BuilderType >, and com.google.protobuf.AbstractMessageLite< MessageType extends AbstractMessageLite< MessageType, BuilderType, BuilderType extends AbstractMessageLite.Builder< MessageType, BuilderType >.

◆ writeTo() [4/4]

void com.google.protobuf.MessageLite.writeTo ( OutputStream  output) throws IOException

Serializes the message and writes it to

. This is just a trivial wrapper around writeTo(CodedOutputStream). This does not flush or close the stream.

NOTE: Protocol Buffers are not self-delimiting. Therefore, if you write any more data to the stream after the message, you must somehow ensure that the parser on the receiving end does not interpret this as being part of the protocol message. This can be done e.g. by writing the size of the message before the data, then making sure to limit the input to that size on the receiving end (e.g. by wrapping the InputStream in one which limits the input). Alternatively, just use writeDelimitedTo(OutputStream).

Implemented in com.google.protobuf.UnknownFieldSet, com.google.protobuf.UnknownFieldSet, com.google.protobuf.AbstractMessageLite< MessageType extends AbstractMessageLite< MessageType, BuilderType, BuilderType extends AbstractMessageLite.Builder< MessageType, BuilderType >, and com.google.protobuf.AbstractMessageLite< MessageType extends AbstractMessageLite< MessageType, BuilderType, BuilderType extends AbstractMessageLite.Builder< MessageType, BuilderType >.


The documentation for this interface was generated from the following file:
gmock_output_test.output
output
Definition: bloaty/third_party/googletest/googlemock/test/gmock_output_test.py:175


grpc
Author(s):
autogenerated on Fri May 16 2025 03:03:07