arlut.csd.Util
Class XMLItem

java.lang.Object
  |
  +--arlut.csd.Util.XMLItem
Direct Known Subclasses:
XMLCharData, XMLCloseElement, XMLElement, XMLEndDocument, XMLError, XMLStartDocument, XMLWarning

public abstract class XMLItem
extends java.lang.Object

Abstract base class for XML data held in the XMLReader class's buffer.

This class implements stubs for most of the methods in its subclass XMLElement, so that the Ganymede server code can process elements without having to constantly perform cast operations. The matches() method returns false unless this XMLItem is actually an XMLElement with the appropriate label, and the matchesClose() method returns false unless this XMLItem is actually an XMLCloseElement with the appropriate label.


Field Summary
 XMLItem parent
           
 
Constructor Summary
XMLItem()
           
 
Method Summary
 void debugPrintTree(int indentLevel)
          This debug method prints out this item and all items under this item if this item is the top node in a tree.
 void dissolve()
          This method unlinks this XMLItem and any subnodes of it from each other, as well as clearing this XMLItem's parent reference.
 boolean getAttrBoolean(java.lang.String name)
          This method returns the boolean attribute value for attribute <name>, if any.
 int getAttrCount()
          This method returns the number of attributes that this element has.
 java.lang.Integer getAttrInt(java.lang.String name)
          This method returns the Integer attribute value for attribute <name>, if any.
 java.lang.String getAttrKey(int index)
          This method returns the name for a given attribute in this XMLItem.
 java.lang.String getAttrStr(java.lang.String name)
          This method returns the attribute value for attribute <name>, if any.
 java.lang.String getAttrVal(int index)
          This method returns the value for a given attribute in this XMLItem.
 XMLItem[] getChildren()
          This method returns an array of children under this item, or null if there are none.
 java.lang.String getCleanString()
          This method returns the character data for this XMLItem with leading and trailing whitespace filtered out.
 java.lang.String getName()
          This method returns the name of an element, if this is the right kind of item.
 XMLItem getParent()
          This method returns the parent of this XMLItem, if any.
 java.lang.String getString()
          This method returns the character data for this XMLItem.
 java.lang.String getTreeString()
          Convenience method to get a string representation of this item and everything under it, if anything.
 void getTreeString(java.lang.StringBuffer buffer, int indentLevel)
          This debug method appends this item and all items under this item if this item is the top node in a tree to the StringBuffer passed in.
 boolean isEmpty()
          This method returns true if this is an empty element.
 boolean isOpen()
          This method returns true if this is an open element.
 boolean matches(java.lang.String name)
          This method returns true if this item is an XMLElement named <name>, false otherwise.
 boolean matchesClose(java.lang.String name)
          This method returns true if this item is an XMLCloseElement named <name>, false otherwise.
 void setChildren(XMLItem[] children)
          This method sets an array of XMLItem references to be this XMLItem's children.
 void setParent(XMLItem parent)
          This method sets this XMLItem's parent.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

parent

public XMLItem parent
Constructor Detail

XMLItem

public XMLItem()
Method Detail

getParent

public XMLItem getParent()

This method returns the parent of this XMLItem, if any.


getChildren

public XMLItem[] getChildren()

This method returns an array of children under this item, or null if there are none.


setParent

public void setParent(XMLItem parent)

This method sets this XMLItem's parent.


setChildren

public void setChildren(XMLItem[] children)

This method sets an array of XMLItem references to be this XMLItem's children.


dissolve

public void dissolve()

This method unlinks this XMLItem and any subnodes of it from each other, as well as clearing this XMLItem's parent reference. After this is called, children and parent will both be null-valued.


matches

public boolean matches(java.lang.String name)

This method returns true if this item is an XMLElement named <name>, false otherwise.


matchesClose

public boolean matchesClose(java.lang.String name)

This method returns true if this item is an XMLCloseElement named <name>, false otherwise.


isEmpty

public boolean isEmpty()

This method returns true if this is an empty element.


isOpen

public boolean isOpen()

This method returns true if this is an open element.


getAttrCount

public int getAttrCount()

This method returns the number of attributes that this element has.


getAttrKey

public java.lang.String getAttrKey(int index)

This method returns the name for a given attribute in this XMLItem.


getAttrVal

public java.lang.String getAttrVal(int index)

This method returns the value for a given attribute in this XMLItem.


getAttrStr

public java.lang.String getAttrStr(java.lang.String name)

This method returns the attribute value for attribute <name>, if any. If this element does not contain an attribute of the given name, null is returned.


getAttrBoolean

public boolean getAttrBoolean(java.lang.String name)

This method returns the boolean attribute value for attribute <name>, if any. For Ganymede's purposes, an attribute value is true if the attribute is present with a string value of "1". If this element does not contain an attribute of the given name, false is returned.


getAttrInt

public java.lang.Integer getAttrInt(java.lang.String name)

This method returns the Integer attribute value for attribute <name>, if any. If this element does not contain an attribute of the given name, or if the attribute does not contain an integer value, a null value is returned.


getName

public java.lang.String getName()

This method returns the name of an element, if this is the right kind of item.


getString

public java.lang.String getString()

This method returns the character data for this XMLItem.


getCleanString

public java.lang.String getCleanString()

This method returns the character data for this XMLItem with leading and trailing whitespace filtered out.


debugPrintTree

public void debugPrintTree(int indentLevel)

This debug method prints out this item and all items under this item if this item is the top node in a tree.


getTreeString

public void getTreeString(java.lang.StringBuffer buffer,
                          int indentLevel)

This debug method appends this item and all items under this item if this item is the top node in a tree to the StringBuffer passed in.


getTreeString

public java.lang.String getTreeString()

Convenience method to get a string representation of this item and everything under it, if anything.