com.amx.duet.tools.xml
Class XMLNode

java.lang.Object
  extended bycom.amx.duet.tools.xml.XMLNode

public class XMLNode
extends java.lang.Object

The XMLNode class was created to store the contents of XML files into Tag and Attribute objects, but it could also be used to store tag information for HTML tags and other user defined tags.

The XMLNode can be traversed foward by looping through the list of nodes stored at the root, then looping through the individual nodes until null is reached. An XMLNode can also be traversed top-down using the getParent() method until null is reached, which signifies the "root" level.

A Tag is stored at the base level of each XMLNode in the list

Since:
AMXTools 1.0.0
Version:
1.0.2

Constructor Summary
XMLNode()
           
XMLNode(XMLNode nodeParent, Tag data)
          Creates an XML node object with the passed in Tag as its data
 
Method Summary
 void addNode(XMLNode node)
          Adds and entire sub tree as a leaf to the current node
 XMLNode addTag(XMLNode nodeParent, Tag tag)
          Takes the passed in Tag and adds it adds a leaf to the current node.
 void clear()
          Clear all of the nodes listed for this node
 void dump()
          Outputs all of the node data to the print stream
 XMLNode getAbsoluteRoot()
          Retrieves the absolute root node of the entire node tree no matter where current node's position is.
 Tag getData()
          Retrieves the first Tag object from this node
 int getDebugState()
          Gets the current diagnostic state.
 XMLNode getNextNode(java.lang.String name)
          Recursive search through the node leaves for the matching named tag
 XMLNode getNextNode(Tag tag)
          Recursive search through the node leaves for the matching tag
 Tag getNextTag(java.lang.String name)
          Recursive search through the node leaves for the matching named tag
 XMLNode getNode(int index)
          Search through nodes on the same level as this leaf at this index
 XMLNode getNode(java.lang.String name)
          Search through nodes on the current level for a matching tag name.
 XMLNode getNode(Tag tag)
          Search through nodes on the current level for a matching tag.
 java.util.Vector getNodeList(java.lang.String name)
          Retrieve a list of nodes at this level of the tree that match the node name
 java.util.Vector getNodes()
          Retrieve the entire list of nodes for this tag
 XMLNode getParent()
          Retrieve the parent node for this node.
 XMLNode getRoot()
          Retrieves the root node of the entire node tree no matter where current node's position is.
 Tag getTag(int index)
          Search through nodes on the same level as this tag at this index
 Tag getTag(java.lang.String name)
          Search through nodes on the same level as the matching named tag
 void setDebug(boolean bState)
          Deprecated. Do not use this method; use setDebugState instead
 void setDebugState(int nState)
          Puts the class into a debug diagnostic state.
 int size()
          Retrieve the number of nodes for this tag
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLNode

public XMLNode()

XMLNode

public XMLNode(XMLNode nodeParent,
               Tag data)
Creates an XML node object with the passed in Tag as its data

Parameters:
data - the first object in the node
Method Detail

addNode

public void addNode(XMLNode node)
Adds and entire sub tree as a leaf to the current node

Parameters:
node - an XMLNode object containing its own tags and nodes

addTag

public XMLNode addTag(XMLNode nodeParent,
                      Tag tag)
Takes the passed in Tag and adds it adds a leaf to the current node. It then returns the XMLNode object created from this tag so that user can add and retrieve nodes to and from this new leaf.

Parameters:
tag - an XML Tag object
Returns:
an XMLNode object

getNode

public XMLNode getNode(int index)
Search through nodes on the same level as this leaf at this index

Parameters:
index - position of the leaf at this level
Returns:
an XMLNode object

getNode

public XMLNode getNode(java.lang.String name)
Search through nodes on the current level for a matching tag name.

Parameters:
name -
Returns:
an XMLNode object

getNode

public XMLNode getNode(Tag tag)
Search through nodes on the current level for a matching tag.

Parameters:
tag -
Returns:
an XMLNode object

getRoot

public XMLNode getRoot()
Retrieves the root node of the entire node tree no matter where current node's position is.

Note: This method does not retrieve the actual root node, instead it retrieves the node stored in the root node, which was the first node that was added to the tree. If for any reason you require the actual root node, you can call getParent() or getAbsoluteRoot().

Returns:
an XMLNode object

getAbsoluteRoot

public XMLNode getAbsoluteRoot()
Retrieves the absolute root node of the entire node tree no matter where current node's position is. This is the node where the data and parent are both set to null.

Note: This method is rarely used. Use getRoot() instead.

Returns:
an XMLNode object

getTag

public Tag getTag(int index)
Search through nodes on the same level as this tag at this index

Parameters:
index - position of the tag at this level
Returns:
an XML Tag object

getTag

public Tag getTag(java.lang.String name)
Search through nodes on the same level as the matching named tag

Parameters:
name - of tag to search for
Returns:
an XML Tag object

getNextTag

public Tag getNextTag(java.lang.String name)
Recursive search through the node leaves for the matching named tag

Parameters:
name - of tag to search for
Returns:
an XML Tag object

getNextNode

public XMLNode getNextNode(java.lang.String name)
Recursive search through the node leaves for the matching named tag

Parameters:
name - of tag to search for
Returns:
an XMLNode object

getNodeList

public java.util.Vector getNodeList(java.lang.String name)
Retrieve a list of nodes at this level of the tree that match the node name

Parameters:
name - of tag to search for
Returns:
Vector containing a list of all the nodes for this tag

getNextNode

public XMLNode getNextNode(Tag tag)
Recursive search through the node leaves for the matching tag

Parameters:
tag - the Tag to search for
Returns:
an XMLNode object

getParent

public XMLNode getParent()
Retrieve the parent node for this node. The node will be null if this is the root node.

Returns:
an XMLNode object

getData

public Tag getData()
Retrieves the first Tag object from this node

Returns:
an XML Tag object

getNodes

public java.util.Vector getNodes()
Retrieve the entire list of nodes for this tag

Returns:
Vector containing a list of all the nodes for this tag

size

public int size()
Retrieve the number of nodes for this tag

Returns:
int containing the number of nodes for this tag

clear

public void clear()
Clear all of the nodes listed for this node


dump

public void dump()
Outputs all of the node data to the print stream


setDebug

public void setDebug(boolean bState)
Deprecated. Do not use this method; use setDebugState instead

Parameters:
bState -

setDebugState

public void setDebugState(int nState)
Puts the class into a debug diagnostic state.

Parameters:
nState -

getDebugState

public int getDebugState()
Gets the current diagnostic state.

Returns:


Copyright © 2008 AMX LLC. All Rights Reserved.