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.ArrayList; 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 ResultSetMetaData extends AbstractResultSetMetaData { franta-hg@171: franta-hg@171: private List columns = new ArrayList<>(); franta-hg@171: franta-hg@171: public void addColumn(ColumnDescriptor cd) { franta-hg@171: columns.add(cd); franta-hg@171: } franta-hg@171: franta-hg@171: @Override franta-hg@171: public int getColumnCount() throws SQLException { franta-hg@171: return columns.size(); franta-hg@171: } franta-hg@171: franta-hg@171: @Override franta-hg@171: public String getColumnLabel(int column) throws SQLException { franta-hg@171: return columns.get(column - 1).label; franta-hg@171: } franta-hg@171: franta-hg@171: @Override franta-hg@171: public String getColumnName(int column) throws SQLException { franta-hg@171: return columns.get(column - 1).name; franta-hg@171: } franta-hg@171: franta-hg@171: @Override franta-hg@171: public int getColumnType(int column) throws SQLException { franta-hg@171: return columns.get(column - 1).type; franta-hg@171: } franta-hg@171: franta-hg@171: @Override franta-hg@171: public String getColumnTypeName(int column) throws SQLException { franta-hg@171: return columns.get(column - 1).typeName; franta-hg@171: } franta-hg@171: franta-hg@171: public static class ColumnDescriptor { franta-hg@171: franta-hg@171: private final int type; franta-hg@171: private final String typeName; franta-hg@171: private final String label; franta-hg@171: private final String name; franta-hg@171: franta-hg@171: public ColumnDescriptor(int type, String typeName, String label, String name) { franta-hg@171: this.type = type; franta-hg@171: this.typeName = typeName; franta-hg@171: this.label = label; franta-hg@171: this.name = name; franta-hg@171: } franta-hg@171: } franta-hg@171: }