Class: Message

ProtoBuf.Reflect. Message

new Message(parent, name, options)

Constructs a new Message.

Parameters:
Name Type Description
parent ProtoBuf.Reflect.Namespace

Parent message or namespace

name string

Message name

options Object.<string,*>

Message options

Extends

Classes

Field

Members

children :Array.<ProtoBuf.Reflect.T>

Children inside the namespace.

Inherited From:

clazz :function(new:ProtoBuf.Builder.Message)

Runtime message class.

extensions :Array.<number>

Extensions range.

name :string

Object name in namespace.

Inherited From:

options :Object.<string, *>

Options.

Inherited From:

parent :ProtoBuf.Reflect.T|null

Parent object.

Inherited From:

Methods

addChild(child)

Adds a child to the namespace.

Parameters:
Name Type Description
child ProtoBuf.Reflect.T

Child

Inherited From:
Throws:
If the child cannot be added (duplicate)
Type
Error

build(rebuild) → {ProtoBuf.Reflect.Message}

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

Parameters:
Name Type Argument Description
rebuild boolean <optional>

Whether to rebuild or not, defaults to false

See:
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:
Returns:
Type
Object.<string,*>

decode(buffer, length) → {ProtoBuf.Builder.Message}

Decodes an encoded message and returns the decoded message.

Parameters:
Name Type Argument Description
buffer ByteBuffer

ByteBuffer to decode from

length number <optional>

Message length. Defaults to decode all the available data.

Throws:
If the message cannot be decoded
Type
Error
Returns:

Decoded message

Type
ProtoBuf.Builder.Message

encode(message, buffer) → {ByteBuffer}

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

Parameters:
Name Type Description
message ProtoBuf.Builder.Message

Runtime message to encode

buffer ByteBuffer

ByteBuffer to write to

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

The ByteBuffer for chaining

Type
ByteBuffer

encodeDelimitied(message, buffer) → {ByteBuffer}

Encodes a runtime message's varint32 length-delimitied contents to the specified buffer.

Parameters:
Name Type Description
message ProtoBuf.Builder.Message

Runtime message to encode

buffer ByteBuffer

ByteBuffer to write to

Throws:
If required fields are missing or the message cannot be encoded for anotzher reason
Type
Error
Returns:

The ByteBffer for chaining

Type
ByteBuffer

fqn() → {string}

Returns the fully qualified name of this object.

Inherited From:
Returns:

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

Type
string

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

Gets a child by its name.

Parameters:
Name Type Description
nameOrId string | number

Child name or id

Inherited From:
Returns:

The child or null if not found

Type
ProtoBuf.Reflect.T

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

Returns an array of the namespace's children.

Parameters:
Name Type Argument Description
type ProtoBuf.Reflect.T <optional>

Filter type (returns instances of this type only). Defaults to null (all children).

Inherited From:
Returns:
Type
Array.<ProtoBuf.Reflect.T>

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

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

Parameters:
Name Type Argument Description
name string <optional>

Returns the option value if specified, otherwise all options are returned.

Inherited From:
Returns:

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

Type
* | Object.<string,*>

hasChild(nameOrId) → {boolean}

Tests if this namespace has a child with the specified name.

Parameters:
Name Type Description
nameOrId string | number

Child name or id

Inherited From:
Returns:

true if there is one, else false

Type
boolean

resolve(qn, excludeFields) → {ProtoBuf.Reflect.Namespace|null}

Resolves a reflect object inside of this namespace.

Parameters:
Name Type Argument Description
qn string

Qualified name to resolve

excludeFields boolean <optional>

Excludes fields, defaults to false

Inherited From:
Returns:

The resolved type or null if not found

Type
ProtoBuf.Reflect.Namespace | null