Class DynamicMessage (3.19.4)

  public 
  
 final 
  
 class 
 DynamicMessage 
  
 extends 
  
 AbstractMessage 
 

An implementation of Message that can represent arbitrary types, given a Descriptors.Descriptor .

Static Methods

getDefaultInstance(Descriptors.Descriptor type)

  public 
  
 static 
  
 DynamicMessage 
  
 getDefaultInstance 
 ( 
 Descriptors 
 . 
 Descriptor 
  
 type 
 ) 
 

Get a DynamicMessage representing the default instance of the given type.

Parameter
Name
Description
Returns
Type
Description

newBuilder(Descriptors.Descriptor type)

  public 
  
 static 
  
 DynamicMessage 
 . 
 Builder 
  
 newBuilder 
 ( 
 Descriptors 
 . 
 Descriptor 
  
 type 
 ) 
 

Construct a Message.Builder for the given type.

Parameter
Name
Description
Returns
Type
Description

newBuilder(Message prototype)

  public 
  
 static 
  
 DynamicMessage 
 . 
 Builder 
  
 newBuilder 
 ( 
 Message 
  
 prototype 
 ) 
 

Construct a Message.Builder for a message of the same type as prototype , and initialize it with prototype 's contents.

Parameter
Name
Description
prototype
Returns
Type
Description

parseFrom(Descriptors.Descriptor type, byte[] data)

  public 
  
 static 
  
 DynamicMessage 
  
 parseFrom 
 ( 
 Descriptors 
 . 
 Descriptor 
  
 type 
 , 
  
 byte 
 [] 
  
 data 
 ) 
 

Parse data as a message of the given type and return it.

Parameters
Name
Description
data
byte []
Returns
Type
Description
Exceptions
Type
Description

parseFrom(Descriptors.Descriptor type, byte[] data, ExtensionRegistry extensionRegistry)

  public 
  
 static 
  
 DynamicMessage 
  
 parseFrom 
 ( 
 Descriptors 
 . 
 Descriptor 
  
 type 
 , 
  
 byte 
 [] 
  
 data 
 , 
  
 ExtensionRegistry 
  
 extensionRegistry 
 ) 
 

Parse data as a message of the given type and return it.

Parameters
Name
Description
data
byte []
extensionRegistry
Returns
Type
Description
Exceptions
Type
Description

parseFrom(Descriptors.Descriptor type, ByteString data)

  public 
  
 static 
  
 DynamicMessage 
  
 parseFrom 
 ( 
 Descriptors 
 . 
 Descriptor 
  
 type 
 , 
  
 ByteString 
  
 data 
 ) 
 

Parse data as a message of the given type and return it.

Parameters
Name
Description
data
Returns
Type
Description
Exceptions
Type
Description

parseFrom(Descriptors.Descriptor type, ByteString data, ExtensionRegistry extensionRegistry)

  public 
  
 static 
  
 DynamicMessage 
  
 parseFrom 
 ( 
 Descriptors 
 . 
 Descriptor 
  
 type 
 , 
  
 ByteString 
  
 data 
 , 
  
 ExtensionRegistry 
  
 extensionRegistry 
 ) 
 

Parse data as a message of the given type and return it.

Parameters
Name
Description
data
extensionRegistry
Returns
Type
Description
Exceptions
Type
Description

parseFrom(Descriptors.Descriptor type, CodedInputStream input)

  public 
  
 static 
  
 DynamicMessage 
  
 parseFrom 
 ( 
 Descriptors 
 . 
 Descriptor 
  
 type 
 , 
  
 CodedInputStream 
  
 input 
 ) 
 

Parse a message of the given type from the given input stream.

Parameters
Name
Description
Returns
Type
Description
Exceptions
Type
Description

parseFrom(Descriptors.Descriptor type, CodedInputStream input, ExtensionRegistry extensionRegistry)

  public 
  
 static 
  
 DynamicMessage 
  
 parseFrom 
 ( 
 Descriptors 
 . 
 Descriptor 
  
 type 
 , 
  
 CodedInputStream 
  
 input 
 , 
  
 ExtensionRegistry 
  
 extensionRegistry 
 ) 
 

Parse a message of the given type from the given input stream.

Parameters
Name
Description
extensionRegistry
Returns
Type
Description
Exceptions
Type
Description

parseFrom(Descriptors.Descriptor type, InputStream input)

  public 
  
 static 
  
 DynamicMessage 
  
 parseFrom 
 ( 
 Descriptors 
 . 
 Descriptor 
  
 type 
 , 
  
 InputStream 
  
 input 
 ) 
 

Parse a message of the given type from input and return it.

Parameters
Name
Description
input
Returns
Type
Description
Exceptions
Type
Description

parseFrom(Descriptors.Descriptor type, InputStream input, ExtensionRegistry extensionRegistry)

  public 
  
 static 
  
 DynamicMessage 
  
 parseFrom 
 ( 
 Descriptors 
 . 
 Descriptor 
  
 type 
 , 
  
 InputStream 
  
 input 
 , 
  
 ExtensionRegistry 
  
 extensionRegistry 
 ) 
 

Parse a message of the given type from input and return it.

Parameters
Name
Description
input
extensionRegistry
Returns
Type
Description
Exceptions
Type
Description

Methods

getAllFields()

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

getDefaultInstanceForType()

  public 
  
 DynamicMessage 
  
 getDefaultInstanceForType 
 () 
 
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<DynamicMessage> 
  
 getParserForType 
 () 
 
Returns
Type
Description

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

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

newBuilderForType()

  public 
  
 DynamicMessage 
 . 
 Builder 
  
 newBuilderForType 
 () 
 
Returns
Type
Description

toBuilder()

  public 
  
 DynamicMessage 
 . 
 Builder 
  
 toBuilder 
 () 
 
Returns
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: