Apache Tomcat 6.0.53

org.apache.jasper.xmlparser
Class TreeNode

java.lang.Object
  extended by org.apache.jasper.xmlparser.TreeNode

public class TreeNode
extends java.lang.Object

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.

Author:
Craig R. McClanahan

Field Summary
protected  java.util.HashMap attributes
          The attributes of this node, keyed by attribute name, Instantiated only if required.
protected  java.lang.String body
          The body text associated with this node (if any).
protected  java.util.ArrayList children
          The children of this node, instantiated only if required.
protected  java.lang.String name
          The name of this node.
protected  TreeNode parent
          The parent node of this node.
 
Constructor Summary
TreeNode(java.lang.String name)
          Construct a new node with no parent.
TreeNode(java.lang.String name, TreeNode parent)
          Construct a new node with the specified parent.
 
Method Summary
 void addAttribute(java.lang.String name, java.lang.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.
 java.lang.String findAttribute(java.lang.String name)
          Return the value of the specified node attribute if it exists, or null otherwise.
 java.util.Iterator findAttributes()
          Return an Iterator of the attribute names of this node.
 TreeNode findChild(java.lang.String name)
          Return the first child node of this node with the specified name, if there is one; otherwise, return null.
 java.util.Iterator findChildren()
          Return an Iterator of all children of this node.
 java.util.Iterator findChildren(java.lang.String name)
          Return an Iterator over all children of this node that have the specified name.
 java.lang.String getBody()
          Return the body text associated with this node (if any).
 java.lang.String getName()
          Return the name of this node.
 void removeAttribute(java.lang.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(java.lang.String body)
          Set the body text associated with this node (if any).
 java.lang.String toString()
          Return a String representation of this TreeNode.
protected  void toString(java.lang.StringBuffer sb, int indent, TreeNode node)
          Append to the specified StringBuffer a character representation of this node, with the specified amount of indentation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

attributes

protected java.util.HashMap attributes
The attributes of this node, keyed by attribute name, Instantiated only if required.


body

protected java.lang.String body
The body text associated with this node (if any).


children

protected java.util.ArrayList children
The children of this node, instantiated only if required.


name

protected java.lang.String name
The name of this node.


parent

protected TreeNode parent
The parent node of this node.

Constructor Detail

TreeNode

public TreeNode(java.lang.String name)
Construct a new node with no parent.

Parameters:
name - The name of this node

TreeNode

public TreeNode(java.lang.String name,
                TreeNode parent)
Construct a new node with the specified parent.

Parameters:
name - The name of this node
parent - The node that is the parent of this node
Method Detail

addAttribute

public void addAttribute(java.lang.String name,
                         java.lang.String value)
Add an attribute to this node, replacing any existing attribute with the same name.

Parameters:
name - The attribute name to add
value - The new attribute value

addChild

public void addChild(TreeNode node)
Add a new child node to this node.

Parameters:
node - The new child node

findAttribute

public java.lang.String findAttribute(java.lang.String name)
Return the value of the specified node attribute if it exists, or null otherwise.

Parameters:
name - Name of the requested attribute

findAttributes

public java.util.Iterator findAttributes()
Return an Iterator of the attribute names of this node. If there are no attributes, an empty Iterator is returned.


findChild

public TreeNode findChild(java.lang.String name)
Return the first child node of this node with the specified name, if there is one; otherwise, return null.

Parameters:
name - Name of the desired child element

findChildren

public java.util.Iterator findChildren()
Return an Iterator of all children of this node. If there are no children, an empty Iterator is returned.


findChildren

public java.util.Iterator findChildren(java.lang.String name)
Return an Iterator over all children of this node that have the specified name. If there are no such children, an empty Iterator is returned.

Parameters:
name - Name used to select children

getBody

public java.lang.String getBody()
Return the body text associated with this node (if any).


getName

public java.lang.String getName()
Return the name of this node.


removeAttribute

public void removeAttribute(java.lang.String name)
Remove any existing value for the specified attribute name.

Parameters:
name - The attribute name to remove

removeNode

public void removeNode(TreeNode node)
Remove a child node from this node, if it is one.

Parameters:
node - The child node to remove

setBody

public void setBody(java.lang.String body)
Set the body text associated with this node (if any).

Parameters:
body - The body text (if any)

toString

public java.lang.String toString()
Return a String representation of this TreeNode.

Overrides:
toString in class java.lang.Object

toString

protected void toString(java.lang.StringBuffer sb,
                        int indent,
                        TreeNode node)
Append to the specified StringBuffer a character representation of this node, with the specified amount of indentation.

Parameters:
sb - The StringBuffer to append to
indent - Number of characters of indentation
node - The TreeNode to be printed

Apache Tomcat 6.0.53

Copyright © 2000-2017 Apache Software Foundation. All Rights Reserved.