The goog.ds.Expr Class

goog.ds.Expr(opt_expr)

Create a new expression. An expression uses a string expression language, and from this string and a passed in DataNode can evaluate to a value, DataNode, or a DataNodeList.

opt_expr {string=}
The string expression.

.ALL_ATTRIBUTES

For DOM interop - all DOM attribute nodes Attribute nodes have dataName starting with "@"

.ALL_CHILD_NODES

For DOM interop - all DOM child nodes (text + element). Text nodes have dataName #text

.ALL_ELEMENTS

For DOM interop - all DOM element child nodes

.COUNT

Get the count of nodes matching an expression

.CURRENT

The current node

.NAME

Get the dataName of a node

.POSITION

Get the position of the "current" node in the current node list This will only apply for datasources that support the concept of a current node (none exist yet). This is similar to XPath position() and concept of current node

.create(expr)

Create an expression from a string, can use cached values

expr {string}
The expression string.
returns {goog.ds.Expr}
The expression object.

.getLast()

Gets the last part of the expression.

returns {?string}
Last part of the expression.

.getNext()

Gets the parent expression of this expression, or null if this is top level

returns {goog.ds.Expr}
The parent.

.getNode(opt_ds, opt_canCreate)

Evaluate an expression on a data node, and return the first matching node Recursively walks through child nodes to evaluate

opt_ds {goog.ds.DataNode=}
Optional datasource to evaluate against. If not provided, evaluates against DataManager global root.
opt_canCreate {boolean=}
If true, will try to create new nodes.
returns {goog.ds.DataNode}
Matching nodes, or null if doesn't exist.

.getNodes(opt_ds, opt_canCreate)

Evaluate an expression on a data node, and return matching nodes Recursively walks through child nodes to evaluate

opt_ds {goog.ds.DataNode=}
Optional datasource to evaluate against. If not provided, evaluates against data root.
opt_canCreate {boolean=}
If true, will try to create new nodes.
returns {goog.ds.DataNodeList}
Matching nodes.

.getParent()

Gets the parent expression of this expression, or null if this is top level

returns {goog.ds.Expr}
The parent.

.getSource()

Get the source data path for the expression

returns {string}
The path.

.getValue(opt_ds)

Evaluate an expression on a data node, and return a value Recursively walks through child nodes to evaluate TODO(user) Support other expression functions

opt_ds {goog.ds.DataNode=}
Optional datasource to evaluate against. If not provided, evaluates against DataManager global root.
returns {*}
Value of the node, or null if doesn't exist.