protected <X extends Exception> CloseableIteration<MemStatement, X> createStatementIterator(
Class<X> excClass, Resource subj, URI pred, Value obj, boolean explicitOnly, int snapshot,
ReadMode readMode, Resource... contexts)
{
// Perform look-ups for value-equivalents of the specified values
MemResource memSubj = valueFactory.getMemResource(subj);
if (subj != null && memSubj == null) {
// non-existent subject
return new EmptyIteration<MemStatement, X>();
}
MemURI memPred = valueFactory.getMemURI(pred);
if (pred != null && memPred == null) {
// non-existent predicate
return new EmptyIteration<MemStatement, X>();
}
MemValue memObj = valueFactory.getMemValue(obj);
if (obj != null && memObj == null) {
// non-existent object
return new EmptyIteration<MemStatement, X>();
}
MemResource[] memContexts;
MemStatementList smallestList;
if (contexts.length == 0) {
memContexts = new MemResource[0];
smallestList = statements;
}
else if (contexts.length == 1 && contexts[0] != null) {
MemResource memContext = valueFactory.getMemResource(contexts[0]);
if (memContext == null) {
// non-existent context
return new EmptyIteration<MemStatement, X>();
}
memContexts = new MemResource[] { memContext };
smallestList = memContext.getContextStatementList();
}
else {
Set<MemResource> contextSet = new LinkedHashSet<MemResource>(2 * contexts.length);
for (Resource context : contexts) {
MemResource memContext = valueFactory.getMemResource(context);
if (context == null || memContext != null) {
contextSet.add(memContext);
}
}