public int compare(Node n1, Node n2) { try { // apply the xpaths. not using stringValueOf since I don't // want all of the child nodes appended to the strings Object val1 = xpath.evaluate(n1); Object val2 = xpath.evaluate(n2); // return if null if (val1 == null || val2 == null) { return val1 == null ? (val2 == null ? 1 : -1) : 1; } Comparable c1 = getComparableValue(val1); Comparable c2 = getComparableValue(val2); // compare descending or ascending if (!descending) { return c1.compareTo(c2); } else { return c2.compareTo(c1); } } catch (JaxenException e) { throw new XPathSortException("error sorting nodes", e); } }
public int compare(Node n1, Node n2) { try { // apply the xpaths. not using stringValueOf since I don't // want all of the child nodes appended to the strings Object val1 = xpath.evaluate(n1); Object val2 = xpath.evaluate(n2); // return if null if (val1 == null || val2 == null) { return val1 == null ? (val2 == null ? 1 : -1) : 1; } Comparable c1 = getComparableValue(val1); Comparable c2 = getComparableValue(val2); // compare descending or ascending if (!descending) { return c1.compareTo(c2); } else { return c2.compareTo(c1); } } catch (JaxenException e) { throw new XPathSortException("error sorting nodes", e); } }
public int compare(Node n1, Node n2) { try { // apply the xpaths. not using stringValueOf since I don't // want all of the child nodes appended to the strings Object val1 = xpath.evaluate(n1); Object val2 = xpath.evaluate(n2); // return if null if (val1 == null || val2 == null) { return val1 == null ? (val2 == null ? 1 : -1) : 1; } Comparable c1 = getComparableValue(val1); Comparable c2 = getComparableValue(val2); // compare descending or ascending if (!descending) { return c1.compareTo(c2); } else { return c2.compareTo(c1); } } catch (XPathException e) { throw new XPathSortException("error sorting nodes", e); } }
public int compare(Node n1, Node n2) { try { // apply the xpaths. not using stringValueOf since I don't // want all of the child nodes appended to the strings Object val1 = xpath.evaluate(n1); Object val2 = xpath.evaluate(n2); // return if null if (val1 == null || val2 == null) { return val1 == null ? (val2 == null ? 1 : -1) : 1; } Comparable c1 = getComparableValue(val1); Comparable c2 = getComparableValue(val2); // compare descending or ascending if (!descending) { return c1.compareTo(c2); } else { return c2.compareTo(c1); } } catch (JaxenException e) { throw new XPathSortException("error sorting nodes", e); } }