/** * Copies all elements of the parsed Iterator to a {@link ArrayList}. * To use other Set implementations that {@link ArrayList} you can use * {@link #addToCollection(Iterator, Collection) * @param <T> the generic type of the returned Collection * @param it the Iterator with elements compatible to T * @return the collection containing all elements of the iterator * @throws IllegalArgumentException if the parsed {@link Iterator} is <code>null</code> */ public static <T> Collection<T> asCollection(Iterator<? extends T> it){ return addToCollection(it, new ArrayList<T>()); } /**
/** * Copies all elements of the parsed Iterator to a {@link ArrayList}. * To use other Set implementations that {@link ArrayList} you can use * {@link #addToCollection(Iterator, Collection) * @param <T> the generic type of the returned Collection * @param it the Iterator with elements compatible to T * @return the collection containing all elements of the iterator * @throws IllegalArgumentException if the parsed {@link Iterator} is <code>null</code> */ public static <T> Collection<T> asCollection(Iterator<? extends T> it){ return addToCollection(it, new ArrayList<T>()); } /**
public RdfQueryResultList(FieldQuery query,Graph resultGraph) { if(query == null){ throw new IllegalArgumentException("Parameter Query MUST NOT be NULL!"); } if(resultGraph == null){ throw new IllegalArgumentException("Parameter \"Graph resultGraph\" MUST NOT be NULL"); } this.query = query; this.resultGraph = resultGraph; List<RdfRepresentation> results = (List<RdfRepresentation>)ModelUtils.addToCollection( ClerezzaQueryUtils.parseQueryResultsFromGraph(resultGraph), new ArrayList<RdfRepresentation>()); //sort the list based on the score Collections.sort(results,RESULT_SCORE_COMPARATOR); this.results = Collections.unmodifiableList(results); } @Override
public RdfQueryResultList(FieldQuery query,Graph resultGraph) { if(query == null){ throw new IllegalArgumentException("Parameter Query MUST NOT be NULL!"); } if(resultGraph == null){ throw new IllegalArgumentException("Parameter \"Graph resultGraph\" MUST NOT be NULL"); } this.query = query; this.resultGraph = resultGraph; List<RdfRepresentation> results = (List<RdfRepresentation>)ModelUtils.addToCollection( ClerezzaQueryUtils.parseQueryResultsFromGraph(resultGraph), new ArrayList<RdfRepresentation>()); //sort the list based on the score Collections.sort(results,RESULT_SCORE_COMPARATOR); this.results = Collections.unmodifiableList(results); } @Override
results = new LinkedHashSet<Object>(); for(Iterator<String> properties = r.getFieldNames();properties.hasNext();){ results.addAll(ModelUtils.addToCollection(r.get(properties.next()), results));