franta-hg@171: /** franta-hg@171: * SQL-DK franta-hg@171: * Copyright © 2014 František Kučera (frantovo.cz) franta-hg@171: * franta-hg@171: * This program is free software: you can redistribute it and/or modify franta-hg@171: * it under the terms of the GNU General Public License as published by franta-hg@171: * the Free Software Foundation, either version 3 of the License, or franta-hg@171: * (at your option) any later version. franta-hg@171: * franta-hg@171: * This program is distributed in the hope that it will be useful, franta-hg@171: * but WITHOUT ANY WARRANTY; without even the implied warranty of franta-hg@171: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the franta-hg@171: * GNU General Public License for more details. franta-hg@171: * franta-hg@171: * You should have received a copy of the GNU General Public License franta-hg@171: * along with this program. If not, see . franta-hg@171: */ franta-hg@171: package info.globalcode.jdbc.loopback; franta-hg@171: franta-hg@171: import java.sql.SQLException; franta-hg@171: import java.util.Iterator; franta-hg@171: import java.util.List; franta-hg@171: franta-hg@171: /** franta-hg@171: * franta-hg@171: * @author Ing. František Kučera (frantovo.cz) franta-hg@171: */ franta-hg@171: public class ResultSet extends AbstractResultSet { franta-hg@171: franta-hg@171: private final ResultSetMetaData metadata; franta-hg@171: private final Iterator data; franta-hg@171: private Object[] currentRow; franta-hg@171: franta-hg@171: public ResultSet(ResultSetMetaData metadata, List table) { franta-hg@171: data = table.listIterator(); franta-hg@171: this.metadata = metadata; franta-hg@171: } franta-hg@171: franta-hg@171: @Override franta-hg@171: public boolean next() throws SQLException { franta-hg@171: if (data.hasNext()) { franta-hg@171: currentRow = data.next(); franta-hg@171: return true; franta-hg@171: } else { franta-hg@171: return false; franta-hg@171: } franta-hg@171: } franta-hg@171: franta-hg@171: @Override franta-hg@171: public Object getObject(int columnNumber) throws SQLException { franta-hg@171: return currentRow[columnNumber - 1]; franta-hg@171: } franta-hg@171: franta-hg@171: @Override franta-hg@171: public ResultSetMetaData getMetaData() throws SQLException { franta-hg@171: return metadata; franta-hg@171: } franta-hg@171: franta-hg@171: @Override franta-hg@171: public void close() throws SQLException { franta-hg@171: } franta-hg@171: franta-hg@171: @Override franta-hg@171: public boolean isClosed() throws SQLException { franta-hg@171: return false; franta-hg@171: } franta-hg@171: }