Hilbert II - Version 0.03.04

org.qedeq.kernel.xml.tracker
Class SimpleXPath

java.lang.Object
  extended byorg.qedeq.kernel.xml.tracker.SimpleXPath

public class SimpleXPath
extends Object

Simple XPath like description of a location in an XML file.

Version:
$Revision: 1.14 $

Constructor Summary
SimpleXPath()
          Empty constructor.
SimpleXPath(SimpleXPath original)
          Copy constructor.
SimpleXPath(String xpath)
          Constructor with simple XPath string as parameter.
 
Method Summary
 void addElement(String elementName)
          Add new element to end of XPath.
 void addElement(String elementName, int occurrence)
          Add new element to end of XPath.
 void deleteLastElement()
          Delete last XPath element if any.
 boolean equals(Object obj)
           
 boolean equalsElements(SimpleXPath other)
          Are the elements and occurrences of this and another element equal?
 String getAttribute()
          Get attribute.
 String getBeforeLastElement()
          Get XPath element name before last.
 String getElementName(int i)
          Get i-th Element name.
 int getElementOccurrence(int i)
          Get i-th occurrence number.
 SourcePosition getEndLocation()
          Get end location.
 String getLastElement()
          Get last XPath element name.
 SourcePosition getStartLocation()
          Get start location.
 int hashCode()
           
 boolean matchesElements(SimpleXPath current, SimpleXPath currentSummary)
          Match the elements and occurrences of this finder object and current elements?
 boolean matchesElementsBegining(SimpleXPath current, SimpleXPath currentSummary)
          Match the elements and occurrences of this finder object and current elements?
 void setAttribute(String attribute)
          Set attribute.
 void setEndLocation(SourcePosition position)
          Set ending location of XPath.
 void setStartLocation(SourcePosition position)
          Set starting location of XPath.
 int size()
          Get number of collected exceptions.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimpleXPath

public SimpleXPath(String xpath)
Constructor with simple XPath string as parameter. This is not the standard XPath definition but it is similar to a subset of the abbreviation XPath notation.

/element1/element2[3]@attribute is an example for such a notation. This selects from the first occurrence of element1 and from the third occurrence of subnode element2 the attribute attribute. The attribute is optional. It is always exactly one node or the attribute of one node specified.

The general syntax could be described as follows: {"/"element"["index"]"}+ ["@"attribute]

Parameters:
xpath - String with the syntax as described above. If the syntax is violated RuntimeExceptions may occur.

SimpleXPath

public SimpleXPath()
Empty constructor.


SimpleXPath

public SimpleXPath(SimpleXPath original)
Copy constructor.

Parameters:
original - XPath to copy.
Method Detail

size

public final int size()
Get number of collected exceptions.

Returns:
Number of collected exceptions.

getElementName

public final String getElementName(int i)
Get i-th Element name.

Parameters:
i - Starts with 0 and must be smaller than size().
Returns:
Wanted element name.

getElementOccurrence

public final int getElementOccurrence(int i)
Get i-th occurrence number.

Parameters:
i - Starts with 0 and must be smaller than size().
Returns:
Wanted element occurrence number.

addElement

public final void addElement(String elementName)
Add new element to end of XPath.

Parameters:
elementName - element to add.

addElement

public final void addElement(String elementName,
                             int occurrence)
Add new element to end of XPath.

Parameters:
elementName - element to add.
occurrence - Occurrence number of element. Starts with 1.

getLastElement

public final String getLastElement()
Get last XPath element name.

Returns:
Last element name. Could be null if no elements exist.

getBeforeLastElement

public final String getBeforeLastElement()
Get XPath element name before last.

Returns:
Before last element name. Could be null if no more than one element exist.

deleteLastElement

public void deleteLastElement()
Delete last XPath element if any.


setAttribute

public final void setAttribute(String attribute)
Set attribute.

Parameters:
attribute - Attribute, maybe null.

getAttribute

public final String getAttribute()
Get attribute.

Returns:
Attribute, maybe null.

setStartLocation

public final void setStartLocation(SourcePosition position)
Set starting location of XPath.

Parameters:
position - Starting point of this XPath.

getStartLocation

public final SourcePosition getStartLocation()
Get start location.

Returns:
File position.

setEndLocation

public final void setEndLocation(SourcePosition position)
Set ending location of XPath.

Parameters:
position - Ending point of this XPath.

getEndLocation

public final SourcePosition getEndLocation()
Get end location.

Returns:
File position.

equals

public final boolean equals(Object obj)

equalsElements

public final boolean equalsElements(SimpleXPath other)
Are the elements and occurrences of this and another element equal? No special treatment of "*" elements.

Parameters:
other - Compare with this object.
Returns:
Are the elements of this and the parameter object equal?

matchesElements

public final boolean matchesElements(SimpleXPath current,
                                     SimpleXPath currentSummary)
Match the elements and occurrences of this finder object and current elements? This object may contain "*" elements.

Parameters:
current - Compare with this current elements. These elements should not contain "*" elements.
currentSummary - Contains only "*" elements. This parameter must be identify the same XPath as current
Returns:
Match the elements of this finder object and the parameter objects?

matchesElementsBegining

public final boolean matchesElementsBegining(SimpleXPath current,
                                             SimpleXPath currentSummary)
Match the elements and occurrences of this finder object and current elements? This object may contain "*" elements. Checks only to current.size().

Parameters:
current - Compare with this current elements. These elements should not contain "*" elements.
currentSummary - Contains only "*" elements. This parameter must be identify the same XPath as current
Returns:
Match the elements of this finder object and the parameter objects?

toString

public final String toString()

hashCode

public final int hashCode()

Hilbert II - Version 0.03.04

©left GNU General Public Licence
All Rights Reserved.