|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgroovy.util.Node
public class Node
Represents an arbitrary tree node which can be used for structured metadata or any arbitrary XML-like tree.
A node can have a name, a value and an optional Map of attributes.
Typically the name is a String and a value is either a String or a List of other Nodes,
though the types are extensible to provide a flexible structure, e.g. you could use a
QName as the name which includes a namespace URI and a local name. Or a JMX ObjectName etc.
So this class can represent metadata like {foo a=1 b="abc"}
or nested
metadata like {foo a=1 b="123" { bar x=12 text="hello" }}
Constructor Summary | |
---|---|
Node(Node parent,
Object name)
|
|
Node(Node parent,
Object name,
Map attributes)
|
|
Node(Node parent,
Object name,
Map attributes,
Object value)
|
|
Node(Node parent,
Object name,
Object value)
|
Method Summary | |
---|---|
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 |
print(PrintWriter out)
|
boolean |
remove(Node child)
|
protected static void |
setMetaClass(MetaClass metaClass,
Class nodeClass)
|
void |
setValue(Object value)
|
String |
text()
|
String |
toString()
|
Object |
value()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Node(Node parent, Object name)
public Node(Node parent, Object name, Object value)
public Node(Node parent, Object name, Map attributes)
public Node(Node parent, Object name, Map attributes, Object value)
Method Detail |
---|
public boolean append(Node child)
public boolean remove(Node child)
public Node appendNode(Object name, Map attributes)
public Node appendNode(Object name)
public Node appendNode(Object name, Object value)
public Node appendNode(Object name, Map attributes, Object value)
protected static void setMetaClass(MetaClass metaClass, Class nodeClass)
public String text()
public Iterator iterator()
public List children()
public Map attributes()
public Object attribute(Object key)
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 interest
public NodeList getAt(QName name)
name
- the QName of interest
public List depthFirst()
public List breadthFirst()
public String toString()
toString
in class Object
public void print(PrintWriter out)
|
Copyright © 2003-2009 The Codehaus. All rights reserved. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |