public QueryResultList<String> findReferences(FieldQuery parsedQuery) throws YardException, IllegalArgumentException {
if(parsedQuery == null){
throw new IllegalArgumentException("The parsed query MUST NOT be NULL!");
}
final SparqlFieldQuery query = SparqlFieldQueryFactory.getSparqlFieldQuery(parsedQuery);
final ResultSet result = executeSparqlFieldQuery(query);
//A little bit complex construct ...
// first we use the adaptingIterator to convert reseource to string
// to get the resources we have to retrieve the root-variable of the
// Iterator<SolutionMapping> provided by the ResultSet of the SPARQL query
Iterator<String> representationIdIterator = new AdaptingIterator<Resource, String>(
new Iterator<Resource>() {
@Override public void remove() { result.remove(); }
@Override public Resource next() {
return result.next().get(query.getRootVariableName()); }
@Override public boolean hasNext() { return result.hasNext(); }
},
new Resource2StringAdapter<Resource>(), String.class);
return new QueryResultListImpl<String>(query,representationIdIterator,String.class);
}