Package com.google.protobuf
Class MessageSetSchema<T>
java.lang.Object
com.google.protobuf.MessageSetSchema<T>
- All Implemented Interfaces:
Schema<T>
Schema used for proto2 messages using message_set_wireformat.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final MessageLite
private final ExtensionSchema
<?> private final boolean
private final UnknownFieldSchema
<?, ?> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
MessageSetSchema
(UnknownFieldSchema<?, ?> unknownFieldSchema, ExtensionSchema<?> extensionSchema, MessageLite defaultInstance) -
Method Summary
Modifier and TypeMethodDescriptionboolean
Determine of the two messages are equal.int
getSerializedSize
(T message) Compute the serialized size of the message.private <UT,
UB> int getUnknownFieldsSerializedSize
(UnknownFieldSchema<UT, UB> schema, T message) int
Compute a hashCode for the message.final boolean
isInitialized
(T message) Checks whether all required fields are set.void
makeImmutable
(T message) Marks repeated/map/extension/unknown fields as immutable.void
mergeFrom
(T message, byte[] data, int position, int limit, ArrayDecoders.Registers registers) Like the above but parses from a byte[] without extensions.void
mergeFrom
(T message, Reader reader, ExtensionRegistryLite extensionRegistry) Reads fields from the givenReader
and merges them into the message.void
Merge values fromother
intomessage
.private <UT,
UB, ET extends FieldSet.FieldDescriptorLite<ET>>
voidmergeFromHelper
(UnknownFieldSchema<UT, UB> unknownFieldSchema, ExtensionSchema<ET> extensionSchema, T message, Reader reader, ExtensionRegistryLite extensionRegistry) A helper method for wildcard capture ofunknownFieldSchema
.Creates a new instance of the message class.(package private) static <T> MessageSetSchema
<T> newSchema
(UnknownFieldSchema<?, ?> unknownFieldSchema, ExtensionSchema<?> extensionSchema, MessageLite defaultInstance) private <UT,
UB, ET extends FieldSet.FieldDescriptorLite<ET>>
booleanparseMessageSetItemOrUnknownField
(Reader reader, ExtensionRegistryLite extensionRegistry, ExtensionSchema<ET> extensionSchema, FieldSet<ET> extensions, UnknownFieldSchema<UT, UB> unknownFieldSchema, UB unknownFields) void
Writes the given message to the targetWriter
.private <UT,
UB> void writeUnknownFieldsHelper
(UnknownFieldSchema<UT, UB> unknownFieldSchema, T message, Writer writer) A helper method for wildcard capture ofunknownFieldSchema
.
-
Field Details
-
defaultInstance
-
unknownFieldSchema
-
hasExtensions
private final boolean hasExtensions -
extensionSchema
-
-
Constructor Details
-
MessageSetSchema
private MessageSetSchema(UnknownFieldSchema<?, ?> unknownFieldSchema, ExtensionSchema<?> extensionSchema, MessageLite defaultInstance)
-
-
Method Details
-
newSchema
static <T> MessageSetSchema<T> newSchema(UnknownFieldSchema<?, ?> unknownFieldSchema, ExtensionSchema<?> extensionSchema, MessageLite defaultInstance) -
newInstance
Description copied from interface:Schema
Creates a new instance of the message class.- Specified by:
newInstance
in interfaceSchema<T>
-
equals
Description copied from interface:Schema
Determine of the two messages are equal. -
hashCode
Description copied from interface:Schema
Compute a hashCode for the message. -
mergeFrom
Description copied from interface:Schema
Merge values fromother
intomessage
. This method doesn't make the message immutable. To make the message immutable after merging, useSchema.makeImmutable(T)
. -
writeTo
Description copied from interface:Schema
Writes the given message to the targetWriter
.- Specified by:
writeTo
in interfaceSchema<T>
- Throws:
IOException
-
writeUnknownFieldsHelper
private <UT,UB> void writeUnknownFieldsHelper(UnknownFieldSchema<UT, UB> unknownFieldSchema, T message, Writer writer) throws IOExceptionA helper method for wildcard capture ofunknownFieldSchema
. See: https://docs.oracle.com/javase/tutorial/java/generics/capture.html- Throws:
IOException
-
mergeFrom
public void mergeFrom(T message, byte[] data, int position, int limit, ArrayDecoders.Registers registers) throws IOException Description copied from interface:Schema
Like the above but parses from a byte[] without extensions. Entry point of fast path. Note that this method may throw IndexOutOfBoundsException if the input data is not valid protobuf wire format. Protobuf public API methods should catch and convert that exception to InvalidProtocolBufferException.- Specified by:
mergeFrom
in interfaceSchema<T>
- Throws:
IOException
-
mergeFrom
public void mergeFrom(T message, Reader reader, ExtensionRegistryLite extensionRegistry) throws IOException Description copied from interface:Schema
Reads fields from the givenReader
and merges them into the message. It doesn't make the message immutable after parsing is done. To make the message immutable, useSchema.makeImmutable(T)
.- Specified by:
mergeFrom
in interfaceSchema<T>
- Throws:
IOException
-
mergeFromHelper
private <UT,UB, void mergeFromHelperET extends FieldSet.FieldDescriptorLite<ET>> (UnknownFieldSchema<UT, UB> unknownFieldSchema, ExtensionSchema<ET> extensionSchema, T message, Reader reader, ExtensionRegistryLite extensionRegistry) throws IOExceptionA helper method for wildcard capture ofunknownFieldSchema
. See: https://docs.oracle.com/javase/tutorial/java/generics/capture.html- Throws:
IOException
-
makeImmutable
Description copied from interface:Schema
Marks repeated/map/extension/unknown fields as immutable.- Specified by:
makeImmutable
in interfaceSchema<T>
-
parseMessageSetItemOrUnknownField
private <UT,UB, boolean parseMessageSetItemOrUnknownFieldET extends FieldSet.FieldDescriptorLite<ET>> (Reader reader, ExtensionRegistryLite extensionRegistry, ExtensionSchema<ET> extensionSchema, FieldSet<ET> extensions, UnknownFieldSchema<UT, UB> unknownFieldSchema, UB unknownFields) throws IOException- Throws:
IOException
-
isInitialized
Description copied from interface:Schema
Checks whether all required fields are set.- Specified by:
isInitialized
in interfaceSchema<T>
-
getSerializedSize
Description copied from interface:Schema
Compute the serialized size of the message.- Specified by:
getSerializedSize
in interfaceSchema<T>
-
getUnknownFieldsSerializedSize
-