@Override protected Comparable<ValueComparableWrapper> sortValue(int doc) { try { final String uuid = getUUIDForIndex(doc); final Node n = session.getNodeByIdentifier(uuid); final Value[] v = evaluator.getValues(ordering.getOperand(), n); return new ValueComparableWrapper(v); } catch (Exception e) { e.printStackTrace(); } return null; } }
private void append(Ordering[] orderings) { String comma = ""; for (Ordering ordering : orderings) { append(comma); comma = ", "; append(ordering.getOperand()); if (JCR_ORDER_DESCENDING.equals(ordering.getOrder())) { append(" DESC"); } } }
private void append(Ordering[] orderings) { String comma = ""; for (Ordering ordering : orderings) { append(comma); comma = ", "; append(ordering.getOperand()); if (JCR_ORDER_DESCENDING.equals(ordering.getOrder())) { append(" DESC"); } } }
private void append(Ordering[] orderings) { String comma = ""; for (Ordering ordering : orderings) { append(comma); comma = ", "; append(ordering.getOperand()); if (JCR_ORDER_DESCENDING.equals(ordering.getOrder())) { append(" DESC"); } } }
@Override protected Comparable<ValueComparableWrapper> sortValue(int doc) { try { final String uuid = getUUIDForIndex(doc); final Node n = session.getNodeByIdentifier(uuid); final Value[] v = evaluator.getValues(ordering.getOperand(), n); return new ValueComparableWrapper(v); } catch (Exception e) { e.printStackTrace(); } return null; } }
public int compare(Row a, Row b) { try { for (Ordering ordering : orderings) { Operand operand = ordering.getOperand(); Value[] va = evaluator.getValues(operand, a); Value[] vb = evaluator.getValues(operand, b); int d = comparator.compare(va, vb); if (d != 0) { if (JCR_ORDER_DESCENDING.equals(ordering.getOrder())) { return -d; } else { return d; } } } return 0; } catch (RepositoryException e) { throw new RuntimeException("Unable to compare rows " + a + " and " + b, e); } } }
public int compare(Row a, Row b) { try { for (Ordering ordering : orderings) { Operand operand = ordering.getOperand(); Value[] va = evaluator.getValues(operand, a); Value[] vb = evaluator.getValues(operand, b); int d = comparator.compare(va, vb); if (d != 0) { if (JCR_ORDER_DESCENDING.equals(ordering.getOrder())) { return -d; } else { return d; } } } return 0; } catch (RepositoryException e) { throw new RuntimeException("Unable to compare rows " + a + " and " + b, e); } } }
/** * Test case for {@link QueryObjectModelFactory#descending(DynamicOperand)} */ public void testOrderingDescending() throws RepositoryException { PropertyValue op = qf.propertyValue(SELECTOR_NAME1, propertyName1); Ordering desc = qf.descending(op); assertEquals("Ordering.getOrder() must return QueryObjectModelConstants.ORDER_DESCENDING", QueryObjectModelConstants.JCR_ORDER_DESCENDING, desc.getOrder()); assertTrue("Not a PropertyValue operand", desc.getOperand() instanceof PropertyValue); }
/** * Test case for {@link QueryObjectModelFactory#ascending(DynamicOperand)} */ public void testOrderingAscending() throws RepositoryException { PropertyValue op = qf.propertyValue(SELECTOR_NAME1, propertyName1); Ordering asc = qf.ascending(op); assertEquals("Ordering.getOrder() must return QueryObjectModelConstants.ORDER_ASCENDING", QueryObjectModelConstants.JCR_ORDER_ASCENDING, asc.getOrder()); assertTrue("Not a PropertyValue operand", asc.getOperand() instanceof PropertyValue); }
@Test public void descending() throws RepositoryException { PropertyValue p = f.propertyValue("selectorName", "propertyName"); Ordering o = f.descending(p); assertEquals(p, o.getOperand()); assertEquals(QueryObjectModelConstants.JCR_ORDER_DESCENDING, o.getOrder()); assertEquals("[selectorName].[propertyName] DESC", o.toString()); }
@Test public void ascending() throws RepositoryException { PropertyValue p = f.propertyValue("selectorName", "propertyName"); Ordering o = f.ascending(p); assertEquals(p, o.getOperand()); assertEquals(QueryObjectModelConstants.JCR_ORDER_ASCENDING, o.getOrder()); assertEquals("[selectorName].[propertyName]", p.toString()); }