java/jdbc-loopback-driver/src/main/java/info/globalcode/jdbc/loopback/ResultSet.java
author František Kučera <franta-hg@frantovo.cz>
Thu, 24 Oct 2019 21:43:08 +0200
branchv_0
changeset 250 aae5009bd0af
parent 237 7e08730da258
permissions -rw-r--r--
fix license version: GNU GPLv3
     1 /**
     2  * SQL-DK
     3  * Copyright © 2014 František Kučera (frantovo.cz)
     4  *
     5  * This program is free software: you can redistribute it and/or modify
     6  * it under the terms of the GNU General Public License as published by
     7  * the Free Software Foundation, version 3 of the License.
     8  *
     9  * This program is distributed in the hope that it will be useful,
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    12  * GNU General Public License for more details.
    13  *
    14  * You should have received a copy of the GNU General Public License
    15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
    16  */
    17 package info.globalcode.jdbc.loopback;
    18 
    19 import java.sql.SQLException;
    20 import java.util.Iterator;
    21 import java.util.List;
    22 
    23 /**
    24  *
    25  * @author Ing. František Kučera (frantovo.cz)
    26  */
    27 public class ResultSet extends AbstractResultSet {
    28 
    29 	private final ResultSetMetaData metadata;
    30 	private final Iterator<Object[]> data;
    31 	private Object[] currentRow;
    32 
    33 	public ResultSet(ResultSetMetaData metadata, List<Object[]> table) {
    34 		data = table.listIterator();
    35 		this.metadata = metadata;
    36 	}
    37 
    38 	@Override
    39 	public boolean next() throws SQLException {
    40 		if (data.hasNext()) {
    41 			currentRow = data.next();
    42 			return true;
    43 		} else {
    44 			return false;
    45 		}
    46 	}
    47 
    48 	@Override
    49 	public Object getObject(int columnNumber) throws SQLException {
    50 		return currentRow[columnNumber - 1];
    51 	}
    52 
    53 	@Override
    54 	public ResultSetMetaData getMetaData() throws SQLException {
    55 		return metadata;
    56 	}
    57 
    58 	@Override
    59 	public void close() throws SQLException {
    60 	}
    61 
    62 	@Override
    63 	public boolean isClosed() throws SQLException {
    64 		return false;
    65 	}
    66 }