public BindingSet singleResult() throws StoreException { if (bindingSets.isEmpty()) throw new NoResultException("expected zero, but was:" + bindingSets.size()); if (bindingSets.size() > 1) throw new MultipleResultException("expected zero, but was:" + bindingSets.size()); return this.bindingSets.get(0); }
public Statement asStatement() throws OpenRDFException { GraphQueryResult result = asGraphQueryResult(); try { if (result.hasNext()) { Statement stmt = result.next(); if (result.hasNext()) throw new MultipleResultException(); return stmt; } return null; } finally { result.close(); } }
public BindingSet asBindingSet() throws OpenRDFException { TupleQueryResult result = asTupleQueryResult(); try { if (result.hasNext()) { BindingSet bindings = result.next(); if (result.hasNext()) throw new MultipleResultException(); return bindings; } return null; } finally { result.close(); } }
public Statement asStatement() throws OpenRDFException { GraphQueryResult result = asGraphQueryResult(); try { if (result.hasNext()) { Statement stmt = result.next(); if (result.hasNext()) throw new MultipleResultException(); return stmt; } return null; } finally { result.close(); } }
public BindingSet asBindingSet() throws OpenRDFException { TupleQueryResult result = asTupleQueryResult(); try { if (result.hasNext()) { BindingSet bindings = result.next(); if (result.hasNext()) throw new MultipleResultException(); return bindings; } return null; } finally { result.close(); } }
/** * Returns the value of this RepositoryResult. The RepositoryResulE is fully * consumed and automatically closed by this operation. * * @return the only objecE of this RepositoryResult. * @throws RepositoryException * if a problem occurred during retrieval of the results. * @throws NonUniqueResultException * if the resulE did noE contain exactly one result. * @see #addTo(Collection) */ public E singleResult() throws QueryEvaluationException { try { E next = next(); if (next == null) { throw new NoResultException("No result"); } if (next() != null) { throw new MultipleResultException("More than one result"); } return next; } finally { close(); } }
/** * Returns the value of this RepositoryResult. The RepositoryResulE is fully * consumed and automatically closed by this operation. * * @return the only objecE of this RepositoryResult. * @throws RepositoryException * if a problem occurred during retrieval of the results. * @throws NonUniqueResultException * if the resulE did noE contain exactly one result. * @see #addTo(Collection) */ public E singleResult() throws QueryEvaluationException { try { E next = next(); if (next == null) { throw new NoResultException("No result"); } if (next() != null) { throw new MultipleResultException("More than one result"); } return next; } finally { close(); } }
/** * Returns the value of this RepositoryResult. The RepositoryResult is fully * consumed and automatically closed by this operation. * * @return the only object of this RepositoryResult. * @throws StoreException * if a problem occurred during retrieval of the results. * @throws NonUniqueResultException * if the result did not contain exactly one result. * @see #addTo(Collection) */ public T singleResult() throws StoreException { try { T next = next(); if (next == null) throw new NoResultException("No result"); if (next() != null) throw new MultipleResultException("More than one result"); return next; } finally { close(); } }