Graph context = objectGN.getNodeContext();
Iterator<Triple> potentialIter = mGraph.filter(subject, triple.getPredicate(), null);
while (potentialIter.hasNext()) {
try {
final Triple potentialTriple = potentialIter.next();
BNode potentialMatch = (BNode)potentialTriple.getObject();
final Graph potentialContext = new GraphNode(potentialMatch, mGraph).getNodeContext();
if (potentialContext.equals(context)) {
removingTriples.addAll(potentialContext);
unGroundedTriples.removeAll(context);
continue OBJ_BNODE_LOOP;
}
} catch (ClassCastException e) {
continue;
}
}
throw new NoSuchSubGraphException();
}
SUBJ_BNODE_LOOP: while (true) {
final Triple triple = getTripleWithBNodeSubject(unGroundedTriples);
if (triple == null) {
break;
}
final GraphNode subjectGN = new GraphNode(triple.getSubject(), unGroundedTriples);
Resource object = triple.getObject();
if (object instanceof BNode) {
object = null;
}
Graph context = subjectGN.getNodeContext();
Iterator<Triple> potentialIter = mGraph.filter(null, triple.getPredicate(), object);
while (potentialIter.hasNext()) {
try {
final Triple potentialTriple = potentialIter.next();
BNode potentialMatch = (BNode)potentialTriple.getSubject();
final Graph potentialContext = new GraphNode(potentialMatch, mGraph).getNodeContext();
if (potentialContext.equals(context)) {
removingTriples.addAll(potentialContext);
unGroundedTriples.removeAll(context);
continue SUBJ_BNODE_LOOP;