proto2.Message Extends
Abstract base class for all Protocol Buffer 2 messages. It will be subclassed in the code generated by the Protocol Compiler. Any other subclasses are prohibited.

Inheritance

Constructor

goog.proto2.Message()

Instance Methods

Public Protected Private
add(fieldvalue)
Adds the given value to the field specified by the given field descriptor. Note that the field must be repeated.
Arguments:
field : goog.proto2.FieldDescriptor
The field in which to add the the value.
value : *
The new value to add to the field.
code »
add$Value(tagvalue)
Adds the value to the *repeating* field indicated by the given tag. GENERATED CODE USE ONLY. Basis of the add{Field} methods.
Arguments:
tag : number
The field's tag index.
value : *
The value to add.
code »
array$Values(tag) !Array
Gets the values at the field indicated by the given tag. GENERATED CODE USE ONLY. Basis of the {field}Array methods.
Arguments:
tag : number
The field's tag index.
Returns: !Array  The values found. If none, returns an empty array.
code »
arrayOf(field) !Array
Returns the array of values found for the given repeated field.
Arguments:
field : goog.proto2.FieldDescriptor
The field for which to return the values.
Returns: !Array  The values found.
code »
checkFieldType_(fieldvalue)
Ensures that the value being assigned to the given field is valid.
Arguments:
field : !goog.proto2.FieldDescriptor
The field being assigned.
value : *
The value being assigned.
code »
clear(field)
Clears the field specified.
Arguments:
field : goog.proto2.FieldDescriptor
The field to clear.
code »
clear$Field(tag)
Clears the field specified by tag. GENERATED CODE USE ONLY. Basis of the clear{Field} methods.
Arguments:
tag : number
The tag of the field to clear.
code »
clone() !goog.proto2.Message
No description.
Returns: !goog.proto2.Message  Recursive clone of the message only including the known fields.
code »
copyFrom(message)
Recursively copies the known fields from the given message to this message. Removes the fields which are not present in the source message.
Arguments:
message : !goog.proto2.Message
The source message.
code »
count$Values(tag) number
Returns the number of values stored in the field by the given tag. GENERATED CODE USE ONLY. Basis of the {field}Count methods.
Arguments:
tag : number
The tag.
Returns: number  The number of values.
code »
countOf(field) number
Returns the number of values stored in the given field.
Arguments:
field : goog.proto2.FieldDescriptor
The field for which to count the number of values.
Returns: number  The count of the values in the given field.
code »
equals(other) boolean
Compares this message with another one ignoring the unknown fields.
Arguments:
other : *
The other message.
Returns: boolean  Whether they are equal. Returns false if the other argument is a different type of message or not a message.
code »
forEachUnknown(callbackopt_scope)
Iterates over all the unknown fields in the message.
Arguments:
callback : function(number, *)
A callback method which gets invoked for each unknown field.
opt_scope : Object=
The scope under which to execute the callback. If not given, the current message will be used.
code »
get(fieldopt_index) *
Returns the value stored at the field specified by the given field descriptor.
Arguments:
field : goog.proto2.FieldDescriptor
The field for which to get the value.
opt_index : number=
If the field is repeated, the index to use when looking up the value.
Returns: *  The value found or null if none.
code »
get$Value(tagopt_index) *
Gets the value at the field indicated by the given tag. GENERATED CODE USE ONLY. Basis of the get{Field} methods.
Arguments:
tag : number
The field's tag index.
opt_index : number=
If the field is a repeated field, the index at which to get the value.
Returns: *  The value found or null for none.
code »
get$ValueOrDefault(tagopt_index) *
Gets the value at the field indicated by the given tag or the default value if none. GENERATED CODE USE ONLY. Basis of the get{Field} methods.
Arguments:
tag : number
The field's tag index.
opt_index : number=
If the field is a repeated field, the index at which to get the value.
Returns: *  The value found or the default value if none set.
code »
getDescriptor() !goog.proto2.Descriptor
Returns the descriptor which describes the current message. This only works if we assume people never subclass protobufs.
Returns: !goog.proto2.Descriptor  The descriptor.
code »
getOrDefault(fieldopt_index) *
Returns the value stored at the field specified by the given field descriptor or the default value if none exists.
Arguments:
field : goog.proto2.FieldDescriptor
The field for which to get the value.
opt_index : number=
If the field is repeated, the index to use when looking up the value.
Returns: *  The value found or the default if none.
code »
getValueForTag_(tag) *
Returns the value for the given tag number. If a lazy deserializer is instantiated, lazily deserializes the field if required before returning the value.
Arguments:
tag : number
The tag number.
Returns: *  The corresponding value, if any.
code »
has(field) boolean
Returns whether there is a value stored at the field specified by the given field descriptor.
Arguments:
field : goog.proto2.FieldDescriptor
The field for which to check if there is a value.
Returns: boolean  True if a value was found.
code »
has$Value(tag) boolean
Returns the whether or not the field indicated by the given tag has a value. GENERATED CODE USE ONLY. Basis of the has{Field} methods.
Arguments:
tag : number
The tag.
Returns: boolean  Whether the message has a value for the field.
code »
initDefaults(simpleFieldsToo)
Fills in the protocol buffer with default values. Any fields that are already set will not be overridden.
Arguments:
simpleFieldsToo : boolean
If true, all fields will be initialized; if false, only the nested messages and groups.
code »
initializeForLazyDeserializer(deserializerdata)
Initializes the message with a lazy deserializer and its associated data. This method should be called by internal methods ONLY.
Arguments:
deserializer : goog.proto2.LazyDeserializer
The lazy deserializer to use to decode the data on the fly.
data : *
The data to decode/deserialize.
code »
mergeFrom(message)
Merges the given message into this message. Singular fields will be overwritten, except for embedded messages which will be merged. Repeated fields will be concatenated.
Arguments:
message : !goog.proto2.Message
The source message.
code »
set(fieldvalue)
Stores the given value to the field specified by the given field descriptor. Note that the field must not be repeated.
Arguments:
field : goog.proto2.FieldDescriptor
The field for which to set the value.
value : *
The new value for the field.
code »
set$Value(tagvalue)
Sets the value of the *non-repeating* field indicated by the given tag. GENERATED CODE USE ONLY. Basis of the set{Field} methods.
Arguments:
tag : number
The field's tag index.
value : *
The field's value.
code »
setUnknown(tagvalue)
Sets the value of an unknown field, by tag.
Arguments:
tag : number
The tag of an unknown field (must be >= 1).
value : *
The value for that unknown field.
code »

Instance Properties

deserializedFields_ :
A map of those fields deserialized, from tag number to their deserialized value.
Code »
fields_ :
Stores the field information (i.e. metadata) about this message.
Code »
lazyDeserializer_ : goog.proto2.LazyDeserializer
The lazy deserializer for this message instance, if any.
Code »
values_ :
Stores the field values in this message. Keyed by the tag of the fields.
Code »

Static Methods

goog.proto2.Message.createDescriptor_(messageTypemetadataObj) !goog.proto2.Descriptor
Creates the metadata descriptor representing the definition of this message.
Arguments:
messageType : function(new:goog.proto2.Message)
Constructor for the message type to which this metadata applies.
metadataObj : Object
The object containing the metadata.
Returns: !goog.proto2.Descriptor  The new descriptor.
code »
goog.proto2.Message.set$Metadata(messageTypemetadataObj)
Sets the metadata that represents the definition of this message. GENERATED CODE USE ONLY. Called when constructing message classes.
Arguments:
messageType : !Function
Constructor for the message type to which this metadata applies.
metadataObj : Object
The object containing the metadata.
code »

Static Properties

goog.proto2.Message.descriptorObj_ :
All instances of goog.proto2.Message should have a static descriptorObj_ property. This is a JSON representation of a Descriptor. The real Descriptor will be deserialized lazily in the getDescriptor() method. This declaration is just here for documentation purposes. goog.proto2.Message does not have its own descriptor.
Code »
goog.proto2.Message.descriptor_ :
All instances of goog.proto2.Message should have a static descriptor_ property. The Descriptor will be deserialized lazily in the getDescriptor() method. This declaration is just here for documentation purposes. goog.proto2.Message does not have its own descriptor.
Code »

Enumerations

goog.proto2.Message.FieldType :
An enumeration defining the possible field types. Should be a mirror of that defined in descriptor.h. TODO(user): Remove this alias. The code generator generates code that references this enum, so it needs to exist until the code generator is changed. The enum was moved to from Message to FieldDescriptor to avoid a dependency cycle. Use goog.proto2.FieldDescriptor.FieldType instead.
Constants:
BOOL
No description.
BYTES
No description.
DOUBLE
No description.
ENUM
No description.
FIXED32
No description.
FIXED64
No description.
FLOAT
No description.
GROUP
No description.
INT32
No description.
INT64
No description.
MESSAGE
No description.
SFIXED32
No description.
SFIXED64
No description.
SINT32
No description.
SINT64
No description.
STRING
No description.
UINT32
No description.
UINT64
No description.
Code »

Package proto2

Package Reference