while (fi.hasNext()) {
Format format = fi.next();
Iterator<ISelector> di = format.getDomainSet().iterator();
while (di.hasNext()) {
ISelector selects = di.next();
if (selects.canSelectResources()) {
/*
* Only ClassFormat and InstanceFormat select resources,
* so the vast amount of property formats can be skipped
*/
if (!(format instanceof ClassFormat || format instanceof InstanceFormat))
continue;
try {
Iterator<Resource> ri = selects.selectResources(in);
while (ri.hasNext()) {
Resource res = ri.next();
if (this._formatResourceMatches.containsKey(res)) {
ResourceFormatMatchSet match = this._formatResourceMatches.get(res);
match.addClassFormat(format);
} else {
ResourceFormatMatchSet match = new ResourceFormatMatchSet(res);
match.addClassFormat(format);
this._formatResourceMatches.put(res, match);
}
}
} catch (InvalidResultSetException e) {
// TODO
}
} else if (selects.canSelectStatements()) {
// inefficient - should really ask the model via sparql or something
// about all the predicates it contains
try {
Iterator<Statement> si = selects.selectStatements(select.getModel(), null);
while (si.hasNext()) {
URI prop = si.next().getPredicate();
if (this._formatPropertyMatches.containsKey(prop)) {
PropertyFormatMatchSet match = this._formatPropertyMatches.get(prop);
match.addPropertyFormat(format);
} else {
PropertyFormatMatchSet match = new PropertyFormatMatchSet(prop);
match.addPropertyFormat(format);
this._formatPropertyMatches.put(prop, match);
}
}
si = selects.selectStatements(select.getNotModel(), null);
while (si.hasNext()) {
URI prop = si.next().getPredicate();
if (this._formatPropertyMatches.containsKey(prop)) {
PropertyFormatMatchSet match = this._formatPropertyMatches.get(prop);
match.addPropertyFormat(format);