Class TreeNode
java.lang.Object
org.apache.jasper.xmlparser.TreeNode
Simplified implementation of a Node from a Document Object Model (DOM)
parse of an XML document. This class is used to represent a DOM tree
so that the XML parser's implementation of
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: 1.2 $ $Date: 2005/12/08 01:29:00 $
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe attributes of this node, keyed by attribute name, Instantiated only if required.protected StringThe body text associated with this node (if any).The children of this node, instantiated only if required.protected StringThe name of this node.protected TreeNodeThe parent node of this node. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAttribute(String name, String value) Add an attribute to this node, replacing any existing attribute with the same name.voidAdd a new child node to this node.findAttribute(String name) Return the value of the specified node attribute if it exists, ornullotherwise.Return an Iterator of the attribute names of this node.Return the first child node of this node with the specified name, if there is one; otherwise, returnnull.Return an Iterator of all children of this node.findChildren(String name) Return an Iterator over all children of this node that have the specified name.getBody()Return the body text associated with this node (if any).getName()Return the name of this node.voidremoveAttribute(String name) Remove any existing value for the specified attribute name.voidremoveNode(TreeNode node) Remove a child node from this node, if it is one.voidSet the body text associated with this node (if any).toString()Return a String representation of this TreeNode.protected voidtoString(StringBuilder sb, int indent, TreeNode node) Append to the specified StringBuilder a character representation of this node, with the specified amount of indentation.
-
Field Details
-
attributes
-
body
The body text associated with this node (if any). -
children
-
name
The name of this node. -
parent
The parent node of this node.
-
-
Constructor Details
-
TreeNode
Construct a new node with no parent.- Parameters:
name- The name of this node
-
TreeNode
-
-
Method Details
-
addAttribute
-
addChild
Add a new child node to this node.- Parameters:
node- The new child node
-
findAttribute
-
findAttributes
-
findChild
-
findChildren
-
findChildren
-
getBody
Return the body text associated with this node (if any). -
getName
Return the name of this node. -
removeAttribute
Remove any existing value for the specified attribute name.- Parameters:
name- The attribute name to remove
-
removeNode
Remove a child node from this node, if it is one.- Parameters:
node- The child node to remove
-
setBody
Set the body text associated with this node (if any).- Parameters:
body- The body text (if any)
-
toString
-
toString
Append to the specified StringBuilder a character representation of this node, with the specified amount of indentation.- Parameters:
sb- The StringBuilder to append toindent- Number of characters of indentationnode- The TreeNode to be printed
-