use of org.apache.jena.rdf.model.RDFList in project jena by apache.
the class SecuredRDFListImpl method baseRemove.
/**
* 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;
}
// not found yet
prev = cell;
cell = cell.getTail();
}
// not found
return this;
}
use of org.apache.jena.rdf.model.RDFList in project jena by apache.
the class SecuredRDFListImpl method setTail.
@Override
public SecuredRDFList setTail(final RDFList tail) throws UpdateDeniedException, AuthenticationRequiredException {
checkUpdate();
final Statement rest = holder.getBaseItem().getRequiredProperty(RDF.rest);
final RDFNode retval = rest.getObject();
final Triple t = new Triple(holder.getBaseItem().asNode(), RDF.rest.asNode(), retval.asNode());
final Triple t2 = new Triple(holder.getBaseItem().asNode(), RDF.rest.asNode(), tail.asNode());
checkUpdate(t, t2);
rest.changeObject(tail);
return SecuredRDFListImpl.getInstance(getModel(), retval.as(RDFList.class));
}
use of org.apache.jena.rdf.model.RDFList in project jena by apache.
the class SecuredRDFListImpl method replace.
/**
* @sec.graph Update
* @sec.triple Update for triple i, and value.
* @throws UpdateDeniedException
* @throws EmptyListException
* @throws ListIndexException
* @throws InvalidListException
* @throws AuthenticationRequiredException if user is not authenticated and is
* required to be.
*/
@Override
public SecuredRDFNode replace(final int i, final RDFNode value) throws UpdateDeniedException, AuthenticationRequiredException, ListIndexException {
checkUpdate();
// get all the ones we can see since the replace must be against one we could
// see.
final ExtendedIterator<RDFList> iter = getFilteredRDFListIterator(Action.Read);
int idx = 0;
try {
while (iter.hasNext()) {
// seek to the proper position.
if (i == idx) {
// verify we can delete and if so delete.
final RDFList list = iter.next();
final RDFNode retval = list.getRequiredProperty(RDF.first).getObject();
final Triple t = new Triple(list.asNode(), RDF.first.asNode(), retval.asNode());
final Triple t2 = new Triple(list.asNode(), RDF.first.asNode(), value.asNode());
checkUpdate(t, t2);
list.getRequiredProperty(RDF.first).changeObject(value);
return SecuredRDFNodeImpl.getInstance(getModel(), retval);
}
idx++;
iter.next();
}
throw new ListIndexException();
} finally {
iter.close();
}
}
Aggregations