org.qedeq.kernel.xml.tracker
Class SimpleXPath

java.lang.Object
  extended by org.qedeq.kernel.xml.tracker.SimpleXPath

public class SimpleXPath
extends java.lang.Object

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

Author:
Michael Meyling

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

Constructor Detail

SimpleXPath

public SimpleXPath(java.lang.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 java.lang.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(java.lang.String elementName)
Add new element to end of XPath.

Parameters:
elementName - element to add.

addElement

public final void addElement(java.lang.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 java.lang.String getLastElement()
Get last XPath element name.

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

getBeforeLastElement

public final java.lang.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(java.lang.String attribute)
Set attribute.

Parameters:
attribute - Attribute, maybe null.

getAttribute

public final java.lang.String getAttribute()
Get attribute.

Returns:
Attribute, maybe null.

equals

public final boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

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 java.lang.String toString()
Overrides:
toString in class java.lang.Object

hashCode

public final int hashCode()
Overrides:
hashCode in class java.lang.Object


Copyright © 2014. All Rights Reserved.