Search in sources :

Example 1 with QueryFatalException

use of org.apache.jena.query.QueryFatalException in project jena by apache.

the class QueryIteratorBase method nextBinding.

/** final - subclasses implement moveToNextBinding() */
@Override
public final Binding nextBinding() {
    try {
        // Need to make sure to only read this once per iteration
        boolean shouldCancel = requestingCancel;
        if (shouldCancel && abortIterator) {
            // Try to close first to release resources (in case the user
            // doesn't have a close() call in a finally block)
            close();
            throw new QueryCancelledException();
        }
        if (finished)
            throw new NoSuchElementException(Lib.className(this));
        if (!hasNextBinding())
            throw new NoSuchElementException(Lib.className(this));
        Binding obj = moveToNextBinding();
        if (obj == null)
            throw new NoSuchElementException(Lib.className(this));
        if (shouldCancel && !finished) {
            // But .cancel sets both requestingCancel and abortIterator
            // This only happens with a continuing iterator.
            close();
        }
        return obj;
    } catch (QueryFatalException ex) {
        Log.error(this, "QueryFatalException", ex);
        throw ex;
    }
}
Also used : Binding(org.apache.jena.sparql.engine.binding.Binding) QueryFatalException(org.apache.jena.query.QueryFatalException) QueryCancelledException(org.apache.jena.query.QueryCancelledException) NoSuchElementException(java.util.NoSuchElementException)

Aggregations

NoSuchElementException (java.util.NoSuchElementException)1 QueryCancelledException (org.apache.jena.query.QueryCancelledException)1 QueryFatalException (org.apache.jena.query.QueryFatalException)1 Binding (org.apache.jena.sparql.engine.binding.Binding)1