org.apache.jasper.xmlparser
public class TreeNode extends Object
org.w3c.dom
need
not be visible to the remainder of Jasper.
WARNING - Construction of a new tree, or modifications to an existing one, are not thread-safe and such accesses must be synchronized.
Version: $Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (Tue, 24 Oct 2006) $
Field Summary | |
---|---|
protected HashMap | attributes
The attributes of this node, keyed by attribute name,
Instantiated only if required. |
protected String | body
The body text associated with this node (if any). |
protected ArrayList | children
The children of this node, instantiated only if required. |
protected String | name
The name of this node. |
protected TreeNode | parent
The parent node of this node. |
Constructor Summary | |
---|---|
TreeNode(String name)
Construct a new node with no parent.
| |
TreeNode(String name, TreeNode parent)
Construct a new node with the specified parent.
|
Method Summary | |
---|---|
void | addAttribute(String name, String value)
Add an attribute to this node, replacing any existing attribute
with the same name.
|
void | addChild(TreeNode node)
Add a new child node to this node.
|
String | findAttribute(String name)
Return the value of the specified node attribute if it exists, or
null otherwise.
|
Iterator | findAttributes()
Return an Iterator of the attribute names of this node. |
TreeNode | findChild(String name)
Return the first child node of this node with the specified name,
if there is one; otherwise, return null .
|
Iterator | findChildren()
Return an Iterator of all children of this node. |
Iterator | findChildren(String name)
Return an Iterator over all children of this node that have the
specified name. |
String | getBody()
Return the body text associated with this node (if any). |
String | getName()
Return the name of this node. |
void | removeAttribute(String name)
Remove any existing value for the specified attribute name.
|
void | removeNode(TreeNode node)
Remove a child node from this node, if it is one.
|
void | setBody(String body)
Set the body text associated with this node (if any).
|
String | toString()
Return a String representation of this TreeNode. |
protected void | toString(StringBuffer sb, int indent, TreeNode node)
Append to the specified StringBuffer a character representation of
this node, with the specified amount of indentation.
|
Parameters: name The name of this node
Parameters: name The name of this node parent The node that is the parent of this node
Parameters: name The attribute name to add value The new attribute value
Parameters: node The new child node
null
otherwise.
Parameters: name Name of the requested attribute
null
.
Parameters: name Name of the desired child element
Parameters: name Name used to select children
Parameters: name The attribute name to remove
Parameters: node The child node to remove
Parameters: body The body text (if any)
Parameters: sb The StringBuffer to append to indent Number of characters of indentation node The TreeNode to be printed