// Path: core/main/src/com/complexible/common/openrdf/util/AdunaIterations.java
// public final class AdunaIterations {
// 	/**
// 	 * the logger
// 	 */
// 	private static final Logger LOGGER = LoggerFactory.getLogger(AdunaIterations.class);
// 
// 	/**
// 	 * Private constructor, no instances
// 	 */
// 	private AdunaIterations() {
//         throw new AssertionError();
// 	}
// 
// 	/**
// 	 * Quietly close the iteration
// 	 * @param theCloseableIteration the iteration to close
// 	 */
// 	public static void closeQuietly(final CloseableIteration<?,?> theCloseableIteration) {
// 		try {
// 			if (theCloseableIteration != null) {
// 				Iterations.closeCloseable(theCloseableIteration);
// 			}
// 		}
// 		catch (Exception e) {
// 			LOGGER.warn("Ignoring error while closing iteration.", e);
// 		}
// 	}
// 
//     /**
//      * Return the first result of the iteration.  If the Iteration is empty or null, the Optional will be absent.
//      *
//      * The Iteration is closed whether or not there is a result.
//      *
//      * @param theIter   the iteration
//      * @return          an Optional containing the first result of the iteration, if present.
//      * @throws E
//      */
//     public static <T, E extends Exception> Optional<T> singleResult(final CloseableIteration<T, E> theIter) throws E {
//         if (theIter == null) {
//             return Optional.empty();
//         }
// 
//         try {
//             return theIter.hasNext() ? Optional.of(theIter.next()) : Optional.<T>empty();
//         }
//         finally {
//             theIter.close();
//         }
//     }
// 
//     /**
//      * Consume all of the results in the Iteration and then close it when iteration is complete.
//      * @param theIter   the Iteration to consume
//      * @throws E        if there is an error while consuming the results
//      */
//     public static <T, E extends Exception> void consume(final CloseableIteration<T, E> theIter) throws E {
//         if (theIter == null) {
//             return;
//         }
// 
//         try {
//             while (theIter.hasNext()) {
//                 theIter.next();
//             }
//         }
//         finally {
//             theIter.close();
//         }
//     }
// 
//     /**
//      * Return the number of elements left in the Iteration.  The iteration is closed when complete.
//      * @param theIter   the Iteration whose size should be computed
//      * @return          the number of elements left
//      * @throws E        if there is an error while iterating
//      */
//     public static <T, E extends Exception> long size(final CloseableIteration<T, E> theIter) throws E {
//         if (theIter == null) {
//             return 0;
//         }
// 
//         try {
//             long aCount = 0;
//             while (theIter.hasNext()) {
//                 theIter.next();
//                 aCount++;
//             }
// 
//             return aCount;
//         }
//         finally {
//             theIter.close();
//         }
//     }
// }


import com.complexible.common.openrdf.util.AdunaIterations;
import info.aduna.iteration.CloseableIteration;
import org.openrdf.model.Graph;
import org.openrdf.model.Statement;
import org.openrdf.sail.Sail;
import org.openrdf.sail.SailConnection;
import org.openrdf.sail.SailException;
		finally {
			aConn.close();
		}
	}

	public static void remove(final Sail theSail, final Graph theGraph) throws SailException {
		SailConnection aConn = theSail.getConnection();
		try {
			SailConnections.remove(aConn, theGraph);
		}
		finally {
			aConn.close();
		}
	}

	public static boolean contains(final Sail theSail, final Statement theStmt) throws SailException {
		SailConnection aConn = theSail.getConnection();
		CloseableIteration<?,?> aIter = null;
		try {
			aIter =
				theStmt.getContext() != null
			       ? aConn.getStatements(theStmt.getSubject(), theStmt.getPredicate(), theStmt.getObject(), true, theStmt.getContext())
			       : aConn.getStatements(theStmt.getSubject(), theStmt.getPredicate(), theStmt.getObject(), true);

			return aIter.hasNext();
		}
		catch (Exception e) {
			throw new SailException(e);
		}
		finally {
// Path: core/main/src/com/complexible/common/openrdf/util/AdunaIterations.java
// public final class AdunaIterations {
// 	/**
// 	 * the logger
// 	 */
// 	private static final Logger LOGGER = LoggerFactory.getLogger(AdunaIterations.class);
// 
// 	/**
// 	 * Private constructor, no instances
// 	 */
// 	private AdunaIterations() {
//         throw new AssertionError();
// 	}
// 
// 	/**
// 	 * Quietly close the iteration
// 	 * @param theCloseableIteration the iteration to close
// 	 */
// 	public static void closeQuietly(final CloseableIteration<?,?> theCloseableIteration) {
// 		try {
// 			if (theCloseableIteration != null) {
// 				Iterations.closeCloseable(theCloseableIteration);
// 			}
// 		}
// 		catch (Exception e) {
// 			LOGGER.warn("Ignoring error while closing iteration.", e);
// 		}
// 	}
// 
//     /**
//      * Return the first result of the iteration.  If the Iteration is empty or null, the Optional will be absent.
//      *
//      * The Iteration is closed whether or not there is a result.
//      *
//      * @param theIter   the iteration
//      * @return          an Optional containing the first result of the iteration, if present.
//      * @throws E
//      */
//     public static <T, E extends Exception> Optional<T> singleResult(final CloseableIteration<T, E> theIter) throws E {
//         if (theIter == null) {
//             return Optional.empty();
//         }
// 
//         try {
//             return theIter.hasNext() ? Optional.of(theIter.next()) : Optional.<T>empty();
//         }
//         finally {
//             theIter.close();
//         }
//     }
// 
//     /**
//      * Consume all of the results in the Iteration and then close it when iteration is complete.
//      * @param theIter   the Iteration to consume
//      * @throws E        if there is an error while consuming the results
//      */
//     public static <T, E extends Exception> void consume(final CloseableIteration<T, E> theIter) throws E {
//         if (theIter == null) {
//             return;
//         }
// 
//         try {
//             while (theIter.hasNext()) {
//                 theIter.next();
//             }
//         }
//         finally {
//             theIter.close();
//         }
//     }
// 
//     /**
//      * Return the number of elements left in the Iteration.  The iteration is closed when complete.
//      * @param theIter   the Iteration whose size should be computed
//      * @return          the number of elements left
//      * @throws E        if there is an error while iterating
//      */
//     public static <T, E extends Exception> long size(final CloseableIteration<T, E> theIter) throws E {
//         if (theIter == null) {
//             return 0;
//         }
// 
//         try {
//             long aCount = 0;
//             while (theIter.hasNext()) {
//                 theIter.next();
//                 aCount++;
//             }
// 
//             return aCount;
//         }
//         finally {
//             theIter.close();
//         }
//     }
// }


// Path: core/main/src/com/complexible/common/openrdf/sail/Sails.java
import com.complexible.common.openrdf.util.AdunaIterations;
import info.aduna.iteration.CloseableIteration;
import org.openrdf.model.Graph;
import org.openrdf.model.Statement;
import org.openrdf.sail.Sail;
import org.openrdf.sail.SailConnection;
import org.openrdf.sail.SailException;

		finally {
			aConn.close();
		}
	}

	public static void remove(final Sail theSail, final Graph theGraph) throws SailException {
		SailConnection aConn = theSail.getConnection();
		try {
			SailConnections.remove(aConn, theGraph);
		}
		finally {
			aConn.close();
		}
	}

	public static boolean contains(final Sail theSail, final Statement theStmt) throws SailException {
		SailConnection aConn = theSail.getConnection();
		CloseableIteration<?,?> aIter = null;
		try {
			aIter =
				theStmt.getContext() != null
			       ? aConn.getStatements(theStmt.getSubject(), theStmt.getPredicate(), theStmt.getObject(), true, theStmt.getContext())
			       : aConn.getStatements(theStmt.getSubject(), theStmt.getPredicate(), theStmt.getObject(), true);

			return aIter.hasNext();
		}
		catch (Exception e) {
			throw new SailException(e);
		}
		finally {
			AdunaIterations.closeQuietly(aIter);