@Override public void remove() { stmt.remove(); super.remove(); } }
@Override public void remove() { super.remove(); current.remove(); }
@Override public void remove() { super.remove(); current.remove(); }
/** * <p>Remove all of the components of this list from the model. Once this operation * has completed, the {@link RDFList} resource on which it was called will no * longer be a resource in the model, so further methods calls on the list object * (for example, {@link #size} will fail. Due to restrictions on the encoding * of lists in RDF, it is not possible to perform an operation which empties a list * and then adds further values to that list. Client code wishing to perform * such an operation should do so in two steps: first remove the old list, then * create a new list with the new contents. It is important that RDF statements * that reference the old list (in the object position) be updated to point * to the newly created list. * Note that this * is operation is only removing the list cells themselves, not the resources * referenced by the list - unless being the object of an <code>rdf:first</code> * statement is the only mention of that resource in the model.</p> */ @Override public void removeList() { for ( Statement statement : collectStatements() ) { statement.remove(); } }
/** * <p>Remove all of the components of this list from the model. Once this operation * has completed, the {@link RDFList} resource on which it was called will no * longer be a resource in the model, so further methods calls on the list object * (for example, {@link #size} will fail. Due to restrictions on the encoding * of lists in RDF, it is not possible to perform an operation which empties a list * and then adds further values to that list. Client code wishing to perform * such an operation should do so in two steps: first remove the old list, then * create a new list with the new contents. It is important that RDF statements * that reference the old list (in the object position) be updated to point * to the newly created list. * Note that this * is operation is only removing the list cells themselves, not the resources * referenced by the list - unless being the object of an <code>rdf:first</code> * statement is the only mention of that resource in the model.</p> */ @Override public void removeList() { for ( Statement statement : collectStatements() ) { statement.remove(); } }
/** * <p> * Helper method for setting the list tail, that assumes we have * a resource that is a list. * </p> * * @param root The resource representing the list cell we're setting the * tail of * @param tail The new tail for this list, as a resource. * @return The old tail, as a resource. */ protected static Resource setTailAux( Resource root, Resource tail, Property pTail ) { Statement current = root.getRequiredProperty( pTail ); Resource oldTail = current.getResource(); // out with the old, in with the new current.remove(); root.addProperty( pTail, tail ); return oldTail; }
/** * <p> * Helper method for setting the list tail, that assumes we have * a resource that is a list. * </p> * * @param root The resource representing the list cell we're setting the * tail of * @param tail The new tail for this list, as a resource. * @return The old tail, as a resource. */ protected static Resource setTailAux( Resource root, Resource tail, Property pTail ) { Statement current = root.getRequiredProperty( pTail ); Resource oldTail = current.getResource(); // out with the old, in with the new current.remove(); root.addProperty( pTail, tail ); return oldTail; }
@Override public Seq remove(int index) { getRequiredProperty(RDF.li(index)).remove(); shiftDown(index+1, size()+1); return this; }
@Override public Container remove(int index, RDFNode o) { // System.err.println( "]] SeqImpl::remove( " + index + ", " + o + ")" ); return remove(getModel().createStatement(this, RDF.li(index), o).remove()); }
@Override public Seq remove(int index) { getRequiredProperty(RDF.li(index)).remove(); shiftDown(index+1, size()+1); return this; }
@Override public Container remove(int index, RDFNode o) { // System.err.println( "]] SeqImpl::remove( " + index + ", " + o + ")" ); return remove(getModel().createStatement(this, RDF.li(index), o).remove()); }
protected void shiftDown(int start, int finish) { for (int i=start; i<=finish; i++) { Statement stmt = getRequiredProperty( RDF.li(i) ); // System.err.println( "]]* remove " + stmt ); stmt.remove(); // System.err.println( "]]* addProperty( " + RDF.li(i-1) + " " + stmt.getObject() ); addProperty(RDF.li(i-1), stmt.getObject()); } }
@Override public SecuredStatement remove() throws UpdateDeniedException, DeleteDeniedException, AuthenticationRequiredException { checkUpdate(); checkDelete(holder.getBaseItem()); holder.getBaseItem().remove(); return holder.getSecuredItem(); }
protected void shiftDown(int start, int finish) { for (int i=start; i<=finish; i++) { Statement stmt = getRequiredProperty( RDF.li(i) ); // System.err.println( "]]* remove " + stmt ); stmt.remove(); // System.err.println( "]]* addProperty( " + RDF.li(i-1) + " " + stmt.getObject() ); addProperty(RDF.li(i-1), stmt.getObject()); } }
/** * <p> * Update the head of the list to have the given value, and return the * previous value. * </p> * * @param value The value that will become the value of the list head * @exception EmptyListException if this list is the empty list */ @Override public RDFNode setHead( RDFNode value ) { if (s_checkValid) { checkValid(); } checkNotNil( "Tried to set the head of an empty list" ); // first remove the existing head Statement current = getRequiredProperty( listFirst() ); RDFNode n = current.getObject(); current.remove(); // now add the new head value to the graph addProperty( listFirst(), value ); return n; }
/** * <p> * Update the head of the list to have the given value, and return the * previous value. * </p> * * @param value The value that will become the value of the list head * @exception EmptyListException if this list is the empty list */ @Override public RDFNode setHead( RDFNode value ) { if (s_checkValid) { checkValid(); } checkNotNil( "Tried to set the head of an empty list" ); // first remove the existing head Statement current = getRequiredProperty( listFirst() ); RDFNode n = current.getObject(); current.remove(); // now add the new head value to the graph addProperty( listFirst(), value ); return n; }
@Override public void removeList() throws UpdateDeniedException, AuthenticationRequiredException { checkUpdate(); final Triple t = new Triple(Node.ANY, listFirst().asNode(), Node.ANY); // have to be able to read and delete to delete all. final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] { Action.Delete, Action.Read }); if (getSecurityEvaluator().evaluate( getSecurityEvaluator().getPrincipal(), perms, this.getModelNode(), t)) { holder.getBaseItem().removeList(); } else { for (final Statement s : collectStatements(perms)) { if (canDelete(s)) { s.remove(); } } } }
public void testValidity() { final Resource root = model.createResource(TestList.NS + "root"); final Property p = model.createProperty(TestList.NS, "p"); // a list of the nil object, but not typed final Resource nil = RDF.nil; model.add(root, p, nil); final RDFList l0 = getListRoot(model); checkValid("valid1", l0, true); // add another node to the head of the list final Resource badList = model.createResource(); model.getRequiredProperty(root, p).remove(); model.add(root, p, badList); model.add(badList, RDF.type, RDF.List); final RDFList l1 = getListRoot(model); checkValid("valid2", l1, false); // checkValid( "valid3", l1, false ); model.add(badList, RDF.first, "fred"); checkValid("valid4", l1, false); model.add(badList, RDF.rest, nil); checkValid("valid5", l1, true); }
public void testValidity() { final Resource root = model.createResource(TestList.NS + "root"); final Property p = model.createProperty(TestList.NS, "p"); // a list of the nil object, but not typed final Resource nil = RDF.nil; model.add(root, p, nil); final RDFList l0 = getListRoot(model); checkValid("valid1", l0, true); // add another node to the head of the list final Resource badList = model.createResource(); model.getRequiredProperty(root, p).remove(); model.add(root, p, badList); model.add(badList, RDF.type, RDF.List); final RDFList l1 = getListRoot(model); checkValid("valid2", l1, false); // checkValid( "valid3", l1, false ); model.add(badList, RDF.first, "fred"); checkValid("valid4", l1, false); model.add(badList, RDF.rest, nil); checkValid("valid5", l1, true); }