/** * @see Iterator#next */ @Override public RDFNode next() { m_seen = m_head; m_head = m_head.getTail(); return m_seen.getHead(); }
/** * @see Iterator#next */ @Override public RDFNode next() { m_seen = m_head; m_head = m_head.getTail(); return m_seen.getHead(); }
/** * <p>Answer a set of all of the RDF statements whose subject is one of the cells * of this list.</p> * @return A list of the statements that form the encoding of this list. */ public Set<Statement> collectStatements() { Set<Statement> stmts = new HashSet<>(); RDFList l = this; do { // collect all statements of this list cell for (Iterator<Statement> i = l.listProperties(); i.hasNext(); ) { stmts.add( i.next() ); } // move on to next cell l = l.getTail(); } while (!l.isEmpty()); return stmts; }
/** * <p>Answer a set of all of the RDF statements whose subject is one of the cells * of this list.</p> * @return A list of the statements that form the encoding of this list. */ public Set<Statement> collectStatements() { Set<Statement> stmts = new HashSet<>(); RDFList l = this; do { // collect all statements of this list cell for (Iterator<Statement> i = l.listProperties(); i.hasNext(); ) { stmts.add( i.next() ); } // move on to next cell l = l.getTail(); } while (!l.isEmpty()); return stmts; }
/** * Removes val from underlying list. * * @param val * @return the modified RDFList. */ private RDFList baseRemove(final RDFList val) { RDFList prev = null; RDFList cell = holder.getBaseItem(); final boolean searching = true; while (searching && !cell.isEmpty()) { if (cell.equals(val)) { // found the value to be removed final RDFList tail = cell.getTail(); if (prev != null) { prev.setTail(tail); } cell.removeProperties(); // return this unless we have removed the head element return (prev == null) ? tail : this; } else { // not found yet prev = cell; cell = cell.getTail(); } } // not found return this; }
public void testTail() { for (int i = 0; i <= 5; i++) { model.read( getFileName("ontology/list" + i + ".rdf")); RDFList l0 = getListRoot(model); // get the tail n times, should be nil at the end for (int j = 0; j < i; j++) { l0 = l0.getTail(); } Assert.assertTrue("Should have reached the end of the list after " + i + " getTail()'s", l0.isEmpty()); } }
public void testHead() { model.read(getFileName("ontology/list5.rdf")); RDFList l0 = getListRoot(model); final String[] names = { "a", "b", "c", "d", "e" }; for (final String name : names) { Assert.assertEquals("head of list has incorrect URI", TestList.NS + name, ((Resource) l0.getHead()).getURI()); l0 = l0.getTail(); } }
public void testTail() { for (int i = 0; i <= 5; i++) { model.read( getFileName("ontology/list" + i + ".rdf")); RDFList l0 = getListRoot(model); // get the tail n times, should be nil at the end for (int j = 0; j < i; j++) { l0 = l0.getTail(); } Assert.assertTrue("Should have reached the end of the list after " + i + " getTail()'s", l0.isEmpty()); } }
public void testHead() { model.read(getFileName("ontology/list5.rdf")); RDFList l0 = getListRoot(model); final String[] names = { "a", "b", "c", "d", "e" }; for (final String name : names) { Assert.assertEquals("head of list has incorrect URI", TestList.NS + name, ((Resource) l0.getHead()).getURI()); l0 = l0.getTail(); } }