All Downloads are FREE. Search and download functionalities are using the official Maven repository.

se.ugli.habanero.j.ResultSetIterator Maven / Gradle / Ivy

There is a newer version: 1.8.1.1
Show newest version
package se.ugli.habanero.j;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Iterator;

public abstract class ResultSetIterator implements Iterator {

	private ResultSet resultSet;

	@Override
	public final boolean hasNext() {
		try {
			return resultSet.next();
		} catch (final SQLException e) {
			throw new HabaneroException(e);
		}
	}

	@Override
	public final E next() {
		try {
			return nextObject(resultSet);
		} catch (final SQLException e) {
			throw new HabaneroException(e);
		}
	}

	final void init(final ResultSet resultSet) throws SQLException {
		this.resultSet = resultSet;
		postInit(resultSet);
	}

	protected abstract E nextObject(ResultSet resultSet) throws SQLException;

	protected void postInit(final ResultSet resultSet) throws SQLException {
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy