/** * @see Iterator#hasNext */ @Override public boolean hasNext() { return !m_head.isEmpty(); }
/** * @see Iterator#hasNext */ @Override public boolean hasNext() { return !m_head.isEmpty(); }
/** * <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; }
boolean searching = true; while (searching && !cell.isEmpty()) { if (cell.getHead().equals( val )) {
@Override public void concatenate(final Iterator<? extends RDFNode> nodes) throws UpdateDeniedException, AddDeniedException, AuthenticationRequiredException { checkUpdate(); if (holder.getBaseItem().isEmpty()) { // concatenating list onto the empty list is an error throw new EmptyListUpdateException( "Tried to concatenate onto the empty list"); } else { Triple t = new Triple(SecurityEvaluator.FUTURE, listFirst() .asNode(), Node.ANY); if (!canCreate(t)) { final List<RDFNode> list = new ArrayList<>(); while (nodes.hasNext()) { final RDFNode n = nodes.next(); t = new Triple(SecurityEvaluator.FUTURE, listFirst() .asNode(), n.asNode()); checkCreate(t); list.add(n); } holder.getBaseItem().concatenate(list.iterator()); } else { holder.getBaseItem().concatenate(nodes); } } }
boolean searching = true; while (searching && !cell.isEmpty()) { if (cell.getHead().equals( val )) {
@Override public RDFList append(final RDFList list) throws ReadDeniedException, AuthenticationRequiredException { if (holder.getBaseItem().isEmpty()) { return list.size() == 0 ? ModelFactory.createDefaultModel() .createList() : list.copy(); } else { final RDFList copy = copy(); if (list.size() > 0) { copy.concatenate(list.copy()); } return copy; } }
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 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()); } }
@Override public void concatenate(final RDFList list) throws UpdateDeniedException, AddDeniedException, AuthenticationRequiredException { checkUpdate(); if (holder.getBaseItem().isEmpty()) { // concatenating list onto the empty list is an error throw new EmptyListUpdateException( "Tried to concatenate onto the empty list"); } else { Triple t = new Triple(SecurityEvaluator.FUTURE, listFirst() .asNode(), Node.ANY); if (!canCreate(t)) { final ExtendedIterator<RDFNode> iter = list.iterator(); try { while (iter.hasNext()) { t = new Triple(SecurityEvaluator.FUTURE, listFirst() .asNode(), iter.next().asNode()); checkCreate(t); } } finally { iter.close(); } } holder.getBaseItem().concatenate(list); } }