public abstract class AbstractMessageLite<MessageType extends AbstractMessageLite<MessageType,BuilderType>,BuilderType extends AbstractMessageLite.Builder<MessageType,BuilderType>> extends Object implements MessageLite
MessageLite interface which implements as many methods of that interface as
possible in terms of other methods.
Users should generally ignore this class and use the MessageLite interface instead.
This class is intended to only be extended by protoc created gencode. It is not intended or supported to extend this class, and any protected methods may be removed without it being considered a breaking change as long as all supported gencode does not depend on the changed methods.
| Modifier and Type | Class and Description |
|---|---|
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. |
protected static interface |
AbstractMessageLite.InternalOneOfEnum
Interface for an enum which signifies which field in a
oneof was specified. |
| Modifier and Type | Field and Description |
|---|---|
protected int |
memoizedHashCode |
| Constructor and Description |
|---|
AbstractMessageLite() |
| Modifier and Type | Method and Description |
|---|---|
protected static <T> void |
addAll(Iterable<T> values,
List<? super T> list) |
protected static void |
checkByteStringIsUtf8(ByteString byteString) |
byte[] |
toByteArray()
Serializes the message to a
byte array and returns it. |
ByteString |
toByteString()
Serializes the message to a
ByteString and returns it. |
void |
writeDelimitedTo(OutputStream output)
Like
MessageLite.writeTo(OutputStream), but writes the size of the message as a varint before writing the data. |
void |
writeTo(OutputStream output)
Serializes the message and writes it to
output. |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetParserForType, getSerializedSize, newBuilderForType, toBuilder, writeTogetDefaultInstanceForType, isInitializedprotected static void checkByteStringIsUtf8(ByteString byteString) throws IllegalArgumentException
IllegalArgumentExceptionpublic byte[] toByteArray()
MessageLitebyte array and returns it. This is just a trivial wrapper around
MessageLite.writeTo(CodedOutputStream).
If this message requires more than Integer.MAX_VALUE bytes to encode, the behavior is unpredictable. It may throw
a runtime exception or truncate or slice the data.toByteArray in interface MessageLitepublic ByteString toByteString()
MessageLiteByteString and returns it. This is just a trivial wrapper around
MessageLite.writeTo(CodedOutputStream).
If this message requires more than Integer.MAX_VALUE bytes to encode, the behavior is unpredictable. It may throw
a runtime exception or truncate or slice the data.toByteString in interface MessageLitepublic void writeDelimitedTo(OutputStream output) throws IOException
MessageLiteMessageLite.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 MessageLite.Builder.mergeDelimitedFrom(InputStream) (or the static method YourMessageType.parseDelimitedFrom(InputStream)) to parse messages written by this method.writeDelimitedTo in interface MessageLiteIOExceptionpublic void writeTo(OutputStream output) throws IOException
MessageLiteoutput. This is just a trivial wrapper around
MessageLite.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, for instance, by writing the size of the message before the data, then
making sure to limit the input to that size on the receiving end by wrapping the InputStream in one which limits
the input. Alternatively, just use MessageLite.writeDelimitedTo(OutputStream).
writeTo in interface MessageLiteIOException