Methods Summary |
---|
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.
// --------------------------------------------------------- Public Methods
if (attributes == null)
attributes = new HashMap();
attributes.put(name, value);
|
public void | addChild(org.apache.jasper.xmlparser.TreeNode node)Add a new child node to this node.
if (children == null)
children = new ArrayList();
children.add(node);
|
public java.lang.String | findAttribute(java.lang.String name)Return the value of the specified node attribute if it exists, or
null otherwise.
if (attributes == null)
return (null);
else
return ((String) attributes.get(name));
|
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.
if (attributes == null)
return (Collections.EMPTY_LIST.iterator());
else
return (attributes.keySet().iterator());
|
public org.apache.jasper.xmlparser.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 .
if (children == null)
return (null);
Iterator items = children.iterator();
while (items.hasNext()) {
TreeNode item = (TreeNode) items.next();
if (name.equals(item.getName()))
return (item);
}
return (null);
|
public java.util.Iterator | findChildren()Return an Iterator of all children of this node. If there are no
children, an empty Iterator is returned.
if (children == null)
return (Collections.EMPTY_LIST.iterator());
else
return (children.iterator());
|
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.
if (children == null)
return (Collections.EMPTY_LIST.iterator());
ArrayList results = new ArrayList();
Iterator items = children.iterator();
while (items.hasNext()) {
TreeNode item = (TreeNode) items.next();
if (name.equals(item.getName()))
results.add(item);
}
return (results.iterator());
|
public java.lang.String | getBody()Return the body text associated with this node (if any).
return (this.body);
|
public java.lang.String | getName()Return the name of this node.
return (this.name);
|
public void | removeAttribute(java.lang.String name)Remove any existing value for the specified attribute name.
if (attributes != null)
attributes.remove(name);
|
public void | removeNode(org.apache.jasper.xmlparser.TreeNode node)Remove a child node from this node, if it is one.
if (children != null)
children.remove(node);
|
public void | setBody(java.lang.String body)Set the body text associated with this node (if any).
this.body = body;
|
public java.lang.String | toString()Return a String representation of this TreeNode.
StringBuffer sb = new StringBuffer();
toString(sb, 0, this);
return (sb.toString());
|
protected void | toString(java.lang.StringBuffer sb, int indent, org.apache.jasper.xmlparser.TreeNode node)Append to the specified StringBuffer a character representation of
this node, with the specified amount of indentation.
int indent2 = indent + 2;
// Reconstruct an opening node
for (int i = 0; i < indent; i++)
sb.append(' ");
sb.append('<");
sb.append(node.getName());
Iterator names = node.findAttributes();
while (names.hasNext()) {
sb.append(' ");
String name = (String) names.next();
sb.append(name);
sb.append("=\"");
String value = node.findAttribute(name);
sb.append(value);
sb.append("\"");
}
sb.append(">\n");
// Reconstruct the body text of this node (if any)
String body = node.getBody();
if ((body != null) && (body.length() > 0)) {
for (int i = 0; i < indent2; i++)
sb.append(' ");
sb.append(body);
sb.append("\n");
}
// Reconstruct child nodes with extra indentation
Iterator children = node.findChildren();
while (children.hasNext()) {
TreeNode child = (TreeNode) children.next();
toString(sb, indent2, child);
}
// Reconstruct a closing node marker
for (int i = 0; i < indent; i++)
sb.append(' ");
sb.append("</");
sb.append(node.getName());
sb.append(">\n");
|