Java Code Examples for info.aduna.iteration.Iterations#closeCloseable()

The following examples show how to use info.aduna.iteration.Iterations#closeCloseable() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RDFStoreTest.java    From database with GNU General Public License v2.0 6 votes vote down vote up
private int countElements(Iteration<?, ?> iter)
	throws Exception
{
	int count = 0;

	try {
		while (iter.hasNext()) {
			iter.next();
			count++;
		}
	}
	finally {
		Iterations.closeCloseable(iter);
	}

	return count;
}
 
Example 2
Source File: RDFStoreTest.java    From database with GNU General Public License v2.0 5 votes vote down vote up
private <T> T first(Iteration<T, ?> iter)
	throws Exception
{
	try {
		if (iter.hasNext()) {
			return iter.next();
		}
	}
	finally {
		Iterations.closeCloseable(iter);
	}

	return null;
}
 
Example 3
Source File: BigdataStoreTest.java    From database with GNU General Public License v2.0 5 votes vote down vote up
private int countElements(Iteration<?, ?> iter) throws Exception {
	int count = 0;

	try {
		while (iter.hasNext()) {
			iter.next();
			count++;
		}
	} finally {
		Iterations.closeCloseable(iter);
	}

	return count;
}