public class Node extends Object implements Serializable
{foo a=1 b="abc"}
or nested
metadata like {foo a=1 b="123" { bar x=12 text="hello" }}
Constructor and Description |
---|
Node(Node parent,
Object name)
Creates a new Node named
name and if a parent is supplied, adds
the newly created node as a child of the parent. |
Node(Node parent,
Object name,
Map attributes)
Creates a new Node named
name with
attributes specified in the attributes Map. |
Node(Node parent,
Object name,
Map attributes,
Object value)
Creates a new Node named
name with value value and
with attributes specified in the attributes Map. |
Node(Node parent,
Object name,
Object value)
Creates a new Node named
name with value value and
if a parent is supplied, adds the newly created node as a child of the parent. |
Modifier and Type | Method and Description |
---|---|
boolean |
append(Node child) |
Node |
appendNode(Object name) |
Node |
appendNode(Object name,
Map attributes) |
Node |
appendNode(Object name,
Map attributes,
Object value) |
Node |
appendNode(Object name,
Object value) |
Object |
attribute(Object key) |
Map |
attributes() |
List |
breadthFirst()
Provide a collection of all the nodes in the tree
using a breadth-first traversal.
|
List |
children() |
List |
depthFirst()
Provide a collection of all the nodes in the tree
using a depth first traversal.
|
Object |
get(String key)
Provides lookup of elements by non-namespaced name
|
NodeList |
getAt(QName name)
Provides lookup of elements by QName.
|
Iterator |
iterator() |
Object |
name() |
Node |
parent() |
void |
plus(Closure c) |
void |
print(PrintWriter out) |
boolean |
remove(Node child) |
Node |
replaceNode(Closure c) |
protected static void |
setMetaClass(MetaClass metaClass,
Class nodeClass) |
void |
setValue(Object value) |
String |
text() |
String |
toString() |
Object |
value() |
public Node(Node parent, Object name)
name
and if a parent is supplied, adds
the newly created node as a child of the parent.parent
- the parent node or null if no parentname
- the name of the nodepublic Node(Node parent, Object name, Object value)
name
with value value
and
if a parent is supplied, adds the newly created node as a child of the parent.parent
- the parent node or null if no parentname
- the name of the nodevalue
- the Node value, e.g. some text but in general any Objectpublic Node(Node parent, Object name, Map attributes)
name
with
attributes specified in the attributes
Map. If a parent is supplied,
the newly created node is added as a child of the parent.parent
- the parent node or null if no parentname
- the name of the nodeattributes
- a Map of name-value pairspublic Node(Node parent, Object name, Map attributes, Object value)
name
with value value
and
with attributes specified in the attributes
Map. If a parent is supplied,
the newly created node is added as a child of the parent.parent
- the parent node or null if no parentname
- the name of the nodeattributes
- a Map of name-value pairsvalue
- the Node value, e.g. some text but in general any Objectpublic boolean append(Node child)
public boolean remove(Node child)
public void plus(Closure c)
public String text()
public Iterator iterator()
public List children()
public Map attributes()
public Object name()
public Object value()
public void setValue(Object value)
public Node parent()
public Object get(String key)
key
- the name (or shortcut key) of the node(s) of interestpublic NodeList getAt(QName name)
name
- the QName of interestpublic List depthFirst()
public List breadthFirst()
public void print(PrintWriter out)