Package com.google.protobuf
Class AbstractMessageLite<MessageType extends AbstractMessageLite<MessageType,BuilderType>,BuilderType extends AbstractMessageLite.Builder<MessageType,BuilderType>>
- java.lang.Object
-
- com.google.protobuf.AbstractMessageLite<MessageType,BuilderType>
-
- All Implemented Interfaces:
MessageLite
,MessageLiteOrBuilder
- Direct Known Subclasses:
AbstractMessage
,GeneratedMessageLite
public abstract class AbstractMessageLite<MessageType extends AbstractMessageLite<MessageType,BuilderType>,BuilderType extends AbstractMessageLite.Builder<MessageType,BuilderType>> extends java.lang.Object implements MessageLite
A partial implementation of theMessageLite
interface which implements as many methods of that interface as possible in terms of other methods.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AbstractMessageLite.Builder<MessageType extends AbstractMessageLite<MessageType,BuilderType>,BuilderType extends AbstractMessageLite.Builder<MessageType,BuilderType>>
A partial implementation of theMessage.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 aoneof
was specified.
-
Field Summary
Fields Modifier and Type Field Description protected int
memoizedHashCode
-
Constructor Summary
Constructors Constructor Description AbstractMessageLite()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected static <T> void
addAll(java.lang.Iterable<T> values, java.util.Collection<? super T> list)
Deprecated.protected static <T> void
addAll(java.lang.Iterable<T> values, java.util.List<? super T> list)
protected static void
checkByteStringIsUtf8(ByteString byteString)
byte[]
toByteArray()
Serializes the message to abyte
array and returns it.ByteString
toByteString()
Serializes the message to aByteString
and returns it.void
writeDelimitedTo(java.io.OutputStream output)
LikeMessageLite.writeTo(OutputStream)
, but writes the size of the message as a varint before writing the data.void
writeTo(java.io.OutputStream output)
Serializes the message and writes it tooutput
.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.google.protobuf.MessageLite
getParserForType, getSerializedSize, newBuilderForType, toBuilder, writeTo
-
Methods inherited from interface com.google.protobuf.MessageLiteOrBuilder
getDefaultInstanceForType, isInitialized
-
-
-
-
Method Detail
-
toByteString
public ByteString toByteString()
Description copied from interface:MessageLite
Serializes the message to aByteString
and returns it. This is just a trivial wrapper aroundMessageLite.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.- Specified by:
toByteString
in interfaceMessageLite
-
toByteArray
public byte[] toByteArray()
Description copied from interface:MessageLite
Serializes the message to abyte
array and returns it. This is just a trivial wrapper aroundMessageLite.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.- Specified by:
toByteArray
in interfaceMessageLite
-
writeTo
public void writeTo(java.io.OutputStream output) throws java.io.IOException
Description copied from interface:MessageLite
Serializes the message and writes it tooutput
. This is just a trivial wrapper aroundMessageLite.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)
.- Specified by:
writeTo
in interfaceMessageLite
- Throws:
java.io.IOException
-
writeDelimitedTo
public void writeDelimitedTo(java.io.OutputStream output) throws java.io.IOException
Description copied from interface:MessageLite
LikeMessageLite.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. UseMessageLite.Builder.mergeDelimitedFrom(InputStream)
(or the static methodYourMessageType.parseDelimitedFrom(InputStream)
) to parse messages written by this method.- Specified by:
writeDelimitedTo
in interfaceMessageLite
- Throws:
java.io.IOException
-
checkByteStringIsUtf8
protected static void checkByteStringIsUtf8(ByteString byteString) throws java.lang.IllegalArgumentException
- Throws:
java.lang.IllegalArgumentException
-
addAll
@Deprecated protected static <T> void addAll(java.lang.Iterable<T> values, java.util.Collection<? super T> list)
Deprecated.
-
addAll
protected static <T> void addAll(java.lang.Iterable<T> values, java.util.List<? super T> list)
-
-