public int compare(Feature f1, Feature f2) { int result = compareAscending(f1, f2); if (ascending) { return result; } else { return result * -1; } }
public int compare(Info i1, Info i2) { int result = compareAscending(i1, i2); if (ascending) { return result; } else { return result * -1; } }
public int compare(T f1, T f2) { int result = compareAscending(f1, f2); if (ascending) { return result; } else { return result * -1; } }
@Override public FeatureCollection<FeatureType, Feature> sort(SortBy order) { List<Feature> results = new ArrayList<Feature>(features); Comparator<Feature> comparator = ComplexComparatorFactory.buildComparator(order); Collections.sort(results, comparator); return new MemoryFeatureCollection(getSchema(), results); }
/** Builds a composite comparator matching the specified sortBy array */ public static Comparator<Info> buildComparator(SortBy... sortBy) { if (sortBy.length == 0) { throw new IllegalArgumentException( "No way to build comparators out of an empty comparator set"); } if (sortBy.length == 1) { return buildComparator(sortBy[0]); } else { List<Comparator<Info>> comparators = new ArrayList<Comparator<Info>>(); for (SortBy curr : sortBy) { Comparator<Info> comparator = buildComparator(curr); comparators.add(comparator); } return new CompositeComparator<Info>(comparators); } }
/** * Builds a composite comparator matching the specified sortBy array * * <ul> * <li>{@link SortBy#NATURAL_ORDER}: sort by feature id (acceding) * <li>{@link SortBy#REVERSE_ORDER}: sort by feature id (descending) * <li>sort by supplied property name, and sort order * </ul> * * @param sortBy sort order (defined in order of precidence) */ public static Comparator<Feature> buildComparator(SortBy... sortBy) { if (sortBy.length == 0) { throw new IllegalArgumentException( "No way to build comparators out of an empty comparator set"); } if (sortBy.length == 1) { return buildComparator(sortBy[0]); } else { List<Comparator<Feature>> comparators = new ArrayList<Comparator<Feature>>(); for (SortBy curr : sortBy) { Comparator<Feature> comparator = buildComparator(curr); comparators.add(comparator); } return new CompositeComparator<Feature>(comparators); } }
public CatalogStoreFeatureIterator(int offset, int count, SortBy[] sortOrder, Filter filter, Catalog catalog, CatalogStoreMapping mapping, RecordDescriptor recordDescriptor, Map<String, String> interpolationProperties) { this.offset = offset; this.count = count; this.sortOrder = sortOrder; this.filter = filter; catalogFacade = catalog.getFacade(); this.mapping = mapping; this.interpolationProperties = interpolationProperties; layerIt = catalogFacade.list(ResourceInfo.class, filter, null, null, sortOrder); nextLayer(); layerGroupIt = catalogFacade.list(LayerGroupInfo.class, filter, null, null, sortOrder); nextLayerGroup(); comparator = sortOrder==null || sortOrder.length==0 ? null : CatalogComparatorFactory.buildComparator(sortOrder); index = 0; while (index < offset && hasNext()) { nextInternal(); } builder = new GenericRecordBuilder(recordDescriptor); }
/** Builds a single comparator based on the sortBy specification */ public static Comparator<Info> buildComparator(SortBy sortBy) { if (sortBy == null) { throw new NullPointerException("The sortBy argument must be not null"); } if (sortBy == SortBy.NATURAL_ORDER) { return new InfoComparator(true); } else if (sortBy == SortBy.REVERSE_ORDER) { return new InfoComparator(false); } else { return new PropertyComparator<Info>( sortBy.getPropertyName(), sortBy.getSortOrder() == SortOrder.ASCENDING); } } }
/** * Builds a single comparator based on the sortBy specification. * * <ul> * <li>{@link SortBy#NATURAL_ORDER}: sort by feature id (acceding) * <li>{@link SortBy#REVERSE_ORDER}: sort by feature id (descending) * <li>sort by supplied property name, and sort order * </ul> * * @param sortBy indication of sort order * @return Comparator used to determine sort order */ public static Comparator<Feature> buildComparator(SortBy sortBy) { if (sortBy == null) { throw new NullPointerException( "The sortBy argument must be not null (consider SortBy.UNSORTED)"); } if (sortBy == SortBy.NATURAL_ORDER) { return new FidComparator(true); } else if (sortBy == SortBy.REVERSE_ORDER) { return new FidComparator(false); } else { return new PropertyComparator<Feature>( sortBy.getPropertyName(), sortBy.getSortOrder() == SortOrder.ASCENDING); } } }
Feature[] features = (Feature[]) records.toArray(new Feature[records.size()]); Comparator<Feature> comparator = ComplexComparatorFactory.buildComparator(q.getSortBy()); Arrays.sort(features, comparator);
sortOrder == null || sortOrder.length == 0 ? null : CatalogComparatorFactory.buildComparator(sortOrder); index = 0; while (index < offset && hasNext()) {
Comparator<Feature> comparator = ComplexComparatorFactory.buildComparator(q.getSortBy()); Arrays.sort(features, comparator);