org.apache.commons.jelly.xpath
Class XPathComparator
java.lang.Object
org.apache.commons.jelly.xpath.XPathComparator
- All Implemented Interfaces:
- java.util.Comparator
public class XPathComparator
- extends java.lang.Object
- implements java.util.Comparator
Compares xml nodes by extracting the value at xpath and
comparing it.
- Version:
- $Id: XPathComparator.java 1807798 2017-09-08 18:43:34Z chtompki $
- Author:
- Jason Horman
Field Summary |
private boolean |
descending
Sort descending or ascending |
private org.jaxen.XPath |
xpath
The xpath to use to extract value from nodes to compare |
Method Summary |
int |
compare(org.dom4j.Node n1,
org.dom4j.Node n2)
|
int |
compare(java.lang.Object o1,
java.lang.Object o2)
|
protected java.lang.Comparable |
getComparableValue(java.lang.Object value)
Turns the XPath result value into a Comparable object. |
org.jaxen.XPath |
getXpath()
|
void |
setDescending(boolean descending)
|
void |
setXpath(org.jaxen.XPath xpath)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.util.Comparator |
equals |
xpath
private org.jaxen.XPath xpath
- The xpath to use to extract value from nodes to compare
descending
private boolean descending
- Sort descending or ascending
XPathComparator
public XPathComparator()
XPathComparator
public XPathComparator(org.jaxen.XPath xpath,
boolean descending)
setXpath
public void setXpath(org.jaxen.XPath xpath)
getXpath
public org.jaxen.XPath getXpath()
setDescending
public void setDescending(boolean descending)
compare
public int compare(java.lang.Object o1,
java.lang.Object o2)
- Specified by:
compare
in interface java.util.Comparator
compare
public int compare(org.dom4j.Node n1,
org.dom4j.Node n2)
getComparableValue
protected java.lang.Comparable getComparableValue(java.lang.Object value)
- Turns the XPath result value into a Comparable object.