com.codemonster.surinam.parser
Class TreeWalker

java.lang.Object
  extended by com.codemonster.surinam.parser.TreeWalker

public class TreeWalker
extends Object

User: sam Date: Aug 20, 2007 Time: 10:16:54 AM


Constructor Summary
TreeWalker(Document xmlDoc)
           
 
Method Summary
 float getFloat(XPath path, String tagname)
           
 int getInt(XPath path, String tagname)
           
 long getLong(XPath path, String tagname)
           
 XNode getNode(XPath path, String tagname)
           
 List<XNode> getNodeList(XPath path, String tagname)
          For the given path, finds all the elements matching the given tag name.
static List<XNode> getRelativeNodeList(XNode rootNode, XPath path, String tagName)
          Treats the given root node as the root of a sub-tree and follows the given path to the end.
 String getString(XPath path, String tagname)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TreeWalker

public TreeWalker(Document xmlDoc)
Method Detail

getString

public String getString(XPath path,
                        String tagname)
                 throws ElementDoesNotExistException
Throws:
ElementDoesNotExistException

getLong

public long getLong(XPath path,
                    String tagname)
             throws ElementDoesNotExistException
Throws:
ElementDoesNotExistException

getFloat

public float getFloat(XPath path,
                      String tagname)
               throws ElementDoesNotExistException
Throws:
ElementDoesNotExistException

getInt

public int getInt(XPath path,
                  String tagname)
           throws ElementDoesNotExistException
Throws:
ElementDoesNotExistException

getNode

public XNode getNode(XPath path,
                     String tagname)
              throws ElementDoesNotExistException
Throws:
ElementDoesNotExistException

getNodeList

public List<XNode> getNodeList(XPath path,
                               String tagname)
                        throws ElementDoesNotExistException
For the given path, finds all the elements matching the given tag name.

Parameters:
path - This is the path to follow to get to the correct scope to develop the list.
tagname - The element name on which the search will be conducted.
Returns:
Returns all the elements matching the given tag name.
Throws:
ElementDoesNotExistException - Thrown if the given tag name doesn't exist.

getRelativeNodeList

public static List<XNode> getRelativeNodeList(XNode rootNode,
                                              XPath path,
                                              String tagName)
                                       throws ElementDoesNotExistException
Treats the given root node as the root of a sub-tree and follows the given path to the end. Then it finds all the elements matching the given tag name that are children of that node. If the tagName is given with the wildcard '*', all children of this node will be returned.

Parameters:
rootNode - The node, below which, the search for matches will be scoped.
path - The relative path from the given root node to the sub-node that will further scope the search.
tagName - The element name on which the search will be conducted.
Returns:
Returns a list of XNode children of the given node.
Throws:
ElementDoesNotExistException - Thrown if the given tag name doesn't exist.


Copyright © 2010. All Rights Reserved.