public class Dom4jNodeListComparator
extends java.lang.Object
implements java.util.Comparator
List sortedList = document.selectNodes("/ListSets/set","setName");| Modifier and Type | Field and Description |
|---|---|
static int |
ASCENDING
Sort ascending.
|
static int |
DESCENDING
Sort descending.
|
| Constructor and Description |
|---|
Dom4jNodeListComparator(java.lang.String xPath)
Default constructor that sorts descending.
|
Dom4jNodeListComparator(java.lang.String xPath,
int sortOrder)
Constructor that allows setting the sort order by ascending or descending.
|
| Modifier and Type | Method and Description |
|---|---|
int |
compare(java.lang.Object o1,
java.lang.Object o2)
Compares two dom4j Nodes for sorting by an xPath.
|
public static final int ASCENDING
public static final int DESCENDING
public Dom4jNodeListComparator(java.lang.String xPath,
int sortOrder)
sortOrder - The order for sorting (ASCENDING or DESCENDING)xPath - An xPath relative to the node rootASCENDING,
DESCENDINGpublic Dom4jNodeListComparator(java.lang.String xPath)
xPath - An xPath relative to the node rootpublic int compare(java.lang.Object o1,
java.lang.Object o2)
Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
compare in interface java.util.Comparatoro1 - The first Object.o2 - The second Object.