Top Description Inners Fields Constructors Methods
com.google.protobuf

public abstract Class AbstractMessageLite<MessageType extends com.google.protobuf.AbstractMessageLite<MessageType, BuilderType>, BuilderType extends AbstractMessageLite.Builder<MessageType, BuilderType>>

extends Object
implements MessageLite
Class Inheritance
All Implemented Interfaces
com.google.protobuf.MessageLite, com.google.protobuf.MessageLiteOrBuilder
Known Direct Subclasses
com.google.protobuf.GeneratedMessageLite, com.google.protobuf.AbstractMessage
Static Imports
com.google.protobuf.Internal.checkNotNull

A partial implementation of the MessageLite interface which implements as many methods of that interface as possible in terms of other methods.
Author
[email protected] Kenton Varda

Nested and Inner Type Summary

Modifier and TypeClass and Description
public abstract static class
AbstractMessageLite.Builder<MessageType extends AbstractMessageLite<MessageType, BuilderType>, BuilderType extends AbstractMessageLite.Builder<MessageType, BuilderType>>

A partial implementation of the Message.Builder interface which implements as many methods of that interface as possible in terms of other methods.

Field Summary

Modifier and TypeField and Description
protected int

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected static <T> void
addAll(final Iterable<T> values, final Collection<? super T> list)

Deprecated
protected static <T> void
addAll(final Iterable<T> values, final List<? super T> list)

protected static void
pack-priv int
private String
pack-priv UninitializedMessageException
newUninitializedMessageException()

Package private helper method for AbstractParser to create UninitializedMessageException.

pack-priv void
public byte[]
toByteArray()

Implements com.google.protobuf.MessageLite.toByteArray.

Serializes the message to a byte array and returns it.
public ByteString
toByteString()

Implements com.google.protobuf.MessageLite.toByteString.

Serializes the message to a ByteString and returns it.
public void
writeDelimitedTo(final OutputStream output)

Implements com.google.protobuf.MessageLite.writeDelimitedTo.

Like writeTo(OutputStream), but writes the size of the message as a varint before writing the data.
public void
writeTo(final OutputStream output)

Implements com.google.protobuf.MessageLite.writeTo.

Serializes the message and writes it to output.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

memoizedHashCodeback to summary
protected int memoizedHashCode

Constructor Detail

AbstractMessageLiteback to summary
public AbstractMessageLite()

Method Detail

addAllback to summary
protected static <T> void addAll(final Iterable<T> values, final Collection<? super T> list)

Deprecated

Annotations
@Deprecated
addAllback to summary
protected static <T> void addAll(final Iterable<T> values, final List<? super T> list)
checkByteStringIsUtf8back to summary
protected static void checkByteStringIsUtf8(ByteString byteString) throws IllegalArgumentException
getMemoizedSerializedSizeback to summary
pack-priv int getMemoizedSerializedSize()
getSerializingExceptionMessageback to summary
private String getSerializingExceptionMessage(String target)
newUninitializedMessageExceptionback to summary
pack-priv UninitializedMessageException newUninitializedMessageException()

Package private helper method for AbstractParser to create UninitializedMessageException.

setMemoizedSerializedSizeback to summary
pack-priv void setMemoizedSerializedSize(int size)
toByteArrayback to summary
public byte[] toByteArray()

Implements com.google.protobuf.MessageLite.toByteArray.

Doc from com.google.protobuf.MessageLite.toByteArray.

Serializes the message to a byte array and returns it. This is just a trivial wrapper around writeTo(CodedOutputStream).

Annotations
@Override
toByteStringback to summary
public ByteString toByteString()

Implements com.google.protobuf.MessageLite.toByteString.

Doc from com.google.protobuf.MessageLite.toByteString.

Serializes the message to a ByteString and returns it. This is just a trivial wrapper around writeTo(CodedOutputStream).

Annotations
@Override
writeDelimitedToback to summary
public void writeDelimitedTo(final OutputStream output) throws IOException

Implements com.google.protobuf.MessageLite.writeDelimitedTo.

Doc from com.google.protobuf.MessageLite.writeDelimitedTo.

Like writeTo(OutputStream), but writes the size of the message as a varint before writing the data. This allows more data to be written to the stream after the message without the need to delimit the message data yourself. Use Builder#mergeDelimitedFrom(InputStream) (or the static method YourMessageType.parseDelimitedFrom(InputStream)) to parse messages written by this method.

Annotations
@Override
writeToback to summary
public void writeTo(final OutputStream output) throws IOException

Implements com.google.protobuf.MessageLite.writeTo.

Doc from com.google.protobuf.MessageLite.writeTo.

Serializes the message and writes it to output. 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).

Annotations
@Override
com.google.protobuf back to summary

public abstract Class AbstractMessageLite.Builder<MessageType extends com.google.protobuf.AbstractMessageLite<MessageType, BuilderType>, BuilderType extends AbstractMessageLite.Builder<MessageType, BuilderType>>

extends Object
implements Builder
Class Inheritance
All Implemented Interfaces
com.google.protobuf.MessageLite.Builder, java.lang.Cloneable, com.google.protobuf.MessageLiteOrBuilder
Known Direct Subclasses
com.google.protobuf.GeneratedMessageLite.Builder, com.google.protobuf.AbstractMessage.Builder
Annotations
@SuppressWarnings:unchecked

A partial implementation of the Message.Builder interface which implements as many methods of that interface as possible in terms of other methods.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
AbstractMessageLite.Builder.LimitedInputStream

An InputStream implementations which reads from some other InputStream but is limited to a particular number of bytes.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected static <T> void
addAll(final Iterable<T> values, final Collection<? super T> list)

Deprecated
protected static <T> void
addAll(final Iterable<T> values, final List<? super T> list)

Adds the values to the list.

private static <T> void
addAllCheckingNulls(Iterable<T> values, List<? super T> list)

public abstract BuilderType
private String
protected abstract BuilderType
internalMergeFrom(MessageType message)

public boolean
public boolean
public BuilderType
mergeFrom(final CodedInputStream input)

Implements com.google.protobuf.MessageLite.Builder.mergeFrom.

Parses a message of this type from the input and merges it with this message.
public abstract BuilderType
mergeFrom(final CodedInputStream input, final ExtensionRegistryLite extensionRegistry)

Redeclares com.google.protobuf.MessageLite.Builder.mergeFrom.

Like Builder#mergeFrom(CodedInputStream), but also parses extensions.
public BuilderType
mergeFrom(final ByteString data)

Implements com.google.protobuf.MessageLite.Builder.mergeFrom.

Parse data as a message of this type and merge it with the message being built.
public BuilderType
mergeFrom(final ByteString data, final ExtensionRegistryLite extensionRegistry)

Implements com.google.protobuf.MessageLite.Builder.mergeFrom.

Parse data as a message of this type and merge it with the message being built.
public BuilderType
mergeFrom(final byte[] data)

Implements com.google.protobuf.MessageLite.Builder.mergeFrom.

Parse data as a message of this type and merge it with the message being built.
public BuilderType
mergeFrom(final byte[] data, final int off, final int len)

Implements com.google.protobuf.MessageLite.Builder.mergeFrom.

Parse data as a message of this type and merge it with the message being built.
public BuilderType
mergeFrom(final byte[] data, final ExtensionRegistryLite extensionRegistry)

Implements com.google.protobuf.MessageLite.Builder.mergeFrom.

Parse data as a message of this type and merge it with the message being built.
public BuilderType
mergeFrom(final byte[] data, final int off, final int len, final ExtensionRegistryLite extensionRegistry)

Implements com.google.protobuf.MessageLite.Builder.mergeFrom.

Parse data as a message of this type and merge it with the message being built.
public BuilderType
mergeFrom(final InputStream input)

Implements com.google.protobuf.MessageLite.Builder.mergeFrom.

Parse a message of this type from input and merge it with the message being built.
public BuilderType
mergeFrom(final InputStream input, final ExtensionRegistryLite extensionRegistry)

Implements com.google.protobuf.MessageLite.Builder.mergeFrom.

Parse a message of this type from input and merge it with the message being built.
public BuilderType
mergeFrom(final MessageLite other)

Implements com.google.protobuf.MessageLite.Builder.mergeFrom.

Merge other into the message being built.
protected static UninitializedMessageException
newUninitializedMessageException(MessageLite message)

Construct an UninitializedMessageException reporting missing fields in the given message.

Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Builderback to summary
public Builder()

Method Detail

addAllback to summary
protected static <T> void addAll(final Iterable<T> values, final Collection<? super T> list)

Deprecated

Annotations
@Deprecated
addAllback to summary
protected static <T> void addAll(final Iterable<T> values, final List<? super T> list)

Adds the values to the list. This is a helper method used by generated code. Users should ignore it.

Exceptions
NullPointerException:
if values or any of the elements of values is null.
addAllCheckingNullsback to summary
private static <T> void addAllCheckingNulls(Iterable<T> values, List<? super T> list)
cloneback to summary
public abstract BuilderType clone()

Redeclares com.google.protobuf.MessageLite.Builder.clone.

Overrides java.lang.Object.clone.

Doc from com.google.protobuf.MessageLite.Builder.clone.

Clones the Builder.

Returns:BuilderType

Doc from java.lang.Object.clone.

a clone of this instance.

Annotations
@Override
getReadingExceptionMessageback to summary
private String getReadingExceptionMessage(String target)
internalMergeFromback to summary
protected abstract BuilderType internalMergeFrom(MessageType message)
mergeDelimitedFromback to summary
public boolean mergeDelimitedFrom(final InputStream input, final ExtensionRegistryLite extensionRegistry) throws IOException

Implements com.google.protobuf.MessageLite.Builder.mergeDelimitedFrom.

Doc from com.google.protobuf.MessageLite.Builder.mergeDelimitedFrom.

Like mergeDelimitedFrom(InputStream) but supporting extensions.

Annotations
@Override
mergeDelimitedFromback to summary
public boolean mergeDelimitedFrom(final InputStream input) throws IOException

Implements com.google.protobuf.MessageLite.Builder.mergeDelimitedFrom.

Doc from com.google.protobuf.MessageLite.Builder.mergeDelimitedFrom.

Like mergeFrom(InputStream), but does not read until EOF. Instead, the size of the message (encoded as a varint) is read first, then the message data. Use MessageLite#writeDelimitedTo(OutputStream) to write messages in this format.

Returns:boolean

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.

Annotations
@Override
mergeFromback to summary
public BuilderType mergeFrom(final CodedInputStream input) throws IOException

Implements com.google.protobuf.MessageLite.Builder.mergeFrom.

Doc from com.google.protobuf.MessageLite.Builder.mergeFrom.

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 build() without setting all required fields, it will throw an UninitializedMessageException, which is a RuntimeException and thus might not be caught. There are a few good ways to deal with this:

  • Call isInitialized() to verify that all required fields are set before building.
  • Use buildPartial() to build, which ignores missing required fields.

Note

The caller should call CodedInputStream#checkLastTagWas(int) after calling this to verify that the last tag seen was the appropriate end-group tag, or zero for EOF.

Annotations
@Override
mergeFromback to summary
public abstract BuilderType mergeFrom(final CodedInputStream input, final ExtensionRegistryLite extensionRegistry) throws IOException

Redeclares com.google.protobuf.MessageLite.Builder.mergeFrom.

Doc from com.google.protobuf.MessageLite.Builder.mergeFrom.

Like Builder#mergeFrom(CodedInputStream), but also parses extensions. The extensions that you want to be able to parse must be registered in extensionRegistry. Extensions not in the registry will be treated as unknown fields.

Annotations
@Override
mergeFromback to summary
public BuilderType mergeFrom(final ByteString data) throws InvalidProtocolBufferException

Implements com.google.protobuf.MessageLite.Builder.mergeFrom.

Doc from com.google.protobuf.MessageLite.Builder.mergeFrom.

Parse data as a message of this type and merge it with the message being built. This is just a small wrapper around mergeFrom(CodedInputStream).

Returns:BuilderType

this

Annotations
@Override
mergeFromback to summary
public BuilderType mergeFrom(final ByteString data, final ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException

Implements com.google.protobuf.MessageLite.Builder.mergeFrom.

Doc from com.google.protobuf.MessageLite.Builder.mergeFrom.

Parse data as a message of this type and merge it with the message being built. This is just a small wrapper around mergeFrom(CodedInputStream, ExtensionRegistryLite).

Returns:BuilderType

this

Annotations
@Override
mergeFromback to summary
public BuilderType mergeFrom(final byte[] data) throws InvalidProtocolBufferException

Implements com.google.protobuf.MessageLite.Builder.mergeFrom.

Doc from com.google.protobuf.MessageLite.Builder.mergeFrom.

Parse data as a message of this type and merge it with the message being built. This is just a small wrapper around mergeFrom(CodedInputStream).

Returns:BuilderType

this

Annotations
@Override
mergeFromback to summary
public BuilderType mergeFrom(final byte[] data, final int off, final int len) throws InvalidProtocolBufferException

Implements com.google.protobuf.MessageLite.Builder.mergeFrom.

Doc from com.google.protobuf.MessageLite.Builder.mergeFrom.

Parse data as a message of this type and merge it with the message being built. This is just a small wrapper around mergeFrom(CodedInputStream).

Returns:BuilderType

this

Annotations
@Override
mergeFromback to summary
public BuilderType mergeFrom(final byte[] data, final ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException

Implements com.google.protobuf.MessageLite.Builder.mergeFrom.

Doc from com.google.protobuf.MessageLite.Builder.mergeFrom.

Parse data as a message of this type and merge it with the message being built. This is just a small wrapper around mergeFrom(CodedInputStream, ExtensionRegistryLite).

Returns:BuilderType

this

Annotations
@Override
mergeFromback to summary
public BuilderType mergeFrom(final byte[] data, final int off, final int len, final ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException

Implements com.google.protobuf.MessageLite.Builder.mergeFrom.

Doc from com.google.protobuf.MessageLite.Builder.mergeFrom.

Parse data as a message of this type and merge it with the message being built. This is just a small wrapper around mergeFrom(CodedInputStream, ExtensionRegistryLite).

Returns:BuilderType

this

Annotations
@Override
mergeFromback to summary
public BuilderType mergeFrom(final InputStream input) throws IOException

Implements com.google.protobuf.MessageLite.Builder.mergeFrom.

Doc from com.google.protobuf.MessageLite.Builder.mergeFrom.

Parse a message of this type from input and merge it with the message being built. This is just a small wrapper around mergeFrom(CodedInputStream). Note that this method always reads the entire input (unless it throws an exception). If you want it to stop earlier, you will need to wrap your input in some wrapper stream that limits reading. Or, use MessageLite#writeDelimitedTo(OutputStream) to write your message and mergeDelimitedFrom(InputStream) to read it.

Despite usually reading the entire input, this does not close the stream.

Returns:BuilderType

this

Annotations
@Override
mergeFromback to summary
public BuilderType mergeFrom(final InputStream input, final ExtensionRegistryLite extensionRegistry) throws IOException

Implements com.google.protobuf.MessageLite.Builder.mergeFrom.

Doc from com.google.protobuf.MessageLite.Builder.mergeFrom.

Parse a message of this type from input and merge it with the message being built. This is just a small wrapper around mergeFrom(CodedInputStream, ExtensionRegistryLite).

Returns:BuilderType

this

Annotations
@Override
mergeFromback to summary
public BuilderType mergeFrom(final MessageLite other)

Implements com.google.protobuf.MessageLite.Builder.mergeFrom.

Doc from com.google.protobuf.MessageLite.Builder.mergeFrom.

Merge other into the message being built. other must have the exact same type as this (i.e. getClass().equals(getDefaultInstanceForType().getClass())).

Merging occurs as follows. For each field:
* For singular primitive fields, if the field is set in other, then other's value overwrites the value in this message.
* For singular message fields, if the field is set in other, it is merged into the corresponding sub-message of this message using the same merging rules.
* For repeated fields, the elements in other are concatenated with the elements in this message. * For oneof groups, if the other message has one of the fields set, the group of this message is cleared and replaced by the field of the other message, so that the oneof constraint is preserved.

This is equivalent to the Message::MergeFrom method in C++.

Annotations
@Override
@SuppressWarnings:unchecked
newUninitializedMessageExceptionback to summary
protected static UninitializedMessageException newUninitializedMessageException(MessageLite message)

Construct an UninitializedMessageException reporting missing fields in the given message.

com.google.protobuf back to summary

pack-priv final Class AbstractMessageLite.Builder.LimitedInputStream

extends FilterInputStream
Class Inheritance

An InputStream implementations which reads from some other InputStream but is limited to a particular number of bytes. Used by mergeDelimitedFrom(). This is intentionally package-private so that UnknownFieldSet can share it.

Field Summary

Modifier and TypeField and Description
private int
Inherited from java.io.FilterInputStream:
in

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public int
available()

Overrides java.io.FilterInputStream.available.

Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking by the next caller of a method for this input stream.
public int
read()

Overrides java.io.FilterInputStream.read.

Reads the next byte of data from the input stream.
public int
read(final byte[]
the buffer into which the data is read.
b
,
final int
the start offset in array b at which the data is written.
off
,
int
the maximum number of bytes to read.
len
)

Overrides java.io.FilterInputStream.read.

Reads up to len bytes of data from this input stream into an array of bytes.
public long
skip(final long
the number of bytes to be skipped.
n
)

Overrides java.io.FilterInputStream.skip.

Skips over and discards n bytes of data from the input stream.
Inherited from java.io.FilterInputStream:
closemarkmarkSupportedreadreset

Field Detail

limitback to summary
private int limit

Constructor Detail

LimitedInputStreamback to summary
pack-priv LimitedInputStream(InputStream in, int limit)

Method Detail

availableback to summary
public int available() throws IOException

Overrides java.io.FilterInputStream.available.

Doc from java.io.FilterInputStream.available.

Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking by the next caller of a method for this input stream. The next caller might be the same thread or another thread. A single read or skip of this many bytes will not block, but may read or skip fewer bytes.

Returns:int

an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
readback to summary
public int read() throws IOException

Overrides java.io.FilterInputStream.read.

Doc from java.io.FilterInputStream.read.

Reads the next byte of data from the input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.

Returns:int

the next byte of data, or -1 if the end of the stream is reached.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
readback to summary
public int read(final byte[] b, final int off, int len) throws IOException

Overrides java.io.FilterInputStream.read.

Doc from java.io.FilterInputStream.read.

Reads up to len bytes of data from this input stream into an array of bytes. If len is not zero, the method blocks until some input is available; otherwise, no bytes are read and 0 is returned.

Parameters
b:byte[]

the buffer into which the data is read.

off:int

the start offset in array b at which the data is written.

len:int

the maximum number of bytes to read.

Returns:int

the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
skipback to summary
public long skip(final long n) throws IOException

Overrides java.io.FilterInputStream.skip.

Doc from java.io.FilterInputStream.skip.

Skips over and discards n bytes of data from the input stream. The skip method may, for a variety of reasons, end up skipping over some smaller number of bytes, possibly 0. The actual number of bytes skipped is returned.

Parameters
n:long

the number of bytes to be skipped.

Returns:long

the actual number of bytes skipped.

Annotations
@Override
Exceptions
IOException:
if in.skip(n) throws an IOException.