// non-existent object
return new EmptyCursor<MemStatement>();
}
MemResource[] memContexts;
MemStatementList smallestList;
contexts = OpenRDFUtil.notNull(contexts);
if (contexts.length == 0) {
memContexts = new MemResource[0];
smallestList = statements;
}
else if (contexts.length == 1 && contexts[0] != null) {
MemResource memContext = vf.getMemResource(contexts[0]);
if (memContext == null) {
// non-existent context
return new EmptyCursor<MemStatement>();
}
memContexts = new MemResource[] { memContext };
smallestList = memContext.getContextStatementList();
}
else {
Set<MemResource> contextSet = new LinkedHashSet<MemResource>(2 * contexts.length);
for (Resource context : contexts) {
MemResource memContext = vf.getMemResource(context);
if (context == null || memContext != null) {
contextSet.add(memContext);
}
}
if (contextSet.isEmpty()) {
// no known contexts specified
return new EmptyCursor<MemStatement>();
}
memContexts = contextSet.toArray(new MemResource[contextSet.size()]);
smallestList = statements;
}
if (memSubj != null) {
MemStatementList l = memSubj.getSubjectStatementList();
if (l.size() < smallestList.size()) {
smallestList = l;
}
}
if (memPred != null) {
MemStatementList l = memPred.getPredicateStatementList();
if (l.size() < smallestList.size()) {
smallestList = l;
}
}
if (memObj != null) {
MemStatementList l = memObj.getObjectStatementList();
if (l.size() < smallestList.size()) {
smallestList = l;
}
}
return new MemStatementCursor(smallestList, memSubj, memPred, memObj, explicitOnly, snapshot, readMode,