org.weborganic.xmldoclet
Class XMLNode

java.lang.Object
  extended by org.weborganic.xmldoclet.XMLNode

public final class XMLNode
extends Object

Represents an XML node.


Constructor Summary
XMLNode(String name)
          Constructs the XMLNode.
XMLNode(String name, Doc doc)
          Constructs the XMLNode.
XMLNode(String name, Doc doc, int line)
          Constructs the XMLNode.
 
Method Summary
 XMLNode attribute(String name, boolean value)
          Adds an attribute to the node
 XMLNode attribute(String name, String value)
          Adds an attribute to the node
 XMLNode child(List<XMLNode> nodes)
          Adds a list of child nodes.
 XMLNode child(XMLNode node)
          Adds a child node.
 String getAttribute(String name)
          Returns the specified attributed.
 String getName()
          Returns the name of the node.
 void save(File dir, String name, Charset encoding, String nsPrefix)
          Saves this XML node to the directory specified.
 XMLNode text(String text)
          Adds text to the content of the node.
 String toString(String tabs)
          Converts the XML node to a String.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLNode

public XMLNode(String name,
               Doc doc,
               int line)
Constructs the XMLNode.

Parameters:
name - The name of the element
doc - The source java document the node belongs to.

XMLNode

public XMLNode(String name,
               Doc doc)
Constructs the XMLNode.

Parameters:
name - The name of the element
doc - The source java document the node belongs to.

XMLNode

public XMLNode(String name)
Constructs the XMLNode.

Parameters:
name - The name of the element
Method Detail

attribute

public XMLNode attribute(String name,
                         String value)
Adds an attribute to the node

Parameters:
name - the name of the attribute.
value - the value for the attribute

attribute

public XMLNode attribute(String name,
                         boolean value)
Adds an attribute to the node

Parameters:
name - the name of the attribute
value - the value for the attribute

child

public XMLNode child(List<XMLNode> nodes)
Adds a list of child nodes.

Parameters:
nodes - The nodes to add.
Returns:
this node for chaining.

child

public XMLNode child(XMLNode node)
Adds a child node.

Parameters:
node - The node
Returns:
this node for chaining.

text

public XMLNode text(String text)
Adds text to the content of the node.

Parameters:
text - The text.
Returns:
this node for chaining.

getAttribute

public String getAttribute(String name)
Returns the specified attributed.

Parameters:
name - The key for the value to be retrieved.
Returns:
The value stored in the attribute hash for the given key.

getName

public String getName()
Returns the name of the node.

Parameters:
name - The name of the node.
Returns:
The name of the node.

save

public void save(File dir,
                 String name,
                 Charset encoding,
                 String nsPrefix)
Saves this XML node to the directory specified.

Parameters:
dir - the directory to save this node to.
name - the name of the file
encoding - the character encoding used for the output.

toString

public String toString(String tabs)
Converts the XML node to a String.

Parameters:
tabs - The tabs used for indentation.
Returns:
the String representation of this node and its children.