Top Description Inners Fields Constructors Methods
com.google.protobuf

public abstract Class GeneratedMessage

extends AbstractMessage
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Known Direct Subclasses
com.google.protobuf.GeneratedMessage.ExtendableMessage
Imports
com.google.protobuf.Descriptors.Descriptor, .Descriptors.EnumDescriptor, .Descriptors.EnumValueDescriptor, .Descriptors.FieldDescriptor, .Descriptors.FileDescriptor, .Descriptors.OneofDescriptor, java.io.IOException, .InputStream, .ObjectStreamException, .Serializable, java.lang.reflect.InvocationTargetException, .Method, java.util.ArrayList, .Collections, .Iterator, .List, .Map, .TreeMap

All generated protocol message classes extend this class. This class implements most of the Message and Builder interfaces using Java reflection. Users can ignore this class and pretend that generated messages implement the Message interface directly.
Author
[email protected] Kenton Varda

Nested and Inner Type Summary

Modifier and TypeClass and Description
public abstract static class
GeneratedMessage.Builder<BuilderType extends GeneratedMessage.Builder<BuilderType>>

protected static interface
GeneratedMessage.BuilderParent

TODO(xiaofeng): remove this after b/29368482 is fixed.

private abstract static class
public abstract static class
GeneratedMessage.ExtendableBuilder<MessageType extends GeneratedMessage.ExtendableMessage<MessageType extends GeneratedMessage.ExtendableMessage>, BuilderType extends GeneratedMessage.ExtendableBuilder<MessageType, BuilderType>>

Generated message builders for message types that contain extension ranges subclass this.

public abstract static class
GeneratedMessage.ExtendableMessage<MessageType extends GeneratedMessage.ExtendableMessage>

Generated message classes for message types that contain extension ranges subclass this.

public static interface
pack-priv static interface
GeneratedMessage.ExtensionDescriptorRetriever

Gets the descriptor for an extension.

public static class
GeneratedMessage.FieldAccessorTable

Users should ignore this class.

public static class
GeneratedMessage.GeneratedExtension<ContainingType extends Message, Type>

Type used to represent generated extensions.

Field Summary

Modifier and TypeField and Description
protected static boolean
private static final long
protected UnknownFieldSet
unknownFields

For use by generated code only.

Inherited from com.google.protobuf.AbstractMessage:
memoizedSize

Constructor Summary

AccessConstructor and Description
protected
protected

Method Summary

Modifier and TypeMethod and Description
private static <MessageType extends GeneratedMessage.ExtendableMessage<MessageType>, T> Extension<MessageType, T>
checkNotLite(ExtensionLite<MessageType, T> extension)

Checks that the Extension is non-Lite and returns it as a GeneratedExtension.

protected static int
computeStringSize(final int fieldNumber, final Object value)

protected static int
pack-priv static void
public Map<Descriptors.FieldDescriptor, Object>
getAllFields()

Implements com.google.protobuf.MessageOrBuilder.getAllFields.

Returns a collection of all the fields in this message which are set and their corresponding values.
private Map<Descriptors.FieldDescriptor, Object>
getAllFieldsMutable(boolean
whether to generate ByteString for string fields
getBytesForString
)

Internal helper to return a modifiable map containing all the fields.

pack-priv Map<Descriptors.FieldDescriptor, Object>
getAllFieldsRaw()

Returns a collection of all the fields in this message which are set and their corresponding values.

public Descriptors.Descriptor
getDescriptorForType()

Implements com.google.protobuf.MessageOrBuilder.getDescriptorForType.

Get the message's type's descriptor.
public Object
getField(final Descriptors.FieldDescriptor field)

Implements com.google.protobuf.MessageOrBuilder.getField.

Obtains the value of the given field, or the default value if it is not set.
pack-priv Object
getFieldRaw(final Descriptors.FieldDescriptor field)

Obtains the value of the given field, or the default value if it is not set.

private static Method
getMethodOrDie(final Class<T> clazz, final String name, final Class<T>... params)

Calls Class.getMethod and throws a RuntimeException if it fails.

public Descriptors.FieldDescriptor
getOneofFieldDescriptor(final Descriptors.OneofDescriptor oneof)

Overrides com.google.protobuf.AbstractMessage.getOneofFieldDescriptor.

Implements com.google.protobuf.MessageOrBuilder.getOneofFieldDescriptor.

TODO(jieluo): Clear it when all subclasses have implemented this method.
public Parser<? extends GeneratedMessage>
getParserForType()

Implements com.google.protobuf.Message.getParserForType, com.google.protobuf.MessageLite.getParserForType.

Gets the parser for a message of the same type as this message.
public Object
getRepeatedField(final Descriptors.FieldDescriptor field, final int index)

Implements com.google.protobuf.MessageOrBuilder.getRepeatedField.

Gets an element of a repeated field.
public int
getRepeatedFieldCount(final Descriptors.FieldDescriptor field)

Implements com.google.protobuf.MessageOrBuilder.getRepeatedFieldCount.

Gets the number of elements of a repeated field.
public int
getSerializedSize()

Overrides com.google.protobuf.AbstractMessage.getSerializedSize.

Implements com.google.protobuf.MessageLite.getSerializedSize.

Get the number of bytes required to encode this message.
public UnknownFieldSet
public boolean
hasField(final Descriptors.FieldDescriptor field)

Implements com.google.protobuf.MessageOrBuilder.hasField.

Returns true if the given field is set.
public boolean
hasOneof(final Descriptors.OneofDescriptor oneof)

Overrides com.google.protobuf.AbstractMessage.hasOneof.

Implements com.google.protobuf.MessageOrBuilder.hasOneof.

TODO(jieluo): Clear it when all subclasses have implemented this method.
protected abstract GeneratedMessage.FieldAccessorTable
internalGetFieldAccessorTable()

Get the FieldAccessorTable for this type.

protected MapField<K, V>
internalGetMapField(int fieldNumber)

Gets the map field with the given field number.

private static Object
invokeOrDie(final Method method, final Object object, final Object... params)

Calls invoke and throws a RuntimeException if it fails.

public boolean
isInitialized()

Overrides com.google.protobuf.AbstractMessage.isInitialized.

Implements com.google.protobuf.MessageLiteOrBuilder.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.

protected abstract Message.Builder
newBuilderForType(GeneratedMessage.BuilderParent parent)

TODO(xiaofeng): remove this together with GeneratedMessage.BuilderParent.

protected Message.Builder
public static <ContainingType extends Message, Type> GeneratedMessage.GeneratedExtension<ContainingType, Type>
newFileScopedGeneratedExtension(final Class<T> singularType, final Message defaultInstance)

For use by generated code only.

public static <ContainingType extends Message, Type> GeneratedMessage.GeneratedExtension<ContainingType, Type>
newFileScopedGeneratedExtension(final Class<T> singularType, final Message defaultInstance, final String descriptorOuterClass, final String extensionName)

Used in proto1 generated code only.

public static <ContainingType extends Message, Type> GeneratedMessage.GeneratedExtension<ContainingType, Type>
newMessageScopedGeneratedExtension(final Message scope, final int descriptorIndex, final Class<T> singularType, final Message defaultInstance)

For use by generated code only.

public static <ContainingType extends Message, Type> GeneratedMessage.GeneratedExtension<ContainingType, Type>
newMessageScopedGeneratedExtension(final Message scope, final String name, final Class<T> singularType, final Message defaultInstance)

Used in proto1 generated code only.

protected static <M extends Message> M
protected static <M extends Message> M
protected boolean

Returns:

true unless the tag is an end-group tag.
parseUnknownField
(CodedInputStream input, UnknownFieldSet.Builder unknownFields, ExtensionRegistryLite extensionRegistry, int tag)

Called by subclasses to parse an unknown field.

protected static <M extends Message> M
protected static <M extends Message> M
protected static <M extends Message> M
protected static <M extends Message> M
protected Object

Returns:

a SerializedForm of this message
writeReplace
()

Replaces this object in the output stream with a serialized form.

protected static void
writeString(CodedOutputStream output, final int fieldNumber, final Object value)

protected static void
public void
writeTo(final CodedOutputStream output)

Overrides com.google.protobuf.AbstractMessage.writeTo.

Implements com.google.protobuf.MessageLite.writeTo.

Serializes the message and writes it to output.
Inherited from com.google.protobuf.AbstractMessage:
compareFieldsequalsfindInitializationErrorsgetInitializationErrorStringgetMemoizedSerializedSizehashBooleanhashCodehashEnumhashEnumListhashFieldshashLongnewUninitializedMessageExceptionsetMemoizedSerializedSizetoString