validStarts = null;
}
Iterator<Lens> li = grouping.getLenses().iterator();
while (li.hasNext()) {
Lens lens = li.next();
Iterator<ISelector> di = lens.getDomainSet().iterator();
while (di.hasNext()) {
ISelector select = di.next();
if (select.canSelectResources()) {
try {
Iterator<Resource> ri = select.selectResources(in);
while (ri.hasNext()) {
Resource res = (Resource) ri.next();
if (null == validStarts || (null != validStarts && validStarts.contains(res))) {
if (this._lensMatches.containsKey(res)) {
LensMatchSet match = this._lensMatches.getMatch(res);
match.add(lens);
} else {
LensMatchSet match = new LensMatchSet(res);
match.add(lens);
this._lensMatches.putMatch(res, match);
}
}
}
} catch (InvalidResultSetException e) {
//
}
}
}
}
// exception if no matches
if (this._lensMatches.size() == 0)
throw new NoResultsException("No lenses matching the data could be found.");
Selection answer = new Selection(this);
answer.setLangPref(langPref);
Iterator<?> resources = this._lensMatches.keySet().iterator();
while (resources.hasNext()) {
Resource subject = (Resource) resources.next();
LensMatchSet match = this._lensMatches.getMatch(subject);
Lens best = match.topMatch();
answer.addPrimary(answer.applyLens(grouping, in, best, subject, 0, MAXIMUM_LENS_DEPTH));
}
return answer;
}