Home Manual Reference Source
public class | source

ModelNode

A dynamic model representation node object.

Static Method Summary

Static Public Methods
public static

Creates a new undefined model node

public static

Creates a new node from a base64 encoded string

Member Summary

Public Members
public get

Determine whether this node is defined.

public get
public get

Method Summary

Public Methods
public

Add a node to the end of this node's value list and return it. If the node is undefined, it will be initialized to be of type list.

public

Get the value of this node as a boolean.

public

Get the value of this node as number.

public
public

Get a copy of this value as an object.

public
public

Get the value of this node as a property.

public

Get the value as a string.

public

Clear this node's value and change its type to undefined.

public

get(name: string): ModelNode

Get the child of this node with the given name.

public

getJSON(): json

public

has(key: string): boolean

Determine whether this node has a child with the given name.

public

Determine whether this node has a defined child with the given name.

public

Change this node's value to the given value.

public

Change this node's value to an empty list.

public

Change this node's value to an empty object.

public

Change this node's value to the given expression value.

public

Change this node's value to the given value. The value is copied from the parameter.

public

setNumber(newValue: number): ModelNode

Change this node's value to the given value.

public

Change this node's value to the given value.

public

setString(newValue: string): ModelNode

Change this node's value to the given value.

public
public

Get a human-readable string representation of this model node, formatted nicely (possibly on multiple lines).

Static Public Methods

public static create(): ModelNode source

Creates a new undefined model node

Return:

ModelNode

the new model node

public static fromBase64(encoded: string): ModelNode source

Creates a new node from a base64 encoded string

Params:

NameTypeAttributeDescription
encoded string

The base64 encoded string.

Return:

ModelNode

the new model node

Public Members

public get defined: boolean source

Determine whether this node is defined.

Return:

boolean

true if this node's value is defined, false otherwise

public get failure: boolean source

Return:

boolean

true if this node has an outcome and the outcome does not equal "success"

public get failureDescription: string source

Return:

string

the failure description or "No failure-description provided"

Public Methods

public add(): ModelNode source

Add a node to the end of this node's value list and return it. If the node is undefined, it will be initialized to be of type list.

Return:

ModelNode

the new node

public asBoolean(): boolean source

Get the value of this node as a boolean. Collection types return true for non-empty collections. Numerical types return true for non-zero values.

Return:

boolean

the boolean value

Throw:

*

IllegalArgumentException if no conversion is possible

public asInt(): number source

Get the value of this node as number. Collection types will return the size of the collection for this value. Other types may attempt a string conversion.

Return:

number

the numeric value

Throw:

*

IllegalArgumentException if no conversion is possible

public asList(): ModelNode[] source

Return:

ModelNode[]

this model node as an array.

public asObject(): ModelNode source

Get a copy of this value as an object. Object values will simply copy themselves.

Property values will return a single-entry object whose key and value are copied from the property key and value.

List values will attempt to interpolate the list into an object by iterating each item, mapping each property into an object entry and otherwise taking pairs of list entries, converting the first to a string, and using the pair of entries as a single object entry. If an object key appears more than once in the source object, the last key takes precedence.

Return:

ModelNode

the object value

Throw:

*

IllegalArgumentException if no conversion is possible

public asProperties(): Property[] source

Return:

Property[]

this model node as an Property array

public asProperty(): Property source

Get the value of this node as a property. Object values will return a property if there is exactly one property in the object. List values will return a property if there are exactly two items in the list, and if the first is convertible to a string.

Return:

Property

the property value

Throw:

*

IllegalArgumentException if no conversion is possible

public asString(): string source

Get the value as a string. This is the literal value of this model node. More than one node type may yield the same value for this method.

Return:

string

the string value

public clear(): ModelNode source

Clear this node's value and change its type to undefined.

Return:

ModelNode

this node

public get(name: string): ModelNode source

Get the child of this node with the given name. If no such child exists, create it. If the node is undefined, it will be initialized to be of type object.

When called on property values, the name must match the property name.

Params:

NameTypeAttributeDescription
name string

the child name

Return:

ModelNode

the child

Throw:

*

IllegalArgumentException if this node does not support getting a child with the given name

public getJSON(): json source

Return:

json

the model node as JSON

public has(key: string): boolean source

Determine whether this node has a child with the given name. Property node types always contain exactly one value with a key equal to the property name.

Params:

NameTypeAttributeDescription
key string

the name

Return:

boolean

true if there is a (possibly undefined) node at the given key

public hasDefined(key: string): boolean source

Determine whether this node has a defined child with the given name. Property node types always contain exactly one value with a key equal to the property name.

Params:

NameTypeAttributeDescription
key string

the name

Return:

boolean

true if there is a node at the given index and its type is not undefined

public setBoolean(newValue: boolean): ModelNode source

Change this node's value to the given value.

Params:

NameTypeAttributeDescription
newValue boolean

the new value

Return:

ModelNode

this node

public setEmptyList(): ModelNode source

Change this node's value to an empty list.

Return:

ModelNode

this node

public setEmptyObject(): ModelNode source

Change this node's value to an empty object.

Return:

ModelNode

this node

public setExpression(newValue: string): ModelNode source

Change this node's value to the given expression value.

Params:

NameTypeAttributeDescription
newValue string

the new value

Return:

ModelNode

this node

public setNode(newValue: ModelNode): ModelNode source

Change this node's value to the given value. The value is copied from the parameter.

Params:

NameTypeAttributeDescription
newValue ModelNode

the new value

Return:

ModelNode

this node

public setNumber(newValue: number): ModelNode source

Change this node's value to the given value.

Params:

NameTypeAttributeDescription
newValue number

the new value

Return:

ModelNode

this node

public setProperty(newValue: Property): ModelNode source

Change this node's value to the given value.

Params:

NameTypeAttributeDescription
newValue Property

the new value

Return:

ModelNode

this node

public setString(newValue: string): ModelNode source

Change this node's value to the given value.

Params:

NameTypeAttributeDescription
newValue string

the new value

Return:

ModelNode

this node

public toBase64String() source

public toString(): string source

Get a human-readable string representation of this model node, formatted nicely (possibly on multiple lines).

Return:

string

the string representation