public abstract class GeneratedMessage extends AbstractMessage implements java.io.Serializable
Modifier and Type | Class and Description |
---|---|
static class |
GeneratedMessage.Builder<BuilderType extends GeneratedMessage.Builder> |
protected static interface |
GeneratedMessage.BuilderParent
Interface for the parent of a Builder that allows the builder to
communicate invalidations back to the parent for use when using nested
builders.
|
static class |
GeneratedMessage.ExtendableBuilder<MessageType extends GeneratedMessage.ExtendableMessage,BuilderType extends GeneratedMessage.ExtendableBuilder>
Generated message builders for message types that contain extension ranges
subclass this.
|
static class |
GeneratedMessage.ExtendableMessage<MessageType extends GeneratedMessage.ExtendableMessage>
Generated message classes for message types that contain extension ranges
subclass this.
|
static interface |
GeneratedMessage.ExtendableMessageOrBuilder<MessageType extends GeneratedMessage.ExtendableMessage> |
static class |
GeneratedMessage.FieldAccessorTable
Users should ignore this class.
|
static class |
GeneratedMessage.GeneratedExtension<ContainingType extends Message,Type>
Type used to represent generated extensions.
|
Modifier and Type | Field and Description |
---|---|
protected static boolean |
alwaysUseFieldBuilders
For testing.
|
protected UnknownFieldSet |
unknownFields
For use by generated code only.
|
memoizedSize
memoizedHashCode
Modifier | Constructor and Description |
---|---|
protected |
GeneratedMessage() |
protected |
GeneratedMessage(GeneratedMessage.Builder<?> builder) |
Modifier and Type | Method and Description |
---|---|
protected static int |
computeStringSize(int fieldNumber,
java.lang.Object value) |
protected static int |
computeStringSizeNoTag(java.lang.Object value) |
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.
|
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.
|
Descriptors.FieldDescriptor |
getOneofFieldDescriptor(Descriptors.OneofDescriptor oneof)
|
Parser<? extends GeneratedMessage> |
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)
|
protected abstract GeneratedMessage.FieldAccessorTable |
internalGetFieldAccessorTable()
Get the FieldAccessorTable for this type.
|
protected MapField |
internalGetMapField(int fieldNumber)
Gets the map field with the given field number.
|
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.
|
protected abstract Message.Builder |
newBuilderForType(GeneratedMessage.BuilderParent parent) |
static <ContainingType extends Message,Type> |
newFileScopedGeneratedExtension(java.lang.Class singularType,
Message defaultInstance)
For use by generated code only.
|
static <ContainingType extends Message,Type> |
newFileScopedGeneratedExtension(java.lang.Class singularType,
Message defaultInstance,
java.lang.String descriptorOuterClass,
java.lang.String extensionName)
Used in proto1 generated code only.
|
static <ContainingType extends Message,Type> |
newMessageScopedGeneratedExtension(Message scope,
int descriptorIndex,
java.lang.Class singularType,
Message defaultInstance)
For use by generated code only.
|
static <ContainingType extends Message,Type> |
newMessageScopedGeneratedExtension(Message scope,
java.lang.String name,
java.lang.Class singularType,
Message defaultInstance)
Used in proto1 generated code only.
|
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 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 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 . |
equals, findInitializationErrors, getInitializationErrorString, hashCode, hashFields, toString
addAll, checkByteStringIsUtf8, toByteArray, toByteString, writeDelimitedTo, writeTo
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
newBuilderForType, toBuilder
toByteArray, toByteString, writeDelimitedTo, writeTo
getDefaultInstanceForType
protected static boolean alwaysUseFieldBuilders
protected UnknownFieldSet unknownFields
protected GeneratedMessage()
protected GeneratedMessage(GeneratedMessage.Builder<?> builder)
public Parser<? extends GeneratedMessage> getParserForType()
MessageLite
getParserForType
in interface Message
getParserForType
in interface MessageLite
protected abstract GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable()
public Descriptors.Descriptor getDescriptorForType()
MessageOrBuilder
getDescriptor()
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 MessageOrBuilder
public boolean isInitialized()
MessageLiteOrBuilder
isInitialized
in interface MessageLiteOrBuilder
isInitialized
in class AbstractMessage
public java.util.Map<Descriptors.FieldDescriptor,java.lang.Object> getAllFields()
MessageOrBuilder
MessageOrBuilder.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 MessageOrBuilder
public boolean hasOneof(Descriptors.OneofDescriptor oneof)
AbstractMessage
hasOneof
in interface MessageOrBuilder
hasOneof
in class AbstractMessage
public Descriptors.FieldDescriptor getOneofFieldDescriptor(Descriptors.OneofDescriptor oneof)
AbstractMessage
getOneofFieldDescriptor
in interface MessageOrBuilder
getOneofFieldDescriptor
in class AbstractMessage
public boolean hasField(Descriptors.FieldDescriptor field)
MessageOrBuilder
hasField
in interface MessageOrBuilder
public java.lang.Object getField(Descriptors.FieldDescriptor field)
MessageOrBuilder
getField
in interface MessageOrBuilder
public int getRepeatedFieldCount(Descriptors.FieldDescriptor field)
MessageOrBuilder
getRepeatedFieldCount
in interface MessageOrBuilder
public java.lang.Object getRepeatedField(Descriptors.FieldDescriptor field, int index)
MessageOrBuilder
getRepeatedField
in interface MessageOrBuilder
public UnknownFieldSet getUnknownFields()
MessageOrBuilder
UnknownFieldSet
for this message.getUnknownFields
in interface MessageOrBuilder
protected 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.IOException
protected static <M extends Message> M parseWithIOException(Parser<M> parser, java.io.InputStream input) throws java.io.IOException
java.io.IOException
protected static <M extends Message> M parseWithIOException(Parser<M> parser, java.io.InputStream input, ExtensionRegistryLite extensions) throws java.io.IOException
java.io.IOException
protected static <M extends Message> M parseWithIOException(Parser<M> parser, CodedInputStream input) throws java.io.IOException
java.io.IOException
protected static <M extends Message> M parseWithIOException(Parser<M> parser, CodedInputStream input, ExtensionRegistryLite extensions) throws java.io.IOException
java.io.IOException
protected static <M extends Message> M parseDelimitedWithIOException(Parser<M> parser, java.io.InputStream input) throws java.io.IOException
java.io.IOException
protected static <M extends Message> M parseDelimitedWithIOException(Parser<M> parser, java.io.InputStream input, ExtensionRegistryLite extensions) throws java.io.IOException
java.io.IOException
public void writeTo(CodedOutputStream output) throws java.io.IOException
MessageLite
output
. This does not
flush or close the stream.writeTo
in interface MessageLite
writeTo
in class AbstractMessage
java.io.IOException
public int getSerializedSize()
MessageLite
getSerializedSize
in interface MessageLite
getSerializedSize
in class AbstractMessage
protected void makeExtensionsImmutable()
protected abstract Message.Builder newBuilderForType(GeneratedMessage.BuilderParent parent)
public static <ContainingType extends Message,Type> GeneratedMessage.GeneratedExtension<ContainingType,Type> newMessageScopedGeneratedExtension(Message scope, int descriptorIndex, java.lang.Class singularType, Message defaultInstance)
public static <ContainingType extends Message,Type> GeneratedMessage.GeneratedExtension<ContainingType,Type> newFileScopedGeneratedExtension(java.lang.Class singularType, Message defaultInstance)
public static <ContainingType extends Message,Type> GeneratedMessage.GeneratedExtension<ContainingType,Type> newMessageScopedGeneratedExtension(Message scope, java.lang.String name, java.lang.Class singularType, Message defaultInstance)
public static <ContainingType extends Message,Type> GeneratedMessage.GeneratedExtension<ContainingType,Type> newFileScopedGeneratedExtension(java.lang.Class singularType, Message defaultInstance, java.lang.String descriptorOuterClass, java.lang.String extensionName)
protected MapField internalGetMapField(int fieldNumber)
protected java.lang.Object writeReplace() throws java.io.ObjectStreamException
return super.writeReplace();
java.io.ObjectStreamException
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.IOException
protected static void writeStringNoTag(CodedOutputStream output, java.lang.Object value) throws java.io.IOException
java.io.IOException