Refine search
private Value getFirstValue(Resource subj, URI pred) throws RepositoryException { CloseableIteration<? extends Statement, RepositoryException> iter = null; try { iter = conn.getStatements(subj, pred, null, false); if (iter.hasNext()) return iter.next().getObject(); return null; } finally { if (iter != null) iter.close(); } }
public void remove() throws SailException { try { innerIter.remove(); } catch (RepositoryException e) { throw new SailException(e); } }
public boolean hasNext() { try { if (this.statements.hasNext()) return true; else { this.statements.close(); return false; } } catch (SailException e) { throw new RuntimeException(e.getMessage(), e); } }
private void setDatatype(ValueFactory vf, ContextAwareConnection conn, URI pred, URI datatype) throws RepositoryException { CloseableIteration<? extends Statement, RepositoryException> stmts; stmts = conn.getStatements(null, pred, null); try { while (stmts.hasNext()) { Statement stmt = stmts.next(); String label = ((Literal) stmt.getObject()).getLabel(); Literal literal = vf.createLiteral(label, datatype); conn.remove(stmt); conn.add(stmt.getSubject(), stmt.getPredicate(), literal); } } finally { stmts.close(); } }
private void updateLiteral(final Literal oldLiteral, final Literal newLiteral) { try { final Set<Statement> statements = new HashSet<Statement>(); final CloseableIteration<? extends Statement, SailException> results = this.graph.getSailConnection().get().getStatements(null, null, oldLiteral, false); while (results.hasNext()) { statements.add(results.next()); } results.close(); this.graph.getSailConnection().get().removeStatements(null, null, oldLiteral); for (Statement statement : statements) { SailHelper.addStatement(statement.getSubject(), statement.getPredicate(), newLiteral, statement.getContext(), this.graph.getSailConnection().get()); } } catch (SailException e) { throw new RuntimeException(e.getMessage(), e); } }
private Set<Resource> loadRecent(SailConnection con) throws SailException { Set<Resource> set = new HashSet<Resource>(); CloseableIteration<? extends Statement, SailException> stmts; stmts = con.getStatements(null, RDF.TYPE, Audit.RECENT, true); try { while (stmts.hasNext()) { set.add(stmts.next().getSubject()); } } finally { stmts.close(); } return set; }
private int findSize() throws RepositoryException { CloseableIteration<? extends Statement, RepositoryException> iter; HashSet<URI> set = new HashSet<URI>(); ObjectConnection conn = getObjectConnection(); iter = conn.getStatements(getResource(), null, null); try { while (iter.hasNext()) { set.add(iter.next().getPredicate()); } } finally { iter.close(); } int index = 0; while (set.contains(getMemberPredicate(index))) index++; return index; }
private void addAll(final Collection<Statement> addTo, final Set<Value> alreadyDescribed, final Set<Value> toDescribe, final CloseableIteration<? extends Statement, SailException> iter) throws SailException { try { while (iter.hasNext()) { Statement st = iter.next(); addTo.add(st); Resource context = st.getContext(); if (null != context && !alreadyDescribed.contains(context)) { toDescribe.add(context); } } } finally { iter.close(); } }
public boolean hasNext() { try { if (open && src.hasNext()) return true; close(); return false; } catch(Exception e) { throw new RuntimeException(e); } }
public void close() throws SailException { try { innerIter.close(); } catch (RepositoryException e) { throw new SailException(e); } }
@Override public boolean hasNext() throws SailException { try { return evaluate.hasNext(); } catch (final QueryEvaluationException e) { throw new SailException(e); } }
public E next() throws X { if (!hasPeeked) { return iteration.next(); } else { E result = peekedElement; hasPeeked = false; peekedElement = null; return result; } }
public Edge next() { try { return new SailEdge(this.statements.next(), graph); } catch (SailException e) { throw new RuntimeException(e.getMessage()); } catch (NoSuchElementException e) { try { this.statements.close(); } catch (SailException e2) { throw new RuntimeException(e2.getMessage(), e2); } throw e; } } }
public Resource next() throws SailException { try { return innerIter.next(); } catch (RepositoryException e) { throw new SailException(e); } }
public Value evaluate(Exists node, BindingSet bindings) throws ValueExprEvaluationException, QueryEvaluationException { CloseableIteration<BindingSet, QueryEvaluationException> iter = evaluate(node.getSubQuery(), bindings); try { return BooleanLiteral.valueOf(iter.hasNext()); } finally { iter.close(); } }
@Override public void remove() throws QueryEvaluationException { iter.remove(); }
private void setSubjectType(ContextAwareConnection conn, URI pred, Value obj, URI type) throws RepositoryException { CloseableIteration<? extends Statement, RepositoryException> stmts; stmts = conn.getStatements(null, pred, obj); try { while (stmts.hasNext()) { conn.add(stmts.next().getSubject(), RDF.TYPE, type); } } finally { stmts.close(); } }