Reputation: 579
In Model.filter(), I would like to store the objects. But if the object is a blank node, I would like to retrieve the corresponding triple and store the real object.
The problem in Model.filter() is that If the blank node(object) is _:a , the returning "Value" will be something like :xxxxxxxxxxa. this is fine but when I have (:xxxxxxxxxxa,p,o) in the model, trying to use model.filter(_:xxxxxxxxxxa,null,null) fails.
java.util.NoSuchElementException
at org.openrdf.model.impl.AbstractModel$ValueSet$ValueSetIterator.
next(AbstractModel.java:493)
at org.openrdf.model.impl.AbstractModel$ValueSet$ValueSetIterator.next(AbstractModel.java:470)
This is the source code which explain the problem in more detain:
private Model triples;
private Value filterBySubjectAndPredicate(Resource subject, IRI Predicate, IRI nextPredicate) {
Value tempValue = triples.filter(subject, vf.createURI(Predicate.getFullIRI()), null).
objects().iterator().next();
BNode bnode = null;
if(tempValue instanceof BNode) {
bnode = vf.createBNode(tempValue.toString());
return triples.filter(bnode, vf.createURI(nextPredicategetFullIRI()), null).
objects().iterator().next();
} else
return triples.filter(subject, vf.createURI(Predicate.getFullIRI()), null).
objects().iterator().next();
}
Thank you in advance.
Upvotes: 1
Views: 186