private Object getOrderByEvaluatedTuple(ExecutionContext context, boolean isOrderByTupleSingle, Object[] holder, Object data, boolean[] objectChangedMarker) { if (isOrderByTupleSingle) { return PDXUtils.convertPDX(this.orderByAttrs.get(0).evaluate(data, context), false, true, true, true, objectChangedMarker, false); } else { int i = 0; for (CompiledSortCriterion csc : this.orderByAttrs) { holder[i++] = PDXUtils.convertPDX(csc.evaluate(data, context), false, true, true, true, objectChangedMarker, false); } return holder; } }
/** * This method evaluates sort criteria and returns an ArrayList of Object[] arrays of the * evaluated criteria. * * @param value the criteria to be evaluated. * @return an Object array of Object arrays of the evaluated criteria. */ protected Object[] evaluateSortCriteria(Object value) { Object[] array = null; if (orderByAttrs != null) { array = new Object[orderByAttrs.size()]; int i = 0; for (CompiledSortCriterion csc : orderByAttrs) { Object[] arr = {csc.evaluate(value, context), csc.getCriterion()}; array[i++] = arr; } } return array; }
private Object[] calculateSortCriteria(ExecutionContext context, Object row) throws FunctionDomainException, TypeMismatchException, NameResolutionException, QueryInvocationTargetException { if (orderByAttrs != null) { Object[] evaluatedResult = new Object[this.orderByAttrs.size()]; int index = 0; for (CompiledSortCriterion csc : orderByAttrs) { Object[] arr = new Object[2]; if (csc.getColumnIndex() == -1) { arr[0] = csc.evaluate(context); } else { arr[0] = csc.evaluate(row, context); } arr[1] = csc.getCriterion(); evaluatedResult[index++] = arr; } return evaluatedResult; } return null; } }
/** * This method evaluates sort criteria and returns the resulting integer value of comparing the * two objects passed into it based on these criteria. * * @param value1 the first object to be compared. * @param value2 the second object to be compared. * @return a negative integer, zero, or a positive integer if the first argument is less than, * equal to, or greater than the second, based on the evaluated sort criteria. */ protected int evaluateSortCriteria(Object value1, Object value2) { int result = -1; if (orderByAttrs != null) { for (CompiledSortCriterion csc : orderByAttrs) { Object sortCriteriaForValue1 = csc.evaluate(value1, context); Object sortCriteriaForValue2 = csc.evaluate(value2, context); result = compareHelperMethod(sortCriteriaForValue1, sortCriteriaForValue2); if (result != 0) { if (csc.getCriterion()) { result *= -1; } break; } } } return result; }