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

net.sf.gluebooster.java.booster.basic.db.ResultSetIterator Maven / Gradle / Ivy

package net.sf.gluebooster.java.booster.basic.db;

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

import net.sf.gluebooster.java.booster.essentials.utils.ThrowableBoostUtils;
/**
 * Iterator over result sets.
 * @author cbauer
 * @defaultParamText resultSet  the result set which is iterated
 *
 */
public class ResultSetIterator implements Iterator {

	private ResultSet resultSet;

	public ResultSetIterator(ResultSet resultSet) {
		this.resultSet = resultSet;
	}

	@Override
	public boolean hasNext() {

		try {
			return resultSet.isAfterLast();
		} catch (SQLException e) {
			throw ThrowableBoostUtils.toRuntimeException(e);
		}
	}

	@Override
	public ResultSet next() {
		// TODO Auto-generated method stub
		try {
			if (!resultSet.next()) {
				throw new IllegalStateException("next no longer allowed");
			}
		} catch (SQLException e) {
			throw ThrowableBoostUtils.toRuntimeException(e);
		}
		return resultSet;
	}

	@Override
	public void remove() {
		throw ThrowableBoostUtils.createNotImplementedException("remove not implemented");
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy