| java.lang.Object com.icesoft.jasper.xmlparser.TreeNode
TreeNode | public class TreeNode (Code) | | 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 version: $Revision: 1.2 $ $Date: 2004/03/17 19:23:05 $ |
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. |
Method Summary | |
public void | addAttribute(String name, String value) Add an attribute to this node, replacing any existing attribute with the
same name. | public void | addChild(TreeNode node) Add a new child node to this node. | public String | findAttribute(String name) Return the value of the specified node attribute if it exists, or
null otherwise. | public Iterator | findAttributes() Return an Iterator of the attribute names of this node. | public TreeNode | findChild(String name) Return the first child node of this node with the specified name, if
there is one; otherwise, return null . | public Iterator | findChildren() Return an Iterator of all children of this node. | public Iterator | findChildren(String name) Return an Iterator over all children of this node that have the specified
name. | public String | getBody() Return the body text associated with this node (if any). | public String | getName() Return the name of this node. | public void | removeAttribute(String name) Remove any existing value for the specified attribute name. | public void | removeNode(TreeNode node) Remove a child node from this node, if it is one. | public void | setBody(String body) Set the body text associated with this node (if any). | public 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. |
attributes | protected HashMap attributes(Code) | | The attributes of this node, keyed by attribute name, Instantiated only
if required.
|
body | protected String body(Code) | | The body text associated with this node (if any).
|
children | protected ArrayList children(Code) | | The children of this node, instantiated only if required.
|
TreeNode | public TreeNode(String name)(Code) | | Construct a new node with no parent.
Parameters: name - The name of this node |
TreeNode | public TreeNode(String name, TreeNode parent)(Code) | | Construct a new node with the specified parent.
Parameters: name - The name of this node Parameters: parent - The node that is the parent of this node |
addAttribute | public void addAttribute(String name, String value)(Code) | | Add an attribute to this node, replacing any existing attribute with the
same name.
Parameters: name - The attribute name to add Parameters: value - The new attribute value |
addChild | public void addChild(TreeNode node)(Code) | | Add a new child node to this node.
Parameters: node - The new child node |
findAttribute | public String findAttribute(String name)(Code) | | Return the value of the specified node attribute if it exists, or
null otherwise.
Parameters: name - Name of the requested attribute |
findAttributes | public Iterator findAttributes()(Code) | | Return an Iterator of the attribute names of this node. If there are no
attributes, an empty Iterator is returned.
|
findChild | public TreeNode findChild(String name)(Code) | | 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 Iterator findChildren()(Code) | | Return an Iterator of all children of this node. If there are no
children, an empty Iterator is returned.
|
findChildren | public Iterator findChildren(String name)(Code) | | 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 String getBody()(Code) | | Return the body text associated with this node (if any).
|
getName | public String getName()(Code) | | Return the name of this node.
|
removeAttribute | public void removeAttribute(String name)(Code) | | Remove any existing value for the specified attribute name.
Parameters: name - The attribute name to remove |
removeNode | public void removeNode(TreeNode node)(Code) | | Remove a child node from this node, if it is one.
Parameters: node - The child node to remove |
setBody | public void setBody(String body)(Code) | | Set the body text associated with this node (if any).
Parameters: body - The body text (if any) |
toString | public String toString()(Code) | | Return a String representation of this TreeNode.
|
toString | protected void toString(StringBuffer sb, int indent, TreeNode node)(Code) | | Append to the specified StringBuffer a character representation of this
node, with the specified amount of indentation.
Parameters: sb - The StringBuffer to append to Parameters: indent - Number of characters of indentation Parameters: node - The TreeNode to be printed |
|
|