# Class: Message

## ProtoBuf.Reflect. Message

#### new Message(buildernon-null, parentnon-null, name, optionsopt, isGroupopt, syntaxnullable)

  Constructs a new Message.

  ##### Parameters:

  Name | Type | Attributes | Description
  --- | --- | --- | ---
  `builder` | ProtoBuf.Builder |  | Builder reference
  `parent` | ProtoBuf.Reflect.Namespace |  | Parent message or namespace
  `name` | string |  | Message name
  `options` | Object.<string, *> | <optional> | Message options
  `isGroup` | boolean | <optional> | `true` if this is a legacy group
  `syntax` | string | <nullable> | The syntax level of this definition (e.g., proto3)

  Source:
    - ProtoBuf.js, line 2250

### Extends

- ProtoBuf.Reflect.Namespace

### Classes

ExtensionField
Field
OneOf

### Members

#### (non-null) builder :ProtoBuf.Builder

  Builder reference.

  ##### Type:

  - ProtoBuf.Builder
  Inherited From:
    - ProtoBuf.Reflect.T#builder
  Source:
    - ProtoBuf.js, line 1382

#### (non-null) children :Array.<ProtoBuf.Reflect.T>

  Children inside the namespace.

  ##### Type:

  - Array.<ProtoBuf.Reflect.T>
  Inherited From:
    - ProtoBuf.Reflect.Namespace#children
  Source:
    - ProtoBuf.js, line 1477

#### className

  Source:
    - ProtoBuf.js, line 2256

#### (nullable) clazz :function

  Runtime message class.

  ##### Type:

  - function
  Source:
    - ProtoBuf.js, line 2270

#### (non-null) extensions :Array.<number>

  Extensions range.

  ##### Type:

  - Array.<number>
  Source:
    - ProtoBuf.js, line 2263

#### isGroup :boolean

  Whether this is a legacy group or not.

  ##### Type:

  - boolean
  Source:
    - ProtoBuf.js, line 2277

#### name :string

  Object name in namespace.

  ##### Type:

  - string
  Inherited From:
    - ProtoBuf.Reflect.T#name
  Source:
    - ProtoBuf.js, line 1396

#### (non-null) options :Object.<string, *>

  Options.

  ##### Type:

  - Object.<string, *>
  Inherited From:
    - ProtoBuf.Reflect.Namespace#options
  Source:
    - ProtoBuf.js, line 1483

#### (nullable) parent :ProtoBuf.Reflect.T

  Parent object.

  ##### Type:

  - ProtoBuf.Reflect.T
  Inherited From:
    - ProtoBuf.Reflect.T#parent
  Source:
    - ProtoBuf.js, line 1389

#### (non-null) syntax :string

  Syntax level (e.g., proto2 or proto3).

  ##### Type:

  - string
  Inherited From:
    - ProtoBuf.Reflect.Namespace#syntax
  Source:
    - ProtoBuf.js, line 1489

### Methods

#### addChild(child)

  Adds a child to the namespace.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `child` | ProtoBuf.Reflect.T | Child

  Inherited From:
    - ProtoBuf.Reflect.Namespace#addChild
  Source:
    - ProtoBuf.js, line 1521

  ##### Throws:

  If the child cannot be added (duplicate)
  Type
    Error

#### build(rebuildopt) → {ProtoBuf.Reflect.Message}

  Builds the message and returns the runtime counterpart, which is a fully functional class.

  ##### Parameters:

  Name | Type | Attributes | Description
  --- | --- | --- | ---
  `rebuild` | boolean | <optional> | Whether to rebuild or not, defaults to false

  Source:
    - ProtoBuf.js, line 2317
  See:
    - ProtoBuf.Builder.Message

  ##### Throws:

  If the message cannot be built
  Type
    Error

  ##### Returns:

  Message class

  Type
    ProtoBuf.Reflect.Message

#### buildOpt() → {Object.<string, *>}

  Builds the namespace's '$options' property.

  Inherited From:
    - ProtoBuf.Reflect.Namespace#buildOpt
  Source:
    - ProtoBuf.js, line 1631

  ##### Returns:

  Type
    Object.<string, *>

#### calculate(messagenon-null) → {number}

  Calculates a runtime message's byte length.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `message` | ProtoBuf.Builder.Message | Runtime message to encode

  Source:
    - ProtoBuf.js, line 3095

  ##### Throws:

  If required fields are missing or the message cannot be calculated for another reason
  Type
    Error

  ##### Returns:

  Byte length

  Type
    number

#### decode(buffer, lengthopt, expectedGroupEndIdopt) → {ProtoBuf.Builder.Message}

  Decodes an encoded message and returns the decoded message.

  ##### Parameters:

  Name | Type | Attributes | Description
  --- | --- | --- | ---
  `buffer` | ByteBuffer |  | ByteBuffer to decode from
  `length` | number | <optional> | Message length. Defaults to decode all the available data.
  `expectedGroupEndId` | number | <optional> | Expected GROUPEND id if this is a legacy group

  Source:
    - ProtoBuf.js, line 3157

  ##### Throws:

  If the message cannot be decoded
  Type
    Error

  ##### Returns:

  Decoded message

  Type
    ProtoBuf.Builder.Message

#### encode(messagenon-null, buffer, noVerifyopt) → {ByteBuffer}

  Encodes a runtime message's contents to the specified buffer.

  ##### Parameters:

  Name | Type | Attributes | Description
  --- | --- | --- | ---
  `message` | ProtoBuf.Builder.Message |  | Runtime message to encode
  `buffer` | ByteBuffer |  | ByteBuffer to write to
  `noVerify` | boolean | <optional> | Whether to not verify field values, defaults to `false`

  Source:
    - ProtoBuf.js, line 3068

  ##### Throws:

  If required fields are missing or the message cannot be encoded for another reason
  Type
    Error

  ##### Returns:

  The ByteBuffer for chaining

  Type
    ByteBuffer

#### fqn() → {string}

  Returns the fully qualified name of this object.

  Inherited From:
    - ProtoBuf.Reflect.T#fqn
  Source:
    - ProtoBuf.js, line 1417

  ##### Returns:

  Fully qualified name as of ".PATH.TO.THIS"

  Type
    string

#### getChild(nameOrId) → (nullable) {ProtoBuf.Reflect.T}

  Gets a child by its name or id.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `nameOrId` | string | number | Child name or id

  Inherited From:
    - ProtoBuf.Reflect.Namespace#getChild
  Source:
    - ProtoBuf.js, line 1541

  ##### Returns:

  The child or null if not found

  Type
    ProtoBuf.Reflect.T

#### getChildren(typeopt) → {Array.<ProtoBuf.Reflect.T>}

  Returns an array of the namespace's children.

  ##### Parameters:

  Name | Type | Attributes | Description
  --- | --- | --- | ---
  `type` | ProtoBuf.Reflect.T | <optional> | Filter type (returns instances of this type only). Defaults to null (all children).

  Inherited From:
    - ProtoBuf.Reflect.Namespace#getChildren
  Source:
    - ProtoBuf.js, line 1504

  ##### Returns:

  Type
    Array.<ProtoBuf.Reflect.T>

#### getOption(nameopt) → {*|Object.<string, *>}

  Gets the value assigned to the option with the specified name.

  ##### Parameters:

  Name | Type | Attributes | Description
  --- | --- | --- | ---
  `name` | string | <optional> | Returns the option value if specified, otherwise all options are returned.

  Inherited From:
    - ProtoBuf.Reflect.Namespace#getOption
  Source:
    - ProtoBuf.js, line 1652

  ##### Returns:

  null} Option value or NULL if there is no such option

  Type
    * | Object.<string, *>

#### qn(tnon-null) → {string}

  Determines the shortest qualified name of the specified type, if any, relative to this namespace.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `t` | ProtoBuf.Reflect.T | Reflection type

  Inherited From:
    - ProtoBuf.Reflect.Namespace#qn
  Source:
    - ProtoBuf.js, line 1594

  ##### Returns:

  The shortest qualified name or, if there is none, the fqn

  Type
    string

#### resolve(qn, excludeNonNamespaceopt) → (nullable) {ProtoBuf.Reflect.Namespace}

  Resolves a reflect object inside of this namespace.

  ##### Parameters:

  Name | Type | Attributes | Description
  --- | --- | --- | ---
  `qn` | string | !Array.<string> |  | Qualified name to resolve
  `excludeNonNamespace` | boolean | <optional> | Excludes non-namespace types, defaults to `false`

  Inherited From:
    - ProtoBuf.Reflect.Namespace#resolve
  Source:
    - ProtoBuf.js, line 1556

  ##### Returns:

  The resolved type or null if not found

  Type
    ProtoBuf.Reflect.Namespace

#### toString(includeClassopt)

  Returns a string representation of this Reflect object (its fully qualified name).

  ##### Parameters:

  Name | Type | Attributes | Description
  --- | --- | --- | ---
  `includeClass` | boolean | <optional> | Set to true to include the class name. Defaults to false.

  Inherited From:
    - ProtoBuf.Reflect.T#toString
  Source:
    - ProtoBuf.js, line 1435

  ##### Returns:

  String representation