NodesReResolvingIterator implements Iterable<Node[]>, Iterator<Node[]> { public static BNode reResolveContextualBnode(BNode bn, URI uriToResolveAgainst) { try { String[] components = bn.parseContextualBNode(); int thisIdx = -1, otherIdx = -1; if (Util.THIS_STRING.equals(components[0])) { thisIdx = 0; otherIdx = 1; } else if (Util.THIS_STRING.equals(components[1])) { thisIdx = 1; otherIdx = 0; } if (thisIdx > -1) { try { BNode bn2 = new BNode(components[otherIdx]); bn2.parseContextualBNode(); bn = bn2; } catch (ParseException e2) { bn = BNode.createBNode( uriToResolveAgainst.toString(), components[otherIdx]); } } else { LOG.log(Level.WARNING, "Encountered malicious Blank Node: {0}", new Object[] { bn }); } } catch (ParseException e) { LOG.log(Level.WARNING, "Encountered malicious Blank Node: {0}", new Object[] { bn }); } return bn; } NodesReResolvingIterator(Iterable<Node[]> it, URI uriToResolveAgainst);  NodesReResolvingIterator(Iterator<Node[]> it, URI uriToResolveAgainst); @Override boolean hasNext(); @Override Node[] next(); @Override Iterator<Node[]> iterator(); @Override void remove(); static BNode reResolveContextualBnode(BNode bn,
			URI uriToResolveAgainst);  }
@Test public void testContextualBNodeTreatment1() throws URISyntaxException { BNode bn = NodesReResolvingIterator .reResolveContextualBnode( new BNode("_:httpx3Ax2Fx2Fthisx2Enx78parserx2Egithubx2Eiox2Freferencex2Ftox2FURIx2Fofx2Fcurrentx2Frdfx2Fgraphx2Fforx2Frepresentingx2Fpermanentlyx2Frelativex2FURIsx2Finx2FNx2DTriplesx2Fxxb1x78x78filex783Ax782FCx783Ax782FUsersx782FTobiasx782FDocumentsx782FAIFBx782Fivisionx782FMeetingsx782520Physicalx782F2015x782D09x782520Patrasx782Fix782DVISIONx782DBrusselsx782DWorkflowx782DDemox785F2x782E0x782Fnewx785Ftakeoffx785Fworkflowx785Fmodelx782Ettl"), new URI("http: BNode goldStandard = new BNode("_:b1xxfilex3Ax2FCx3Ax2FUsersx2FTobiasx2FDocumentsx2FAIFBx2Fivisionx2FMeetingsx2520Physicalx2F2015x2D09x2520Patrasx2Fix2DVISIONx2DBrusselsx2DWorkflowx2DDemox5F2x2E0x2Fnewx5Ftakeoffx5Fworkflowx5Fmodelx2Ettl"); assertEquals(goldStandard, bn); }
@Test public void testContextualBNodeTreatment2() throws URISyntaxException { BNode bn = NodesReResolvingIterator .reResolveContextualBnode( new BNode("_:httpx3Ax2Fx2Fthisx2Enx78parserx2Egithubx2Eiox2Freferencex2Ftox2FURIx2Fofx2Fcurrentx2Frdfx2Fgraphx2Fforx2Frepresentingx2Fpermanentlyx2Frelativex2FURIsx2Finx2FNx2DTriplesx2Fxxb1"), new URI("http: BNode goldStandard = new BNode("_:b1xxhttpx3Ax2Fx2Fex78amplex2Eorgx2Flalalax2F2"); assertEquals(goldStandard, bn); }