groovy.util
Class Node

java.lang.Object
  extended bygroovy.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.5 $
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 bredthFirst()
          Provide a collection of all the nodes in the tree using a bredth first traversal
 java.util.List children()
           
 java.util.List depthFirst()
          Provide a collection of all the nodes in the tree using a depth first traversal
 java.lang.Object get(java.lang.String key)
           
 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
 

Constructor Detail

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)
Method Detail

text

public java.lang.String text()

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


bredthFirst

public java.util.List bredthFirst()
Provide a collection of all the nodes in the tree using a bredth first traversal


toString

public java.lang.String toString()

print

public void print(java.io.PrintWriter out)


Copyright © 2003-2004 The Codehaus. All Rights Reserved.