@Test public void testDescGreaterThan() throws Exception { order.addElement(desc); cmp.setIterator(Arrays.asList(POS).iterator()); OrderComparator sud = new OrderComparator(strategy, order, cmp); assertTrue(sud.compare(null, null) < 0); }
@Override public int compare(BindingSet o1, BindingSet o2) { try { for (OrderElem element : order.getElements()) { Value v1 = evaluate(element.getExpr(), o1); Value v2 = evaluate(element.getExpr(), o2); int compare = cmp.compare(v1, v2); if (compare != 0) { return element.isAscending() ? compare : -compare; } } if (o1 == null || o2 == null) { if (o1 == null) { return o2 == null ? 0 : 1; } if (o2 == null) { return o1 == null ? 0 : -1; } } if (o2.size() != o1.size()) { return o1.size() < o2.size() ? 1 : -1; } final ArrayList<String> o1bindingNamesOrdered = new ArrayList<>(o1.getBindingNames()); Collections.sort(o1bindingNamesOrdered); if (!o1.getBindingNames().equals(o2.getBindingNames())) { final ArrayList<String> o2bindingNamesOrdered = new ArrayList<>(o2.getBindingNames()); Collections.sort(o2bindingNamesOrdered); for (int i = 0; i < o1bindingNamesOrdered.size(); i++) { String o1bn = o1bindingNamesOrdered.get(i); String o2bn = o2bindingNamesOrdered.get(i); int compare = o1bn.compareTo(o2bn); if (compare != 0) { return compare; } } } for (String bindingName : o1bindingNamesOrdered) { final Value v1 = o1.getValue(bindingName); final Value v2 = o2.getValue(bindingName); final int compare = cmp.compare(v1, v2); if (compare != 0) { return compare; } } return 0; } catch (QueryEvaluationException e) { logger.debug(e.getMessage(), e); return 0; } catch (IllegalArgumentException e) { logger.debug(e.getMessage(), e); return 0; } }
OrderComparator implements Comparator<BindingSet>, Serializable { @Override public int compare(BindingSet o1, BindingSet o2) { try { for (OrderElem element : order.getElements()) { Value v1 = evaluate(element.getExpr(), o1); Value v2 = evaluate(element.getExpr(), o2); int compare = cmp.compare(v1, v2); if (compare != 0) { return element.isAscending() ? compare : -compare; } } if (o1 == null || o2 == null) { if (o1 == null) { return o2 == null ? 0 : 1; } if (o2 == null) { return o1 == null ? 0 : -1; } } if (o2.size() != o1.size()) { return o1.size() < o2.size() ? 1 : -1; } final ArrayList<String> o1bindingNamesOrdered = new ArrayList<>(o1.getBindingNames()); Collections.sort(o1bindingNamesOrdered); if (!o1.getBindingNames().equals(o2.getBindingNames())) { final ArrayList<String> o2bindingNamesOrdered = new ArrayList<>(o2.getBindingNames()); Collections.sort(o2bindingNamesOrdered); for (int i = 0; i < o1bindingNamesOrdered.size(); i++) { String o1bn = o1bindingNamesOrdered.get(i); String o2bn = o2bindingNamesOrdered.get(i); int compare = o1bn.compareTo(o2bn); if (compare != 0) { return compare; } } } for (String bindingName : o1bindingNamesOrdered) { final Value v1 = o1.getValue(bindingName); final Value v2 = o2.getValue(bindingName); final int compare = cmp.compare(v1, v2); if (compare != 0) { return compare; } } return 0; } catch (QueryEvaluationException e) { logger.debug(e.getMessage(), e); return 0; } catch (IllegalArgumentException e) { logger.debug(e.getMessage(), e); return 0; } } }
OrderComparator implements Comparator<BindingSet>, Serializable { @Override public int compare(BindingSet o1, BindingSet o2) { try { for (OrderElem element : order.getElements()) { Value v1 = evaluate(element.getExpr(), o1); Value v2 = evaluate(element.getExpr(), o2); int compare = cmp.compare(v1, v2); if (compare != 0) { return element.isAscending() ? compare : -compare; } } if (o1 == null || o2 == null) { if (o1 == null) { return o2 == null ? 0 : 1; } if (o2 == null) { return o1 == null ? 0 : -1; } } if (o2.size() != o1.size()) { return o1.size() < o2.size() ? 1 : -1; } final ArrayList<String> o1bindingNamesOrdered = new ArrayList<>(o1.getBindingNames()); Collections.sort(o1bindingNamesOrdered); if (!o1.getBindingNames().equals(o2.getBindingNames())) { final ArrayList<String> o2bindingNamesOrdered = new ArrayList<>(o2.getBindingNames()); Collections.sort(o2bindingNamesOrdered); for (int i = 0; i < o1bindingNamesOrdered.size(); i++) { String o1bn = o1bindingNamesOrdered.get(i); String o2bn = o2bindingNamesOrdered.get(i); int compare = o1bn.compareTo(o2bn); if (compare != 0) { return compare; } } } for (String bindingName : o1bindingNamesOrdered) { final Value v1 = o1.getValue(bindingName); final Value v2 = o2.getValue(bindingName); final int compare = cmp.compare(v1, v2); if (compare != 0) { return compare; } } return 0; } catch (QueryEvaluationException e) { logger.debug(e.getMessage(), e); return 0; } catch (IllegalArgumentException e) { logger.debug(e.getMessage(), e); return 0; } } OrderComparator(EvaluationStrategy strategy, Order order, ValueComparator vcmp); }
OrderComparator implements Comparator<BindingSet>, Serializable { @Override public int compare(BindingSet o1, BindingSet o2) { try { for (OrderElem element : order.getElements()) { Value v1 = evaluate(element.getExpr(), o1); Value v2 = evaluate(element.getExpr(), o2); int compare = cmp.compare(v1, v2); if (compare != 0) { return element.isAscending() ? compare : -compare; } } if (o1 == null || o2 == null) { if (o1 == null) { return o2 == null ? 0 : 1; } if (o2 == null) { return o1 == null ? 0 : -1; } } if (o2.size() != o1.size()) { return o1.size() < o2.size() ? 1 : -1; } final ArrayList<String> o1bindingNamesOrdered = new ArrayList<>(o1.getBindingNames()); Collections.sort(o1bindingNamesOrdered); if (!o1.getBindingNames().equals(o2.getBindingNames())) { final ArrayList<String> o2bindingNamesOrdered = new ArrayList<>(o2.getBindingNames()); Collections.sort(o2bindingNamesOrdered); for (int i = 0; i < o1bindingNamesOrdered.size(); i++) { String o1bn = o1bindingNamesOrdered.get(i); String o2bn = o2bindingNamesOrdered.get(i); int compare = o1bn.compareTo(o2bn); if (compare != 0) { return compare; } } } for (String bindingName : o1bindingNamesOrdered) { final Value v1 = o1.getValue(bindingName); final Value v2 = o2.getValue(bindingName); final int compare = cmp.compare(v1, v2); if (compare != 0) { return compare; } } return 0; } catch (QueryEvaluationException e) { logger.debug(e.getMessage(), e); return 0; } catch (IllegalArgumentException e) { logger.debug(e.getMessage(), e); return 0; } } OrderComparator(EvaluationStrategy strategy, Order order, ValueComparator vcmp); @Override int compare(BindingSet o1, BindingSet o2); }
OrderComparator implements Comparator<BindingSet>, Serializable { @Override public int compare(BindingSet o1, BindingSet o2) { try { for (OrderElem element : order.getElements()) { Value v1 = evaluate(element.getExpr(), o1); Value v2 = evaluate(element.getExpr(), o2); int compare = cmp.compare(v1, v2); if (compare != 0) { return element.isAscending() ? compare : -compare; } } if (o1 == null || o2 == null) { if (o1 == null) { return o2 == null ? 0 : 1; } if (o2 == null) { return o1 == null ? 0 : -1; } } if (o2.size() != o1.size()) { return o1.size() < o2.size() ? 1 : -1; } final ArrayList<String> o1bindingNamesOrdered = new ArrayList<>(o1.getBindingNames()); Collections.sort(o1bindingNamesOrdered); if (!o1.getBindingNames().equals(o2.getBindingNames())) { final ArrayList<String> o2bindingNamesOrdered = new ArrayList<>(o2.getBindingNames()); Collections.sort(o2bindingNamesOrdered); for (int i = 0; i < o1bindingNamesOrdered.size(); i++) { String o1bn = o1bindingNamesOrdered.get(i); String o2bn = o2bindingNamesOrdered.get(i); int compare = o1bn.compareTo(o2bn); if (compare != 0) { return compare; } } } for (String bindingName : o1bindingNamesOrdered) { final Value v1 = o1.getValue(bindingName); final Value v2 = o2.getValue(bindingName); final int compare = cmp.compare(v1, v2); if (compare != 0) { return compare; } } return 0; } catch (QueryEvaluationException e) { logger.debug(e.getMessage(), e); return 0; } catch (IllegalArgumentException e) { logger.debug(e.getMessage(), e); return 0; } } OrderComparator(EvaluationStrategy strategy, Order order, ValueComparator vcmp); @Override int compare(BindingSet o1, BindingSet o2);  }