public abstract class GeneratedMessageV3 extends AbstractMessage implements java.io.Serializable
| Modifier and Type | Class and Description |
|---|---|
static class |
GeneratedMessageV3.Builder<BuilderType extends GeneratedMessageV3.Builder<BuilderType>> |
protected static interface |
GeneratedMessageV3.BuilderParent
TODO(xiaofeng): remove this after b/29368482 is fixed.
|
static class |
GeneratedMessageV3.ExtendableBuilder<MessageType extends GeneratedMessageV3.ExtendableMessage,BuilderType extends GeneratedMessageV3.ExtendableBuilder<MessageType,BuilderType>>
Generated message builders for message types that contain extension ranges
subclass this.
|
static class |
GeneratedMessageV3.ExtendableMessage<MessageType extends GeneratedMessageV3.ExtendableMessage>
Generated message classes for message types that contain extension ranges
subclass this.
|
static interface |
GeneratedMessageV3.ExtendableMessageOrBuilder<MessageType extends GeneratedMessageV3.ExtendableMessage> |
(package private) static interface |
GeneratedMessageV3.ExtensionDescriptorRetriever
Gets the descriptor for an extension.
|
static class |
GeneratedMessageV3.FieldAccessorTable
Users should ignore this class.
|
| Modifier and Type | Field and Description |
|---|---|
protected static boolean |
alwaysUseFieldBuilders
For testing.
|
private static long |
serialVersionUID |
protected UnknownFieldSet |
unknownFields
For use by generated code only.
|
memoizedSizememoizedHashCode| Modifier | Constructor and Description |
|---|---|
protected |
GeneratedMessageV3() |
protected |
GeneratedMessageV3(GeneratedMessageV3.Builder<?> builder) |
| Modifier and Type | Method and Description |
|---|---|
protected static boolean |
canUseUnsafe() |
private static <MessageType extends GeneratedMessageV3.ExtendableMessage<MessageType>,T> |
checkNotLite(ExtensionLite<MessageType,T> extension)
Checks that the
Extension is non-Lite and returns it as a
GeneratedMessage.GeneratedExtension. |
protected static int |
computeStringSize(int fieldNumber,
java.lang.Object value) |
protected static int |
computeStringSizeNoTag(java.lang.Object value) |
(package private) static void |
enableAlwaysUseFieldBuildersForTesting()
For testing.
|
java.util.Map<Descriptors.FieldDescriptor,java.lang.Object> |
getAllFields()
Returns a collection of all the fields in this message which are set
and their corresponding values.
|
private java.util.Map<Descriptors.FieldDescriptor,java.lang.Object> |
getAllFieldsMutable(boolean getBytesForString)
Internal helper to return a modifiable map containing all the fields.
|
(package private) java.util.Map<Descriptors.FieldDescriptor,java.lang.Object> |
getAllFieldsRaw()
Returns a collection of all the fields in this message which are set
and their corresponding values.
|
Descriptors.Descriptor |
getDescriptorForType()
Get the message's type's descriptor.
|
java.lang.Object |
getField(Descriptors.FieldDescriptor field)
Obtains the value of the given field, or the default value if it is
not set.
|
(package private) java.lang.Object |
getFieldRaw(Descriptors.FieldDescriptor field)
Obtains the value of the given field, or the default value if it is
not set.
|
private static java.lang.reflect.Method |
getMethodOrDie(java.lang.Class clazz,
java.lang.String name,
java.lang.Class... params)
Calls Class.getMethod and throws a RuntimeException if it fails.
|
Descriptors.FieldDescriptor |
getOneofFieldDescriptor(Descriptors.OneofDescriptor oneof)
TODO(jieluo): Clear it when all subclasses have implemented this method.
|
Parser<? extends GeneratedMessageV3> |
getParserForType()
Gets the parser for a message of the same type as this message.
|
java.lang.Object |
getRepeatedField(Descriptors.FieldDescriptor field,
int index)
Gets an element of a repeated field.
|
int |
getRepeatedFieldCount(Descriptors.FieldDescriptor field)
Gets the number of elements of a repeated field.
|
int |
getSerializedSize()
Get the number of bytes required to encode this message.
|
UnknownFieldSet |
getUnknownFields()
Get the
UnknownFieldSet for this message. |
boolean |
hasField(Descriptors.FieldDescriptor field)
Returns true if the given field is set.
|
boolean |
hasOneof(Descriptors.OneofDescriptor oneof)
TODO(jieluo): Clear it when all subclasses have implemented this method.
|
protected abstract GeneratedMessageV3.FieldAccessorTable |
internalGetFieldAccessorTable()
Get the FieldAccessorTable for this type.
|
protected MapField |
internalGetMapField(int fieldNumber)
Gets the map field with the given field number.
|
private static java.lang.Object |
invokeOrDie(java.lang.reflect.Method method,
java.lang.Object object,
java.lang.Object... params)
Calls invoke and throws a RuntimeException if it fails.
|
boolean |
isInitialized()
Returns true if all required fields in the message and all embedded
messages are set, false otherwise.
|
protected void |
makeExtensionsImmutable()
Used by parsing constructors in generated classes.
|
private static <V> void |
maybeSerializeBooleanEntryTo(CodedOutputStream out,
java.util.Map<java.lang.Boolean,V> m,
MapEntry<java.lang.Boolean,V> defaultEntry,
int fieldNumber,
boolean key) |
protected Message.Builder |
newBuilderForType(AbstractMessage.BuilderParent parent)
Create a nested builder.
|
protected abstract Message.Builder |
newBuilderForType(GeneratedMessageV3.BuilderParent parent)
TODO(xiaofeng): remove this together with GeneratedMessageV3.BuilderParent.
|
protected static <M extends Message> |
parseDelimitedWithIOException(Parser<M> parser,
java.io.InputStream input) |
protected static <M extends Message> |
parseDelimitedWithIOException(Parser<M> parser,
java.io.InputStream input,
ExtensionRegistryLite extensions) |
protected boolean |
parseUnknownField(CodedInputStream input,
UnknownFieldSet.Builder unknownFields,
ExtensionRegistryLite extensionRegistry,
int tag)
Called by subclasses to parse an unknown field.
|
protected boolean |
parseUnknownFieldProto3(CodedInputStream input,
UnknownFieldSet.Builder unknownFields,
ExtensionRegistryLite extensionRegistry,
int tag) |
protected static <M extends Message> |
parseWithIOException(Parser<M> parser,
CodedInputStream input) |
protected static <M extends Message> |
parseWithIOException(Parser<M> parser,
CodedInputStream input,
ExtensionRegistryLite extensions) |
protected static <M extends Message> |
parseWithIOException(Parser<M> parser,
java.io.InputStream input) |
protected static <M extends Message> |
parseWithIOException(Parser<M> parser,
java.io.InputStream input,
ExtensionRegistryLite extensions) |
protected static <V> void |
serializeBooleanMapTo(CodedOutputStream out,
MapField<java.lang.Boolean,V> field,
MapEntry<java.lang.Boolean,V> defaultEntry,
int fieldNumber) |
protected static <V> void |
serializeIntegerMapTo(CodedOutputStream out,
MapField<java.lang.Integer,V> field,
MapEntry<java.lang.Integer,V> defaultEntry,
int fieldNumber) |
protected static <V> void |
serializeLongMapTo(CodedOutputStream out,
MapField<java.lang.Long,V> field,
MapEntry<java.lang.Long,V> defaultEntry,
int fieldNumber) |
private static <K,V> void |
serializeMapTo(CodedOutputStream out,
java.util.Map<K,V> m,
MapEntry<K,V> defaultEntry,
int fieldNumber)
Serialize the map using the iteration order.
|
protected static <V> void |
serializeStringMapTo(CodedOutputStream out,
MapField<java.lang.String,V> field,
MapEntry<java.lang.String,V> defaultEntry,
int fieldNumber) |
protected java.lang.Object |
writeReplace()
Replaces this object in the output stream with a serialized form.
|
protected static void |
writeString(CodedOutputStream output,
int fieldNumber,
java.lang.Object value) |
protected static void |
writeStringNoTag(CodedOutputStream output,
java.lang.Object value) |
void |
writeTo(CodedOutputStream output)
Serializes the message and writes it to
output. |
compareFields, equals, findInitializationErrors, getInitializationErrorString, getMemoizedSerializedSize, hashBoolean, hashCode, hashEnum, hashEnumList, hashFields, hashLong, newUninitializedMessageException, setMemoizedSerializedSize, toStringaddAll, addAll, checkByteStringIsUtf8, toByteArray, toByteString, writeDelimitedTo, writeToclone, finalize, getClass, notify, notifyAll, wait, wait, waitnewBuilderForType, toBuildertoByteArray, toByteString, writeDelimitedTo, writeTogetDefaultInstanceForTypeprivate static final long serialVersionUID
protected static boolean alwaysUseFieldBuilders
protected UnknownFieldSet unknownFields
protected GeneratedMessageV3()
protected GeneratedMessageV3(GeneratedMessageV3.Builder<?> builder)
public Parser<? extends GeneratedMessageV3> getParserForType()
MessageLitegetParserForType in interface MessagegetParserForType in interface MessageLitestatic void enableAlwaysUseFieldBuildersForTesting()
RepeatedFieldBuilder and SingleFieldBuilder.protected abstract GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable()
public Descriptors.Descriptor getDescriptorForType()
MessageOrBuildergetDescriptor() method of generated message classes in that
this method is an abstract method of the Message interface
whereas getDescriptor() is a static method of a specific class.
They return the same thing.getDescriptorForType in interface MessageOrBuilderprivate java.util.Map<Descriptors.FieldDescriptor,java.lang.Object> getAllFieldsMutable(boolean getBytesForString)
getAllFields().getBytesForString - whether to generate ByteString for string fieldspublic boolean isInitialized()
MessageLiteOrBuilderisInitialized in interface MessageLiteOrBuilderisInitialized in class AbstractMessagepublic java.util.Map<Descriptors.FieldDescriptor,java.lang.Object> getAllFields()
MessageOrBuilderMessageOrBuilder.getField(Descriptors.FieldDescriptor) for each field. The map
is guaranteed to be a sorted map, so iterating over it will return fields
in order by field number.
getAllFields in interface MessageOrBuilderjava.util.Map<Descriptors.FieldDescriptor,java.lang.Object> getAllFieldsRaw()
getFieldRaw(Descriptors.FieldDescriptor) for each field. The map
is guaranteed to be a sorted map, so iterating over it will return fields
in order by field number.public boolean hasOneof(Descriptors.OneofDescriptor oneof)
AbstractMessagehasOneof in interface MessageOrBuilderhasOneof in class AbstractMessagepublic Descriptors.FieldDescriptor getOneofFieldDescriptor(Descriptors.OneofDescriptor oneof)
AbstractMessagegetOneofFieldDescriptor in interface MessageOrBuildergetOneofFieldDescriptor in class AbstractMessagepublic boolean hasField(Descriptors.FieldDescriptor field)
MessageOrBuilderhasField in interface MessageOrBuilderpublic java.lang.Object getField(Descriptors.FieldDescriptor field)
MessageOrBuildergetField in interface MessageOrBuilderjava.lang.Object getFieldRaw(Descriptors.FieldDescriptor field)
public int getRepeatedFieldCount(Descriptors.FieldDescriptor field)
MessageOrBuildergetRepeatedFieldCount in interface MessageOrBuilderpublic java.lang.Object getRepeatedField(Descriptors.FieldDescriptor field, int index)
MessageOrBuildergetRepeatedField in interface MessageOrBuilderpublic UnknownFieldSet getUnknownFields()
MessageOrBuilderUnknownFieldSet for this message.getUnknownFields in interface MessageOrBuilderprotected boolean parseUnknownField(CodedInputStream input, UnknownFieldSet.Builder unknownFields, ExtensionRegistryLite extensionRegistry, int tag) throws java.io.IOException
true unless the tag is an end-group tag.java.io.IOExceptionprotected boolean parseUnknownFieldProto3(CodedInputStream input, UnknownFieldSet.Builder unknownFields, ExtensionRegistryLite extensionRegistry, int tag) throws java.io.IOException
java.io.IOExceptionprotected static <M extends Message> M parseWithIOException(Parser<M> parser, java.io.InputStream input) throws java.io.IOException
java.io.IOExceptionprotected static <M extends Message> M parseWithIOException(Parser<M> parser, java.io.InputStream input, ExtensionRegistryLite extensions) throws java.io.IOException
java.io.IOExceptionprotected static <M extends Message> M parseWithIOException(Parser<M> parser, CodedInputStream input) throws java.io.IOException
java.io.IOExceptionprotected static <M extends Message> M parseWithIOException(Parser<M> parser, CodedInputStream input, ExtensionRegistryLite extensions) throws java.io.IOException
java.io.IOExceptionprotected static <M extends Message> M parseDelimitedWithIOException(Parser<M> parser, java.io.InputStream input) throws java.io.IOException
java.io.IOExceptionprotected static <M extends Message> M parseDelimitedWithIOException(Parser<M> parser, java.io.InputStream input, ExtensionRegistryLite extensions) throws java.io.IOException
java.io.IOExceptionprotected static boolean canUseUnsafe()
public void writeTo(CodedOutputStream output) throws java.io.IOException
MessageLiteoutput. This does not
flush or close the stream.writeTo in interface MessageLitewriteTo in class AbstractMessagejava.io.IOExceptionpublic int getSerializedSize()
MessageLitegetSerializedSize in interface MessageLitegetSerializedSize in class AbstractMessageprotected void makeExtensionsImmutable()
protected abstract Message.Builder newBuilderForType(GeneratedMessageV3.BuilderParent parent)
protected Message.Builder newBuilderForType(AbstractMessage.BuilderParent parent)
AbstractMessagenewBuilderForType in class AbstractMessageprivate static java.lang.reflect.Method getMethodOrDie(java.lang.Class clazz,
java.lang.String name,
java.lang.Class... params)
private static java.lang.Object invokeOrDie(java.lang.reflect.Method method,
java.lang.Object object,
java.lang.Object... params)
protected MapField internalGetMapField(int fieldNumber)
protected java.lang.Object writeReplace()
throws java.io.ObjectStreamException
return super.writeReplace();java.io.ObjectStreamExceptionprivate static <MessageType extends GeneratedMessageV3.ExtendableMessage<MessageType>,T> Extension<MessageType,T> checkNotLite(ExtensionLite<MessageType,T> extension)
Extension is non-Lite and returns it as a
GeneratedMessage.GeneratedExtension.protected static int computeStringSize(int fieldNumber,
java.lang.Object value)
protected static int computeStringSizeNoTag(java.lang.Object value)
protected static void writeString(CodedOutputStream output, int fieldNumber, java.lang.Object value) throws java.io.IOException
java.io.IOExceptionprotected static void writeStringNoTag(CodedOutputStream output, java.lang.Object value) throws java.io.IOException
java.io.IOExceptionprotected static <V> void serializeIntegerMapTo(CodedOutputStream out, MapField<java.lang.Integer,V> field, MapEntry<java.lang.Integer,V> defaultEntry, int fieldNumber) throws java.io.IOException
java.io.IOExceptionprotected static <V> void serializeLongMapTo(CodedOutputStream out, MapField<java.lang.Long,V> field, MapEntry<java.lang.Long,V> defaultEntry, int fieldNumber) throws java.io.IOException
java.io.IOExceptionprotected static <V> void serializeStringMapTo(CodedOutputStream out, MapField<java.lang.String,V> field, MapEntry<java.lang.String,V> defaultEntry, int fieldNumber) throws java.io.IOException
java.io.IOExceptionprotected static <V> void serializeBooleanMapTo(CodedOutputStream out, MapField<java.lang.Boolean,V> field, MapEntry<java.lang.Boolean,V> defaultEntry, int fieldNumber) throws java.io.IOException
java.io.IOExceptionprivate static <V> void maybeSerializeBooleanEntryTo(CodedOutputStream out, java.util.Map<java.lang.Boolean,V> m, MapEntry<java.lang.Boolean,V> defaultEntry, int fieldNumber, boolean key) throws java.io.IOException
java.io.IOExceptionprivate static <K,V> void serializeMapTo(CodedOutputStream out, java.util.Map<K,V> m, MapEntry<K,V> defaultEntry, int fieldNumber) throws java.io.IOException
java.io.IOException