if (directory) {
return plugin.scanDirectory(store, name);
} else {
BufferedInputStream inputStream = new BufferedInputStream(openInputStream(name, element));
StreamSource streamSource = new StreamSource(inputStream, name);
Descriptor descriptor = plugin.scanFile(store, streamSource);
inputStream.close();
return descriptor;
}
} catch(Exception e) {
throw new IOException("Error scanning "+name,e);
}
}
@Override
public Descriptor next() {
if (hasNext()) {
Descriptor result = next;
next = null;
return result;
}
throw new NoSuchElementException("No more results.");
}