Class AbstractMessageLite<MessageType extends AbstractMessageLite<MessageType, BuilderType>, BuilderType extends AbstractMessageLite.Builder<MessageType, BuilderType>>
- All Implemented Interfaces:
MessageLite, MessageLiteOrBuilder
- Direct Known Subclasses:
AbstractMessage, GeneratedMessageLite
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAbstractMessageLite.Builder<MessageType extends AbstractMessageLite<MessageType, BuilderType>, BuilderType extends AbstractMessageLite.Builder<MessageType, BuilderType>>A partial implementation of theMessage.Builderinterface which implements as many methods of that interface as possible in terms of other methods.protected static interfaceInterface for an enum which signifies which field in aoneofwas specified. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static <T> voidprotected static voidcheckByteStringIsUtf8(ByteString byteString) (package private) int(package private) intgetSerializedSize(Schema schema) private StringgetSerializingExceptionMessage(String target) (package private) UninitializedMessageExceptionPackage private helper method for AbstractParser to create UninitializedMessageException.(package private) voidsetMemoizedSerializedSize(int size) byte[]Serializes the message to abytearray and returns it.Serializes the message to aByteStringand returns it.voidwriteDelimitedTo(OutputStream output) LikeMessageLite.writeTo(OutputStream), but writes the size of the message as a varint before writing the data.voidwriteTo(OutputStream output) Serializes the message and writes it tooutput.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface MessageLite
getParserForType, getSerializedSize, newBuilderForType, toBuilder, writeToMethods inherited from interface MessageLiteOrBuilder
getDefaultInstanceForType, isInitialized
-
Field Details
-
memoizedHashCode
protected int memoizedHashCode
-
-
Constructor Details
-
AbstractMessageLite
public AbstractMessageLite()
-
-
Method Details
-
toByteString
Description copied from interface:MessageLiteSerializes the message to aByteStringand 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:
toByteStringin interfaceMessageLite
-
toByteArray
public byte[] toByteArray()Description copied from interface:MessageLiteSerializes the message to abytearray 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:
toByteArrayin interfaceMessageLite
-
writeTo
Description copied from interface:MessageLiteSerializes 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:
writeToin interfaceMessageLite- Throws:
IOException
-
writeDelimitedTo
Description copied from interface:MessageLiteLikeMessageLite.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:
writeDelimitedToin interfaceMessageLite- Throws:
IOException
-
getMemoizedSerializedSize
int getMemoizedSerializedSize() -
setMemoizedSerializedSize
void setMemoizedSerializedSize(int size) -
getSerializedSize
-
newUninitializedMessageException
UninitializedMessageException newUninitializedMessageException()Package private helper method for AbstractParser to create UninitializedMessageException. -
getSerializingExceptionMessage
-
checkByteStringIsUtf8
- Throws:
IllegalArgumentException
-
addAll
-