Class GeneratedMessageV3 (3.19.4)

  public 
  
 abstract 
  
 class 
 GeneratedMessageV3 
  
 extends 
  
 AbstractMessage 
  
 implements 
  
 Serializable 
 

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.

Implements

Serializable

Static Fields

alwaysUseFieldBuilders

  protected 
  
 static 
  
 boolean 
  
 alwaysUseFieldBuilders 
 

For testing. Allows a test to disable the optimization that avoids using field builders for nested messages until they are requested. By disabling this optimization, existing tests can be reused to test the field builders.

Field Value
Type
Description

Static Methods

<M>parseDelimitedWithIOException(Parser<M> parser, InputStream input)

  protected 
  
 static 
  
 M 
  
< M>parseDelimitedWithIOException 
 ( 
 Parser<M> 
  
 parser 
 , 
  
 InputStream 
  
 input 
 ) 
 
Parameters
Name
Description
parser
Parser < M >
input
Returns
Type
Description
M
Exceptions
Type
Description

<M>parseDelimitedWithIOException(Parser<M> parser, InputStream input, ExtensionRegistryLite extensions)

  protected 
  
 static 
  
 M 
  
< M>parseDelimitedWithIOException 
 ( 
 Parser<M> 
  
 parser 
 , 
  
 InputStream 
  
 input 
 , 
  
 ExtensionRegistryLite 
  
 extensions 
 ) 
 
Parameters
Name
Description
parser
Parser < M >
input
Returns
Type
Description
M
Exceptions
Type
Description

<M>parseWithIOException(Parser<M> parser, CodedInputStream input)

  protected 
  
 static 
  
 M 
  
< M>parseWithIOException 
 ( 
 Parser<M> 
  
 parser 
 , 
  
 CodedInputStream 
  
 input 
 ) 
 
Parameters
Name
Description
parser
Parser < M >
Returns
Type
Description
M
Exceptions
Type
Description

<M>parseWithIOException(Parser<M> parser, CodedInputStream input, ExtensionRegistryLite extensions)

  protected 
  
 static 
  
 M 
  
< M>parseWithIOException 
 ( 
 Parser<M> 
  
 parser 
 , 
  
 CodedInputStream 
  
 input 
 , 
  
 ExtensionRegistryLite 
  
 extensions 
 ) 
 
Parameters
Name
Description
parser
Parser < M >
Returns
Type
Description
M
Exceptions
Type
Description

<M>parseWithIOException(Parser<M> parser, InputStream input)

  protected 
  
 static 
  
 M 
  
< M>parseWithIOException 
 ( 
 Parser<M> 
  
 parser 
 , 
  
 InputStream 
  
 input 
 ) 
 
Parameters
Name
Description
parser
Parser < M >
input
Returns
Type
Description
M
Exceptions
Type
Description

<M>parseWithIOException(Parser<M> parser, InputStream input, ExtensionRegistryLite extensions)

  protected 
  
 static 
  
 M 
  
< M>parseWithIOException 
 ( 
 Parser<M> 
  
 parser 
 , 
  
 InputStream 
  
 input 
 , 
  
 ExtensionRegistryLite 
  
 extensions 
 ) 
 
Parameters
Name
Description
parser
Parser < M >
input
Returns
Type
Description
M
Exceptions
Type
Description

<V>serializeBooleanMapTo(CodedOutputStream out, MapField<Boolean,V> field, MapEntry<Boolean,V> defaultEntry, int fieldNumber)

  protected 
  
 static 
  
 void 
  
< V>serializeBooleanMapTo 
 ( 
 CodedOutputStream 
  
 out 
 , 
  
 MapField<Boolean 
 , 
 V 
>  
 field 
 , 
  
 MapEntry<Boolean 
 , 
 V 
>  
 defaultEntry 
 , 
  
 int 
  
 fieldNumber 
 ) 
 
Parameters
Name
Description
field
MapField < Boolean , V >
defaultEntry
MapEntry < Boolean , V >
fieldNumber
int
Exceptions
Type
Description

<V>serializeIntegerMapTo(CodedOutputStream out, MapField<Integer,V> field, MapEntry<Integer,V> defaultEntry, int fieldNumber)

  protected 
  
 static 
  
 void 
  
< V>serializeIntegerMapTo 
 ( 
 CodedOutputStream 
  
 out 
 , 
  
 MapField<Integer 
 , 
 V 
>  
 field 
 , 
  
 MapEntry<Integer 
 , 
 V 
>  
 defaultEntry 
 , 
  
 int 
  
 fieldNumber 
 ) 
 
Parameters
Name
Description
field
MapField < Integer , V >
defaultEntry
MapEntry < Integer , V >
fieldNumber
int
Exceptions
Type
Description

<V>serializeLongMapTo(CodedOutputStream out, MapField<Long,V> field, MapEntry<Long,V> defaultEntry, int fieldNumber)

  protected 
  
 static 
  
 void 
  
< V>serializeLongMapTo 
 ( 
 CodedOutputStream 
  
 out 
 , 
  
 MapField<Long 
 , 
 V 
>  
 field 
 , 
  
 MapEntry<Long 
 , 
 V 
>  
 defaultEntry 
 , 
  
 int 
  
 fieldNumber 
 ) 
 
Parameters
Name
Description
field
MapField < Long , V >
defaultEntry
MapEntry < Long , V >
fieldNumber
int
Exceptions
Type
Description

<V>serializeStringMapTo(CodedOutputStream out, MapField<String,V> field, MapEntry<String,V> defaultEntry, int fieldNumber)

  protected 
  
 static 
  
 void 
  
< V>serializeStringMapTo 
 ( 
 CodedOutputStream 
  
 out 
 , 
  
 MapField<String 
 , 
 V 
>  
 field 
 , 
  
 MapEntry<String 
 , 
 V 
>  
 defaultEntry 
 , 
  
 int 
  
 fieldNumber 
 ) 
 
Parameters
Name
Description
field
MapField < String , V >
defaultEntry
MapEntry < String , V >
fieldNumber
int
Exceptions
Type
Description

canUseUnsafe()

  protected 
  
 static 
  
 boolean 
  
 canUseUnsafe 
 () 
 
Returns
Type
Description

computeStringSize(int fieldNumber, Object value)

  protected 
  
 static 
  
 int 
  
 computeStringSize 
 ( 
 int 
  
 fieldNumber 
 , 
  
 Object 
  
 value 
 ) 
 
Parameters
Name
Description
fieldNumber
int
value
Returns
Type
Description
int

computeStringSizeNoTag(Object value)

  protected 
  
 static 
  
 int 
  
 computeStringSizeNoTag 
 ( 
 Object 
  
 value 
 ) 
 
Parameter
Name
Description
value
Returns
Type
Description
int

emptyBooleanList()

  protected 
  
 static 
  
 Internal 
 . 
 BooleanList 
  
 emptyBooleanList 
 () 
 
Returns
Type
Description

emptyDoubleList()

  protected 
  
 static 
  
 Internal 
 . 
 DoubleList 
  
 emptyDoubleList 
 () 
 
Returns
Type
Description

emptyFloatList()

  protected 
  
 static 
  
 Internal 
 . 
 FloatList 
  
 emptyFloatList 
 () 
 
Returns
Type
Description

emptyIntList()

  protected 
  
 static 
  
 Internal 
 . 
 IntList 
  
 emptyIntList 
 () 
 
Returns
Type
Description

emptyLongList()

  protected 
  
 static 
  
 Internal 
 . 
 LongList 
  
 emptyLongList 
 () 
 
Returns
Type
Description

isStringEmpty(Object value)

  protected 
  
 static 
  
 boolean 
  
 isStringEmpty 
 ( 
 Object 
  
 value 
 ) 
 
Parameter
Name
Description
value
Returns
Type
Description

mutableCopy(Internal.BooleanList list)

  protected 
  
 static 
  
 Internal 
 . 
 BooleanList 
  
 mutableCopy 
 ( 
 Internal 
 . 
 BooleanList 
  
 list 
 ) 
 
Parameter
Name
Description
Returns
Type
Description

mutableCopy(Internal.DoubleList list)

  protected 
  
 static 
  
 Internal 
 . 
 DoubleList 
  
 mutableCopy 
 ( 
 Internal 
 . 
 DoubleList 
  
 list 
 ) 
 
Parameter
Name
Description
Returns
Type
Description

mutableCopy(Internal.FloatList list)

  protected 
  
 static 
  
 Internal 
 . 
 FloatList 
  
 mutableCopy 
 ( 
 Internal 
 . 
 FloatList 
  
 list 
 ) 
 
Parameter
Name
Description
Returns
Type
Description

mutableCopy(Internal.IntList list)

  protected 
  
 static 
  
 Internal 
 . 
 IntList 
  
 mutableCopy 
 ( 
 Internal 
 . 
 IntList 
  
 list 
 ) 
 
Parameter
Name
Description
Returns
Type
Description

mutableCopy(Internal.LongList list)

  protected 
  
 static 
  
 Internal 
 . 
 LongList 
  
 mutableCopy 
 ( 
 Internal 
 . 
 LongList 
  
 list 
 ) 
 
Parameter
Name
Description
Returns
Type
Description

newBooleanList()

  protected 
  
 static 
  
 Internal 
 . 
 BooleanList 
  
 newBooleanList 
 () 
 
Returns
Type
Description

newDoubleList()

  protected 
  
 static 
  
 Internal 
 . 
 DoubleList 
  
 newDoubleList 
 () 
 
Returns
Type
Description

newFloatList()

  protected 
  
 static 
  
 Internal 
 . 
 FloatList 
  
 newFloatList 
 () 
 
Returns
Type
Description

newIntList()

  protected 
  
 static 
  
 Internal 
 . 
 IntList 
  
 newIntList 
 () 
 
Returns
Type
Description

newLongList()

  protected 
  
 static 
  
 Internal 
 . 
 LongList 
  
 newLongList 
 () 
 
Returns
Type
Description

writeString(CodedOutputStream output, int fieldNumber, Object value)

  protected 
  
 static 
  
 void 
  
 writeString 
 ( 
 CodedOutputStream 
  
 output 
 , 
  
 int 
  
 fieldNumber 
 , 
  
 Object 
  
 value 
 ) 
 
Parameters
Name
Description
fieldNumber
int
value
Exceptions
Type
Description

writeStringNoTag(CodedOutputStream output, Object value)

  protected 
  
 static 
  
 void 
  
 writeStringNoTag 
 ( 
 CodedOutputStream 
  
 output 
 , 
  
 Object 
  
 value 
 ) 
 
Parameters
Name
Description
value
Exceptions
Type
Description

Constructors

GeneratedMessageV3()

  protected 
  
 GeneratedMessageV3 
 () 
 

GeneratedMessageV3(GeneratedMessageV3.Builder<?> builder)

  protected 
  
 GeneratedMessageV3 
 ( 
 GeneratedMessageV3 
 . 
 Builder 
< ? 
>  
 builder 
 ) 
 
Parameter
Name
Description
builder
Builder < ? >

Fields

unknownFields

  protected 
  
 UnknownFieldSet 
  
 unknownFields 
 

For use by generated code only.

Field Value
Type
Description

Methods

getAllFields()

  public 
  
 Map<Descriptors 
 . 
 FieldDescriptor 
 , 
 Object 
>  
 getAllFields 
 () 
 
Returns
Type
Description

getDescriptorForType()

  public 
  
 Descriptors 
 . 
 Descriptor 
  
 getDescriptorForType 
 () 
 
Returns
Type
Description

getField(Descriptors.FieldDescriptor field)

  public 
  
 Object 
  
 getField 
 ( 
 Descriptors 
 . 
 FieldDescriptor 
  
 field 
 ) 
 
Parameter
Name
Description
Returns
Type
Description

getOneofFieldDescriptor(Descriptors.OneofDescriptor oneof)

  public 
  
 Descriptors 
 . 
 FieldDescriptor 
  
 getOneofFieldDescriptor 
 ( 
 Descriptors 
 . 
 OneofDescriptor 
  
 oneof 
 ) 
 

TODO(jieluo): Clear it when all subclasses have implemented this method.

Parameter
Name
Description
Returns
Type
Description
Overrides

getParserForType()

  public 
  
 Parser 
< ? 
  
 extends 
  
 GeneratedMessageV3 
>  
 getParserForType 
 () 
 
Returns
Type
Description
Parser < ? extends com.google.protobuf.GeneratedMessageV3 >

getRepeatedField(Descriptors.FieldDescriptor field, int index)

  public 
  
 Object 
  
 getRepeatedField 
 ( 
 Descriptors 
 . 
 FieldDescriptor 
  
 field 
 , 
  
 int 
  
 index 
 ) 
 
Parameters
Name
Description
index
int
Returns
Type
Description

getRepeatedFieldCount(Descriptors.FieldDescriptor field)

  public 
  
 int 
  
 getRepeatedFieldCount 
 ( 
 Descriptors 
 . 
 FieldDescriptor 
  
 field 
 ) 
 
Parameter
Name
Description
Returns
Type
Description
int

getSerializedSize()

  public 
  
 int 
  
 getSerializedSize 
 () 
 

Get the number of bytes required to encode this message. The result is only computed on the first call and memoized after that.

If this message requires more than Integer.MAX_VALUE bytes to encode, the return value will be smaller than the actual number of bytes required and might be negative.

Returns
Type
Description
int
Overrides

getUnknownFields()

  public 
  
 UnknownFieldSet 
  
 getUnknownFields 
 () 
 
Returns
Type
Description

hasField(Descriptors.FieldDescriptor field)

  public 
  
 boolean 
  
 hasField 
 ( 
 Descriptors 
 . 
 FieldDescriptor 
  
 field 
 ) 
 
Parameter
Name
Description
Returns
Type
Description

hasOneof(Descriptors.OneofDescriptor oneof)

  public 
  
 boolean 
  
 hasOneof 
 ( 
 Descriptors 
 . 
 OneofDescriptor 
  
 oneof 
 ) 
 

TODO(jieluo): Clear it when all subclasses have implemented this method.

Parameter
Name
Description
Returns
Type
Description
Overrides

internalGetFieldAccessorTable()

  protected 
  
 abstract 
  
 GeneratedMessageV3 
 . 
 FieldAccessorTable 
  
 internalGetFieldAccessorTable 
 () 
 

Get the FieldAccessorTable for this type. We can't have the message class pass this in to the constructor because of bootstrapping trouble with DescriptorProtos.

Returns
Type
Description

internalGetMapField(int fieldNumber)

  protected 
  
 MapField 
  
 internalGetMapField 
 ( 
 int 
  
 fieldNumber 
 ) 
 

Gets the map field with the given field number. This method should be overridden in the generated message class if the message contains map fields.

Unlike other field types, reflection support for map fields can't be implemented based on generated public API because we need to access a map field as a list in reflection API but the generated API only allows us to access it as a map. This method returns the underlying map field directly and thus enables us to access the map field as a list.

Parameter
Name
Description
fieldNumber
int
Returns
Type
Description

isInitialized()

  public 
  
 boolean 
  
 isInitialized 
 () 
 

Returns true if all required fields in the message and all embedded messages are set, false otherwise.

See also: MessageOrBuilder#getInitializationErrorString()

Returns
Type
Description
Overrides

makeExtensionsImmutable()

  protected 
  
 void 
  
 makeExtensionsImmutable 
 () 
 

Used by parsing constructors in generated classes.

mergeFromAndMakeImmutableInternal(CodedInputStream input, ExtensionRegistryLite extensionRegistry)

  protected 
  
 void 
  
 mergeFromAndMakeImmutableInternal 
 ( 
 CodedInputStream 
  
 input 
 , 
  
 ExtensionRegistryLite 
  
 extensionRegistry 
 ) 
 
Parameters
Name
Description
extensionRegistry
Exceptions
Type
Description

newBuilderForType(AbstractMessage.BuilderParent parent)

  protected 
  
 Message 
 . 
 Builder 
  
 newBuilderForType 
 ( 
 AbstractMessage 
 . 
 BuilderParent 
  
 parent 
 ) 
 

Create a nested builder.

Parameter
Name
Description
Returns
Type
Description
Overrides

newBuilderForType(GeneratedMessageV3.BuilderParent parent)

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

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

Parameter
Name
Description
Returns
Type
Description

newInstance(GeneratedMessageV3.UnusedPrivateParameter unused)

  protected 
  
 Object 
  
 newInstance 
 ( 
 GeneratedMessageV3 
 . 
 UnusedPrivateParameter 
  
 unused 
 ) 
 

Creates a new instance of this message type. Overridden in the generated code.

Parameter
Name
Description
Returns
Type
Description

parseUnknownField(CodedInputStream input, UnknownFieldSet.Builder unknownFields, ExtensionRegistryLite extensionRegistry, int tag)

  protected 
  
 boolean 
  
 parseUnknownField 
 ( 
 CodedInputStream 
  
 input 
 , 
  
 UnknownFieldSet 
 . 
 Builder 
  
 unknownFields 
 , 
  
 ExtensionRegistryLite 
  
 extensionRegistry 
 , 
  
 int 
  
 tag 
 ) 
 

Called by subclasses to parse an unknown field.

Parameters
Name
Description
unknownFields
extensionRegistry
tag
int
Returns
Type
Description

true unless the tag is an end-group tag.

Exceptions
Type
Description

parseUnknownFieldProto3(CodedInputStream input, UnknownFieldSet.Builder unknownFields, ExtensionRegistryLite extensionRegistry, int tag)

  protected 
  
 boolean 
  
 parseUnknownFieldProto3 
 ( 
 CodedInputStream 
  
 input 
 , 
  
 UnknownFieldSet 
 . 
 Builder 
  
 unknownFields 
 , 
  
 ExtensionRegistryLite 
  
 extensionRegistry 
 , 
  
 int 
  
 tag 
 ) 
 

Delegates to parseUnknownField. This method is obsolete, but we must retain it for compatibility with older generated code.

Parameters
Name
Description
unknownFields
extensionRegistry
tag
int
Returns
Type
Description
Exceptions
Type
Description

writeReplace()

  protected 
  
 Object 
  
 writeReplace 
 () 
 

Replaces this object in the output stream with a serialized form. Part of Java's serialization magic. Generated sub-classes must override this method by calling return super.writeReplace();

Returns
Type
Description

a SerializedForm of this message

Exceptions
Type
Description

writeTo(CodedOutputStream output)

  public 
  
 void 
  
 writeTo 
 ( 
 CodedOutputStream 
  
 output 
 ) 
 

Serializes the message and writes it to output . This does not flush or close the stream.

Parameter
Name
Description
Overrides
Exceptions
Type
Description
Design a Mobile Site
View Site in Mobile | Classic
Share by: