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.
| Modifier and Type | Class and Description |
|---|---|
| public static interface | MessageLite.Builder
Abstract interface implemented by Protocol Message builders. |
| Modifier and Type | Method and Description |
|---|---|
| public Parser | |
| public int | |
| public MessageLite. | |
| public MessageLite. | |
| public byte[] | |
| public ByteString | |
| public void | writeDelimitedTo(OutputStream output)
Like |
| public void | |
| public void |
| getParserForType | back to summary |
|---|---|
| public Parser Gets the parser for a message of the same type as this message. | |
| getSerializedSize | back to summary |
|---|---|
| public int getSerializedSize() Get the number of bytes required to encode this message. The result is only computed on the first call and memoized after that. | |
| newBuilderForType | back to summary |
|---|---|
| public MessageLite. Constructs a new builder for a message of the same type as this message. | |
| toBuilder | back to summary |
|---|---|
| public MessageLite. Constructs a builder initialized with the current message. Use this to derive a new message from the current one. | |
| toByteArray | back to summary |
|---|---|
| public byte[] toByteArray() Serializes the message to a | |
| toByteString | back to summary |
|---|---|
| public ByteString toByteString() Serializes the message to a | |
| writeDelimitedTo | back to summary |
|---|---|
| public void writeDelimitedTo(OutputStream output) throws IOException Like | |
| writeTo | back to summary |
|---|---|
| public void writeTo(CodedOutputStream output) throws IOException Serializes the message and writes it to | |
| writeTo | back to summary |
|---|---|
| public void writeTo(OutputStream output) throws IOException Serializes the message and writes it to 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 | |
| Modifier and Type | Method and Description |
|---|---|
| public MessageLite | |
| public MessageLite | buildPartial()
Like |
| public MessageLite. | |
| public MessageLite. | |
| public boolean | Returns: True if successful, or false if the stream is at EOF when the method starts. Any other error (including reaching EOF during parsing) will cause an exception to be thrown.Like |
| public boolean | mergeDelimitedFrom(InputStream input, ExtensionRegistryLite extensionRegistry)
Like |
| public MessageLite. | mergeFrom(CodedInputStream input)
Parses a message of this type from the input and merges it with this message. |
| public MessageLite. | mergeFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)
Like |
| public MessageLite. | Returns: thisParse |
| public MessageLite. | Returns: thisParse |
| public MessageLite. | Returns: thisParse |
| public MessageLite. | Returns: thisParse |
| public MessageLite. | Returns: thisParse |
| public MessageLite. | Returns: thisParse |
| public MessageLite. | Returns: thisParse a message of this type from |
| public MessageLite. | Returns: thisParse a message of this type from |
| public MessageLite. |
| build | back to summary |
|---|---|
| public MessageLite build() Constructs the message based on the state of the Builder. Subsequent changes to the Builder will not affect the returned message.
| |
| buildPartial | back to summary |
|---|---|
| public MessageLite buildPartial() Like | |
| clear | back to summary |
|---|---|
| public MessageLite. Resets all fields to their default values. | |
| clone | back to summary |
|---|---|
| public MessageLite. Clones the Builder.
| |
| mergeDelimitedFrom | back to summary |
|---|---|
| public boolean mergeDelimitedFrom(InputStream input) throws IOException Like
| |
| mergeDelimitedFrom | back to summary |
|---|---|
| public boolean mergeDelimitedFrom(InputStream input, ExtensionRegistryLite extensionRegistry) throws IOException Like | |
| mergeFrom | back to summary |
|---|---|
| public MessageLite. Parses a message of this type from the input and merges it with this message. Warning: This does not verify that all required fields are present in the input message.
If you call
Note The caller should call | |
| mergeFrom | back to summary |
|---|---|
| public MessageLite. Like | |
| mergeFrom | back to summary |
|---|---|
| public MessageLite. Parse
| |
| mergeFrom | back to summary |
|---|---|
| public MessageLite. Parse
| |
| mergeFrom | back to summary |
|---|---|
| public MessageLite. Parse
| |
| mergeFrom | back to summary |
|---|---|
| public MessageLite. Parse
| |
| mergeFrom | back to summary |
|---|---|
| public MessageLite. Parse
| |
| mergeFrom | back to summary |
|---|---|
| public MessageLite. Parse
| |
| mergeFrom | back to summary |
|---|---|
| public MessageLite. Parse a message of this type from Despite usually reading the entire input, this does not close the stream.
| |
| mergeFrom | back to summary |
|---|---|
| public MessageLite. Parse a message of this type from
| |
| mergeFrom | back to summary |
|---|---|
| public MessageLite. Merge Merging occurs as follows. For each field: This is equivalent to the | |