@Test public void testGetListsForkedValid() { Statement testStatement1 = vf.createStatement(testListHeadBNode1, RDF.FIRST, testObjectLiteral1); this.testGraph.add(testStatement1); Statement testStatement2 = vf.createStatement(testListHeadBNode1, RDF.REST, testListHeadUri1); this.testGraph.add(testStatement2); Statement testStatement3 = vf.createStatement(testListHeadUri1, RDF.FIRST, testObjectUri1); this.testGraph.add(testStatement3); Statement testStatement4 = vf.createStatement(testListHeadUri1, RDF.REST, testListHeadBNode2); this.testGraph.add(testStatement4); Statement testStatement5 = vf.createStatement(testListHeadUri1, RDF.REST, testListHeadUri2); this.testGraph.add(testStatement5); Statement testStatement6 = vf.createStatement(testListHeadBNode2, RDF.FIRST, testObjectBNode1); this.testGraph.add(testStatement6); Statement testStatement7 = vf.createStatement(testListHeadBNode2, RDF.REST, RDF.NIL); this.testGraph.add(testStatement7); Statement testStatement8 = vf.createStatement(testListHeadUri2, RDF.FIRST, testObjectUri2); this.testGraph.add(testStatement8); Statement testStatement9 = vf.createStatement(testListHeadUri2, RDF.REST, RDF.NIL); this.testGraph.add(testStatement9); Set<Resource> heads = new HashSet<>(1); heads.add(this.testListHeadBNode1); final Collection<List<Value>> results = this.testRdfListUtilDefaults.getLists(heads, this.testGraph); assertEquals(2, results.size()); boolean foundFirstList = false; boolean foundSecondList = false; for (List<Value> resultList : results) { assertEquals(3, resultList.size()); assertTrue(resultList.contains(testObjectLiteral1)); assertTrue(resultList.contains(testObjectUri1)); if (resultList.contains(testObjectBNode1)) { foundFirstList = true; } else if (resultList.contains(testObjectUri2)) { foundSecondList = true; } } assertTrue("Did not find first list", foundFirstList); assertTrue("Did not find second list", foundSecondList); }
public Collection<List<Value>> getLists(final Set<Resource> heads, final Model graphToSearch, final Resource... contexts) { OpenRDFUtil.verifyContextNotNull(contexts); Collection<List<Value>> matches = new LinkedList<>(); try { for (Resource h : heads) { matches.addAll(getListsRecursive(h, graphToSearch, contexts)); } } catch (RuntimeException rex) { if (this.getUseIterativeOnError() && rex.getMessage().contains("List was too long")) { matches.clear(); matches = getListsIterative(heads, graphToSearch, contexts); } else { throw rex; } } return matches; }
RdfListUtil { public Collection<List<Value>> getLists(final Set<Resource> heads, final Model graphToSearch, final Resource... contexts) { OpenRDFUtil.verifyContextNotNull(contexts); Collection<List<Value>> matches = new LinkedList<>(); try { for (Resource h : heads) { matches.addAll(getListsRecursive(h, graphToSearch, contexts)); } } catch (RuntimeException rex) { if (this.getUseIterativeOnError() && rex.getMessage().contains("List was too long")) { matches.clear(); matches = getListsIterative(heads, graphToSearch, contexts); } else { throw rex; } } return matches; } }
RdfListUtil { public Collection<List<Value>> getLists(final Set<Resource> heads, final Model graphToSearch, final Resource... contexts) { OpenRDFUtil.verifyContextNotNull(contexts); Collection<List<Value>> matches = new LinkedList<>(); try { for (Resource h : heads) { matches.addAll(getListsRecursive(h, graphToSearch, contexts)); } } catch (RuntimeException rex) { if (this.getUseIterativeOnError() && rex.getMessage().contains("List was too long")) { matches.clear(); matches = getListsIterative(heads, graphToSearch, contexts); } else { throw rex; } } return matches; } RdfListUtil();  RdfListUtil(boolean checkCycles, boolean checkIncomplete, boolean useIterativeOnError); }
RdfListUtil { public Collection<List<Value>> getLists(final Set<Resource> heads, final Model graphToSearch, final Resource... contexts) { OpenRDFUtil.verifyContextNotNull(contexts); Collection<List<Value>> matches = new LinkedList<>(); try { for (Resource h : heads) { matches.addAll(getListsRecursive(h, graphToSearch, contexts)); } } catch (RuntimeException rex) { if (this.getUseIterativeOnError() && rex.getMessage().contains("List was too long")) { matches.clear(); matches = getListsIterative(heads, graphToSearch, contexts); } else { throw rex; } } return matches; } RdfListUtil();  RdfListUtil(boolean checkCycles, boolean checkIncomplete, boolean useIterativeOnError); void addList(final Resource head,
                        final List<Value> nextValues,
                        final Model graphToAddTo,
                        final Resource... contexts); void addListAtNode(final Resource subject,
                              final IRI predicate, final List<Value> nextValues,
                              final Model graphToAddTo, final Resource... contexts); List<Value> getList(final Resource head,
                               final Model graphToSearch, final Resource... contexts); List<Value> getListAtNode(final Resource subject,
                                     final IRI predicate,
                                     final Model graphToSearch,
                                     final Resource... contexts); Collection<List<Value>> getListsIterative(final Set<Resource> heads,
                                                     final Model graphToSearch,
                                                     final Resource... contexts); Collection<List<Value>> getLists(final Set<Resource> heads,
                                            final Model graphToSearch,
                                            final Resource... contexts); Collection<List<Value>> getListsRecursive(final Resource head,
                                                     final Model graph,
                                                     final Resource... contexts); Collection<List<Value>> getListsAtNode(
            final Resource subject, final IRI predicate,
            final Model graphToSearch, final Resource... contexts); boolean getCheckCycles(); boolean getCheckIncomplete(); boolean getUseIterativeOnError(); }
RdfListUtil { public Collection<List<Value>> getLists(final Set<Resource> heads, final Model graphToSearch, final Resource... contexts) { OpenRDFUtil.verifyContextNotNull(contexts); Collection<List<Value>> matches = new LinkedList<>(); try { for (Resource h : heads) { matches.addAll(getListsRecursive(h, graphToSearch, contexts)); } } catch (RuntimeException rex) { if (this.getUseIterativeOnError() && rex.getMessage().contains("List was too long")) { matches.clear(); matches = getListsIterative(heads, graphToSearch, contexts); } else { throw rex; } } return matches; } RdfListUtil();  RdfListUtil(boolean checkCycles, boolean checkIncomplete, boolean useIterativeOnError); void addList(final Resource head,
                        final List<Value> nextValues,
                        final Model graphToAddTo,
                        final Resource... contexts); void addListAtNode(final Resource subject,
                              final IRI predicate, final List<Value> nextValues,
                              final Model graphToAddTo, final Resource... contexts); List<Value> getList(final Resource head,
                               final Model graphToSearch, final Resource... contexts); List<Value> getListAtNode(final Resource subject,
                                     final IRI predicate,
                                     final Model graphToSearch,
                                     final Resource... contexts); Collection<List<Value>> getListsIterative(final Set<Resource> heads,
                                                     final Model graphToSearch,
                                                     final Resource... contexts); Collection<List<Value>> getLists(final Set<Resource> heads,
                                            final Model graphToSearch,
                                            final Resource... contexts); Collection<List<Value>> getListsRecursive(final Resource head,
                                                     final Model graph,
                                                     final Resource... contexts); Collection<List<Value>> getListsAtNode(
            final Resource subject, final IRI predicate,
            final Model graphToSearch, final Resource... contexts); boolean getCheckCycles(); boolean getCheckIncomplete(); boolean getUseIterativeOnError(); final static boolean DEFAULT_CHECK_CYCLES; final static boolean DEFAULT_CHECK_INCOMPLETE; final static boolean DEFAULT_USE_ITERATIVE_ON_ERROR; }