/** Sets the sort to the given criteria in succession: the * first SortField is checked first, but if it produces a * tie, then the second SortField is used to break the tie, * etc. Finally, if there is still a tie after all SortFields * are checked, the internal Lucene docid is used to break it. */ public Sort(SortField... fields) { setSort(fields); }
/** Sorts by the criteria in the given SortField. */ public Sort(SortField field) { setSort(field); }
public Sort toSort(List<? extends OrderSpecifier<?>> orderBys) { List<SortField> sorts = new ArrayList<SortField>(orderBys.size()); for (OrderSpecifier<?> order : orderBys) { if (!(order.getTarget() instanceof Path<?>)) { throw new IllegalArgumentException("argument was not of type Path."); } Class<?> type = order.getTarget().getType(); boolean reverse = !order.isAscending(); Path<?> path = getPath(order.getTarget()); if (Number.class.isAssignableFrom(type)) { sorts.add(new SortField(toField(path), sortFields.get(type), reverse)); } else { sorts.add(new SortField(toField(path), sortLocale, reverse)); } } Sort sort = new Sort(); sort.setSort(sorts.toArray(new SortField[sorts.size()])); return sort; } }
public Sort toSort(List<? extends OrderSpecifier<?>> orderBys) { List<SortField> sorts = new ArrayList<SortField>(orderBys.size()); for (OrderSpecifier<?> order : orderBys) { if (!(order.getTarget() instanceof Path<?>)) { throw new IllegalArgumentException("argument was not of type Path."); } Class<?> type = order.getTarget().getType(); boolean reverse = !order.isAscending(); Path<?> path = getPath(order.getTarget()); if (Number.class.isAssignableFrom(type)) { sorts.add(new SortField(toField(path), sortFields.get(type), reverse)); } else { sorts.add(new SortField(toField(path), SortField.Type.STRING, reverse)); } } Sort sort = new Sort(); sort.setSort(sorts.toArray(new SortField[sorts.size()])); return sort; } }
public Sort toSort(List<? extends OrderSpecifier<?>> orderBys) { List<SortField> sorts = new ArrayList<SortField>(orderBys.size()); for (OrderSpecifier<?> order : orderBys) { if (!(order.getTarget() instanceof Path<?>)) { throw new IllegalArgumentException( "argument was not of type Path."); } Class<?> type = order.getTarget().getType(); boolean reverse = !order.isAscending(); Path<?> path = getPath(order.getTarget()); if (Number.class.isAssignableFrom(type)) { sorts.add(new SortedNumericSortField(toField(path), sortFields.get(type), reverse)); } else { sorts.add(new SortField(toField(path), SortField.Type.STRING, reverse)); } } Sort sort = new Sort(); sort.setSort(sorts.toArray(new SortField[sorts.size()])); return sort; } }
/** Sets the sort to the given criteria in succession: the * first SortField is checked first, but if it produces a * tie, then the second SortField is used to break the tie, * etc. Finally, if there is still a tie after all SortFields * are checked, the internal Lucene docid is used to break it. */ public Sort(SortField... fields) { setSort(fields); }
/** Sorts by the terms in <code>field</code> then by index order (document * number). The type of value in <code>field</code> is determined * automatically. * @see SortField#AUTO */ public Sort (String field) { setSort (field, false); }
/** * Sets the sort to the terms in <code>field</code> then by index order * (document number). */ public final void setSort(String field) { setSort(field, false); }
/** * Sorts by the terms in <code>field</code> then by index order (document * number). The type of value in <code>field</code> is determined * automatically. * * @see SortField#AUTO */ public Sort(String field) { setSort(field, false); }
/** * Sorts in succession by the terms in each field. The type of value in * <code>field</code> is determined automatically. * * @see SortField#AUTO */ public Sort(String[] fields) { setSort(fields); }
/** Sorts in succession by the terms in each field. * The type of value in <code>field</code> is determined * automatically. * @see SortField#AUTO */ public Sort (String[] fields) { setSort (fields); }
/** Sets the sort to the terms in <code>field</code> then by index order * (document number). */ public final void setSort (String field) { setSort (field, false); }
/** * Sorts possibly in reverse by the terms in <code>field</code> then by * index order (document number). The type of value in <code>field</code> is * determined automatically. * * @see SortField#AUTO */ public Sort(String field, boolean reverse) { setSort(field, reverse); }
/** * Sorts in succession by the terms in each field. The type of value in * <code>field</code> is determined automatically. * * @see SortField#AUTO */ public Sort(String[] fields) { setSort(fields); }
/** * Sets the sort to the terms in <code>field</code> then by index order * (document number). */ public final void setSort(String field) { setSort(field, false); }
/** Sorts in succession by the criteria in each SortField. */ public Sort (SortField[] fields) { setSort (fields); }
/** Sorts by the criteria in the given SortField. */ public Sort(SortField field) { setSort(field); }
/** Sorts in succession by the criteria in each SortField. */ public Sort(SortField[] fields) { setSort(fields); }
@Override public Sort readObject(final ObjectInput input) throws IOException, ClassNotFoundException { final int count = UnsignedNumeric.readUnsignedInt(input); SortField[] sortfields = new SortField[count]; for (int i = 0; i < count; i++) { sortfields[i] = LuceneSortFieldExternalizer.readObjectStatic(input); } Sort sort = new Sort(); sort.setSort(sortfields); return sort; }
@Override public Sort readObject(final ObjectInput input) throws IOException, ClassNotFoundException { final int count = UnsignedNumeric.readUnsignedInt(input); SortField[] sortfields = new SortField[count]; for (int i=0; i<count; i++) { sortfields[i] = LuceneSortFieldExternalizer.readObjectStatic(input); } Sort sort = new Sort(); sort.setSort(sortfields); return sort; }