Class XPathTracker

java.lang.Object
  extended by XPathTracker

public class XPathTracker
extends java.lang.Object

This class is used to keep track of the position in an XML document e.g. during SAX Parsing. Internal representation format is a (very small) subset of XPath. Main advantage over a full-fledged implementation of XPath is high performance.

Version:
0.1, November 2007
Author:
Johannes Dellert

Constructor Summary
XPathTracker()
          builds a new XPath tracker, starting with an empty path
 
Method Summary
 boolean atPath(java.lang.String thePath)
          check whether the XPathTracker is at a path the path to check for can consist of a disjunction (by the | symbol) of XPaths and each of the XPaths can contain one occurrence of ".." designating an arbitrary number of intermediary levels
 void goToAttribute(java.lang.String dir)
          move position along the attribute axis
 void goToElement(java.lang.String dir)
          move position to a subelement
 void levelUp()
          move position up one level
 java.lang.String toString()
          get info about the present position (for debugging purposes)
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XPathTracker

public XPathTracker()
builds a new XPath tracker, starting with an empty path

Method Detail

goToAttribute

public void goToAttribute(java.lang.String dir)
move position along the attribute axis

Parameters:
dir - - the name of the attribute

goToElement

public void goToElement(java.lang.String dir)
move position to a subelement

Parameters:
dir - - the name of the element

levelUp

public void levelUp()
move position up one level


atPath

public boolean atPath(java.lang.String thePath)
check whether the XPathTracker is at a path the path to check for can consist of a disjunction (by the | symbol) of XPaths and each of the XPaths can contain one occurrence of ".." designating an arbitrary number of intermediary levels

Parameters:
thePath - - the path we want to check for
Returns:
- true if thePath matches the current position of the tracker, false otherwise

toString

public java.lang.String toString()
get info about the present position (for debugging purposes)

Overrides:
toString in class java.lang.Object
Returns:
- info about the present position in internal XPath notation