groovy.util
Class Node
java.lang.Object
groovy.util.Node
- public class Node
- extends java.lang.Object
Represents an arbitrary tree node which can be used for structured metadata which can be 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" }}
- Version:
- $Revision: 1.8 $
- Author:
- James Strachan
Constructor Summary |
Node(Node parent,
java.lang.Object name)
|
Node(Node parent,
java.lang.Object name,
java.util.Map attributes)
|
Node(Node parent,
java.lang.Object name,
java.util.Map attributes,
java.lang.Object value)
|
Node(Node parent,
java.lang.Object name,
java.lang.Object value)
|
Method Summary |
java.lang.Object |
attribute(java.lang.Object key)
|
java.util.Map |
attributes()
|
java.util.List |
breadthFirst()
Provide a collection of all the nodes in the tree
using a bredth first traversal |
private java.util.List |
breadthFirstRest()
|
java.util.List |
children()
|
java.util.List |
depthFirst()
Provide a collection of all the nodes in the tree
using a depth first traversal |
private java.util.List |
depthFirstRest()
|
java.lang.Object |
get(java.lang.String key)
|
java.util.Iterator |
iterator()
|
java.lang.Object |
name()
|
Node |
parent()
|
void |
print(java.io.PrintWriter out)
|
void |
setValue(java.lang.Object value)
|
java.lang.String |
text()
|
java.lang.String |
toString()
|
java.lang.Object |
value()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
parent
private Node parent
name
private java.lang.Object name
attributes
private java.util.Map attributes
value
private java.lang.Object value
Node
public Node(Node parent,
java.lang.Object name)
Node
public Node(Node parent,
java.lang.Object name,
java.lang.Object value)
Node
public Node(Node parent,
java.lang.Object name,
java.util.Map attributes)
Node
public Node(Node parent,
java.lang.Object name,
java.util.Map attributes,
java.lang.Object value)
text
public java.lang.String text()
iterator
public java.util.Iterator iterator()
children
public java.util.List children()
attributes
public java.util.Map attributes()
attribute
public java.lang.Object attribute(java.lang.Object key)
name
public java.lang.Object name()
value
public java.lang.Object value()
setValue
public void setValue(java.lang.Object value)
parent
public Node parent()
get
public java.lang.Object get(java.lang.String key)
depthFirst
public java.util.List depthFirst()
- Provide a collection of all the nodes in the tree
using a depth first traversal
depthFirstRest
private java.util.List depthFirstRest()
breadthFirst
public java.util.List breadthFirst()
- Provide a collection of all the nodes in the tree
using a bredth first traversal
breadthFirstRest
private java.util.List breadthFirstRest()
toString
public java.lang.String toString()
print
public void print(java.io.PrintWriter out)
Copyright © 2003-2005 The Codehaus. All Rights Reserved.