ModelNode
A dynamic model representation node object.
Static Method Summary
Static Public Methods | ||
public static |
Creates a new undefined model node |
|
public static |
fromBase64(encoded: string): ModelNode 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 |
asProperties(): Property[] |
|
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 the child of this node with the given name. |
|
public |
getJSON(): json |
|
public |
Determine whether this node has a child with the given name. |
|
public |
hasDefined(key: string): boolean Determine whether this node has a defined child with the given name. |
|
public |
setBoolean(newValue: boolean): ModelNode 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 |
setExpression(newValue: string): ModelNode 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 |
Change this node's value to the given value. |
|
public |
setProperty(newValue: Property): ModelNode Change this node's value to the given value. |
|
public |
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). |
Public Members
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.
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.
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.
Throw:
* |
IllegalArgumentException if no conversion is possible |
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.
Throw:
* |
IllegalArgumentException if no conversion is possible |
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.
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.
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:
Name | Type | Attribute | Description |
name | string | the child name |
Throw:
* |
IllegalArgumentException if this node does not support getting a child with the given name |
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:
Name | Type | Attribute | Description |
key | string | the name |
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:
Name | Type | Attribute | Description |
key | string | the name |
public setBoolean(newValue: boolean): ModelNode source
Change this node's value to the given value.
Params:
Name | Type | Attribute | Description |
newValue | boolean | the new value |
public setExpression(newValue: string): ModelNode source
Change this node's value to the given expression value.
Params:
Name | Type | Attribute | Description |
newValue | string | the new value |
public setNode(newValue: ModelNode): ModelNode source
Change this node's value to the given value. The value is copied from the parameter.
Params:
Name | Type | Attribute | Description |
newValue | ModelNode | the new value |
public setNumber(newValue: number): ModelNode source
Change this node's value to the given value.
Params:
Name | Type | Attribute | Description |
newValue | number | the new value |
public setProperty(newValue: Property): ModelNode source
Change this node's value to the given value.
Params:
Name | Type | Attribute | Description |
newValue | Property | the new value |
public setString(newValue: string): ModelNode source
Change this node's value to the given value.
Params:
Name | Type | Attribute | Description |
newValue | string | the new value |