use of org.sbpax.util.iterators.IterOfNone in project vcell by virtualcell.
the class IndexedGraph method match.
public Iterator<Statement> match(Resource subject, URI predicate, Value object, Resource... contexts) {
Iterator<Statement> iterator = new RDFGraphMatchIterator(this, subject, predicate, object);
if (subject != null) {
if (predicate != null) {
if (object != null) {
Statement statement = getValueFactory().createStatement(subject, predicate, object);
if (statements.contains(statement)) {
iterator = new IndexedGraphIterator(this, new IterOfOne<Statement>(statement));
} else {
iterator = new IterOfNone<Statement>();
}
} else {
Set<Statement> matches = spMap.get(new ListOfTwo<Value>(subject, predicate));
iterator = matches != null ? new IndexedGraphIterator(this, matches.iterator()) : new IterOfNone<Statement>();
}
} else {
if (object != null) {
Set<Statement> matches = soMap.get(new ListOfTwo<Value>(subject, object));
iterator = matches != null ? new IndexedGraphIterator(this, matches.iterator()) : new IterOfNone<Statement>();
} else {
Set<Statement> matches = sMap.get(subject);
iterator = matches != null ? new IndexedGraphIterator(this, matches.iterator()) : new IterOfNone<Statement>();
}
}
} else {
if (predicate != null) {
if (object != null) {
Set<Statement> matches = poMap.get(new ListOfTwo<Value>(predicate, object));
iterator = matches != null ? new IndexedGraphIterator(this, matches.iterator()) : new IterOfNone<Statement>();
} else {
Set<Statement> matches = pMap.get(predicate);
iterator = matches != null ? new IndexedGraphIterator(this, matches.iterator()) : new IterOfNone<Statement>();
}
} else {
if (object != null) {
Set<Statement> matches = oMap.get(object);
iterator = matches != null ? new IndexedGraphIterator(this, matches.iterator()) : new IterOfNone<Statement>();
} else {
iterator = new IndexedGraphIterator(this, statements.iterator());
}
}
}
return iterator;
}
Aggregations