public interface Message extends MessageLite
See also MessageLite
, which defines most of the methods that typical
users care about. Message
adds to it methods that are not available
in the "lite" runtime. The biggest added features are introspection and
reflection -- i.e., getting descriptors for the message type and accessing
the field values dynamically.
Modifier and Type | Interface and Description |
---|---|
static interface |
Message.Builder
Abstract interface implemented by Protocol Message builders.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object other)
Compares the specified object with this message for equality.
|
Map<Descriptors.FieldDescriptor,Object> |
getAllFields()
Returns a collection of all the fields in this message which are set
and their corresponding values.
|
Message |
getDefaultInstanceForType()
Get an instance of the type with all fields set to their default values.
|
Descriptors.Descriptor |
getDescriptorForType()
Get the message's type's descriptor.
|
Object |
getField(Descriptors.FieldDescriptor field)
Obtains the value of the given field, or the default value if it is
not set.
|
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.
|
UnknownFieldSet |
getUnknownFields()
Get the
UnknownFieldSet for this message. |
boolean |
hasField(Descriptors.FieldDescriptor field)
Returns true if the given field is set.
|
int |
hashCode()
Returns the hash code value for this message.
|
Message.Builder |
newBuilderForType()
Constructs a new builder for a message of the same type as this message.
|
Message.Builder |
toBuilder()
Constructs a builder initialized with the current message.
|
String |
toString()
Converts the message to a string in protocol buffer text format.
|
getSerializedSize, isInitialized, toByteArray, toByteString, writeDelimitedTo, writeTo, writeTo
Descriptors.Descriptor getDescriptorForType()
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.Message getDefaultInstanceForType()
MessageLite
getDefaultInstance()
method of generated message classes in that
this method is an abstract method of the MessageLite
interface
whereas getDefaultInstance()
is a static method of a specific
class. They return the same thing.getDefaultInstanceForType
in interface MessageLite
Map<Descriptors.FieldDescriptor,Object> getAllFields()
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.boolean hasField(Descriptors.FieldDescriptor field)
IllegalArgumentException
- The field is a repeated field, or
field.getContainingType() != getDescriptorForType()
.Object getField(Descriptors.FieldDescriptor field)
int getRepeatedFieldCount(Descriptors.FieldDescriptor field)
IllegalArgumentException
- The field is not a repeated field, or
field.getContainingType() != getDescriptorForType()
.Object getRepeatedField(Descriptors.FieldDescriptor field, int index)
IllegalArgumentException
- The field is not a repeated field, or
field.getContainingType() != getDescriptorForType()
.UnknownFieldSet getUnknownFields()
UnknownFieldSet
for this message.boolean equals(Object other)
getDescriptorForType()
) and has identical values for
all of its fields.int hashCode()
hashCode
in class Object
Map.hashCode()
String toString()
TextFormat.printToString(Message)
.Message.Builder newBuilderForType()
MessageLite
newBuilderForType
in interface MessageLite
Message.Builder toBuilder()
MessageLite
toBuilder
in interface MessageLite
Copyright © 2008-2012. All Rights Reserved.