|
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, either version 3 of the License, or |
|
8 * (at your option) any later version. |
|
9 * |
|
10 * This program is distributed in the hope that it will be useful, |
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 * GNU General Public License for more details. |
|
14 * |
|
15 * You should have received a copy of the GNU General Public License |
|
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
17 */ |
|
18 package info.globalcode.jdbc.loopback; |
|
19 |
|
20 import java.sql.SQLException; |
|
21 import java.util.ArrayList; |
|
22 import java.util.List; |
|
23 |
|
24 /** |
|
25 * |
|
26 * @author Ing. František Kučera (frantovo.cz) |
|
27 */ |
|
28 public class ResultSetMetaData extends AbstractResultSetMetaData { |
|
29 |
|
30 private List<ColumnDescriptor> columns = new ArrayList<>(); |
|
31 |
|
32 public void addColumn(ColumnDescriptor cd) { |
|
33 columns.add(cd); |
|
34 } |
|
35 |
|
36 @Override |
|
37 public int getColumnCount() throws SQLException { |
|
38 return columns.size(); |
|
39 } |
|
40 |
|
41 @Override |
|
42 public String getColumnLabel(int column) throws SQLException { |
|
43 return columns.get(column - 1).label; |
|
44 } |
|
45 |
|
46 @Override |
|
47 public String getColumnName(int column) throws SQLException { |
|
48 return columns.get(column - 1).name; |
|
49 } |
|
50 |
|
51 @Override |
|
52 public int getColumnType(int column) throws SQLException { |
|
53 return columns.get(column - 1).type; |
|
54 } |
|
55 |
|
56 @Override |
|
57 public String getColumnTypeName(int column) throws SQLException { |
|
58 return columns.get(column - 1).typeName; |
|
59 } |
|
60 |
|
61 public static class ColumnDescriptor { |
|
62 |
|
63 private final int type; |
|
64 private final String typeName; |
|
65 private final String label; |
|
66 private final String name; |
|
67 |
|
68 public ColumnDescriptor(int type, String typeName, String label, String name) { |
|
69 this.type = type; |
|
70 this.typeName = typeName; |
|
71 this.label = label; |
|
72 this.name = name; |
|
73 } |
|
74 } |
|
75 } |