com.adventnet.utilities.xml.dom
Class XMLNode

java.lang.Object
  |
  +--com.adventnet.utilities.xml.dom.XMLNode

public class XMLNode
extends java.lang.Object
implements java.io.Serializable

This represents an XML data element .

nodeType variable identifies the type of the data element. Valid values are ELEMENT, DOCUMENT, ENTITYREF, COMMENT, PCDATA, CDATA

attributeList Hashtable stores the attributes of an element.

parentNode provides a referenence to the parent XMLNode

childNodes Vector provides references to its child nodes

See Also:
Serialized Form

Field Summary
(package private)  java.util.Vector attrNameVector
           
static int CDATA
           
static int COMMENT
          Comment Node
static int DOCUMENT
          Document Node
static int ELEMENT
          Element Node
static int ENTITYREF
          Entity Reference
static int PCDATA
           
 
Constructor Summary
XMLNode()
          Constructor to create a new instance of XMLNode
 
Method Summary
 void addChildNode(XMLNode childNode)
          Adds a node as a child node to this node.
 java.util.Enumeration children()
          Returns an Enumeration of child nodes
 java.lang.Object clone()
          Clones the XML node along with its children
 void deleteChildNode(XMLNode node)
          Deletes the specified node from the childList
 void deleteNode()
          Deletes all the children of this node
 java.lang.Object getAttribute(java.lang.String attrName)
          Gets the value of the attribute for the specified attrName
 java.util.Hashtable getAttributeList()
          Gets the attribute list of this node
 java.util.Vector getAttrKeysVector()
          Gets the attribute keys as a Vector
 int getChildCount()
          Gets the number of children for this node
 XMLNode getChildNode(java.lang.String s)
          Gets the child node with tag name childName.
 java.util.Vector getChildNodes()
          Gets all the children under this node
 java.lang.String getNodeName()
          Gets the name of the node
 int getNodeType()
          Gets the node type, For eg: ELEMENT
 java.lang.String getNodeValue()
          Gets the value of the node.
 XMLNode getParentNode()
          Gets the parent node for this node.
 boolean isLeaf()
           
 void removeAttribute(java.lang.String attrName)
          Method to remove a attribute from the attribute list if an entry exists with this attrName as a key
 int removeFromParent()
           
 void setAttribute(java.lang.String attrName, java.lang.Object attrValue)
          Sets the attrName and a value which is an Object type data in the the attribute list for this node.
 void setAttribute(java.lang.String attrName, java.lang.String attrValue)
          Sets the attrName and attrValue in the attribute list for this node.
 void setAttributeList(java.util.Hashtable attrList)
          Sets a attribute list for this node
 void setChildNodes(java.util.Vector childNodesV)
          Sets the children for this node as a Vector
 void setNodeName(java.lang.String nName)
          Sets the name of the node
 void setNodeType(int nType)
          Sets the node's type
 void setNodeValue(java.lang.String nValue)
          Sets a value for the node.
 void setParentNode(XMLNode pNode)
          Sets the parent node for this node
 java.lang.String toString()
          Returns the node name of this node
 
Methods inherited from class java.lang.Object
, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ELEMENT

public static final int ELEMENT
Element Node

DOCUMENT

public static final int DOCUMENT
Document Node

ENTITYREF

public static final int ENTITYREF
Entity Reference

COMMENT

public static final int COMMENT
Comment Node

PCDATA

public static final int PCDATA

CDATA

public static final int CDATA

attrNameVector

java.util.Vector attrNameVector
Constructor Detail

XMLNode

public XMLNode()
Constructor to create a new instance of XMLNode
Method Detail

getNodeType

public int getNodeType()
Gets the node type, For eg: ELEMENT

setNodeType

public void setNodeType(int nType)
Sets the node's type

getNodeValue

public java.lang.String getNodeValue()
Gets the value of the node. For a comment node, this method will return the comment text.
Returns:
returns null for ELEMENT node.

setNodeValue

public void setNodeValue(java.lang.String nValue)
Sets a value for the node.

getNodeName

public java.lang.String getNodeName()
Gets the name of the node

setNodeName

public void setNodeName(java.lang.String nName)
Sets the name of the node

getAttributeList

public java.util.Hashtable getAttributeList()
Gets the attribute list of this node

setAttributeList

public void setAttributeList(java.util.Hashtable attrList)
Sets a attribute list for this node

getChildNodes

public java.util.Vector getChildNodes()
Gets all the children under this node

getChildNode

public XMLNode getChildNode(java.lang.String s)
Gets the child node with tag name childName. It will just search one level below ie only among this nodes children.

setChildNodes

public void setChildNodes(java.util.Vector childNodesV)
Sets the children for this node as a Vector

getParentNode

public XMLNode getParentNode()
Gets the parent node for this node.

setParentNode

public void setParentNode(XMLNode pNode)
Sets the parent node for this node

getAttribute

public java.lang.Object getAttribute(java.lang.String attrName)
Gets the value of the attribute for the specified attrName

getAttrKeysVector

public java.util.Vector getAttrKeysVector()
Gets the attribute keys as a Vector

setAttribute

public void setAttribute(java.lang.String attrName,
                         java.lang.String attrValue)
Sets the attrName and attrValue in the attribute list for this node.

setAttribute

public void setAttribute(java.lang.String attrName,
                         java.lang.Object attrValue)
Sets the attrName and a value which is an Object type data in the the attribute list for this node.

removeAttribute

public void removeAttribute(java.lang.String attrName)
Method to remove a attribute from the attribute list if an entry exists with this attrName as a key

addChildNode

public void addChildNode(XMLNode childNode)
Adds a node as a child node to this node.

deleteNode

public void deleteNode()
Deletes all the children of this node

deleteChildNode

public void deleteChildNode(XMLNode node)
Deletes the specified node from the childList

isLeaf

public boolean isLeaf()

removeFromParent

public int removeFromParent()

getChildCount

public int getChildCount()
Gets the number of children for this node

children

public java.util.Enumeration children()
Returns an Enumeration of child nodes

clone

public java.lang.Object clone()
Clones the XML node along with its children
Overrides:
clone in class java.lang.Object
Returns:
a duplicate instance of this XMLNode.

toString

public java.lang.String toString()
Returns the node name of this node
Overrides:
toString in class java.lang.Object