author | František Kučera <franta-hg@frantovo.cz> |
Mon, 04 Mar 2019 20:15:24 +0100 | |
branch | v_0 |
changeset 238 | 4a1864c3e867 |
parent 164 | java/sql-dk/src/info/globalcode/sql/dk/formatting/FakeSqlArray.java@8cc7862605a1 |
child 250 | aae5009bd0af |
permissions | -rw-r--r-- |
159
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
1 |
/** |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
2 |
* SQL-DK |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
3 |
* Copyright © 2014 František Kučera (frantovo.cz) |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
4 |
* |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
5 |
* This program is free software: you can redistribute it and/or modify |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License as published by |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
7 |
* the Free Software Foundation, either version 3 of the License, or |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
8 |
* (at your option) any later version. |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
9 |
* |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
10 |
* This program is distributed in the hope that it will be useful, |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
13 |
* GNU General Public License for more details. |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
14 |
* |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
16 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
17 |
*/ |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
18 |
package info.globalcode.sql.dk.formatting; |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
19 |
|
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
20 |
import info.globalcode.sql.dk.SQLType; |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
21 |
import java.sql.Array; |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
22 |
import java.sql.ResultSet; |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
23 |
import java.sql.SQLException; |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
24 |
import java.util.Map; |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
25 |
|
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
26 |
/** |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
27 |
* Fake SQL array, for formatting purposes only |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
28 |
* |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
29 |
* @author Ing. František Kučera (frantovo.cz) |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
30 |
*/ |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
31 |
public class FakeSqlArray implements Array { |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
32 |
|
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
33 |
private static final UnsupportedOperationException exception = new UnsupportedOperationException("This is just a fake SQL array."); |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
34 |
private final Object[] data; |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
35 |
private final SQLType baseType; |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
36 |
|
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
37 |
public FakeSqlArray(Object[] data, SQLType baseType) { |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
38 |
this.data = data; |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
39 |
this.baseType = baseType; |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
40 |
} |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
41 |
|
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
42 |
@Override |
164
8cc7862605a1
FakeSqlArray#toString()
František Kučera <franta-hg@frantovo.cz>
parents:
159
diff
changeset
|
43 |
public String toString() { |
8cc7862605a1
FakeSqlArray#toString()
František Kučera <franta-hg@frantovo.cz>
parents:
159
diff
changeset
|
44 |
StringBuilder string = new StringBuilder(); |
8cc7862605a1
FakeSqlArray#toString()
František Kučera <franta-hg@frantovo.cz>
parents:
159
diff
changeset
|
45 |
for (Object o : data) { |
8cc7862605a1
FakeSqlArray#toString()
František Kučera <franta-hg@frantovo.cz>
parents:
159
diff
changeset
|
46 |
string.append(o); |
8cc7862605a1
FakeSqlArray#toString()
František Kučera <franta-hg@frantovo.cz>
parents:
159
diff
changeset
|
47 |
string.append("\n"); |
8cc7862605a1
FakeSqlArray#toString()
František Kučera <franta-hg@frantovo.cz>
parents:
159
diff
changeset
|
48 |
} |
8cc7862605a1
FakeSqlArray#toString()
František Kučera <franta-hg@frantovo.cz>
parents:
159
diff
changeset
|
49 |
return string.toString(); |
8cc7862605a1
FakeSqlArray#toString()
František Kučera <franta-hg@frantovo.cz>
parents:
159
diff
changeset
|
50 |
} |
8cc7862605a1
FakeSqlArray#toString()
František Kučera <franta-hg@frantovo.cz>
parents:
159
diff
changeset
|
51 |
|
8cc7862605a1
FakeSqlArray#toString()
František Kučera <franta-hg@frantovo.cz>
parents:
159
diff
changeset
|
52 |
@Override |
159
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
53 |
public String getBaseTypeName() throws SQLException { |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
54 |
return baseType.name(); |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
55 |
} |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
56 |
|
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
57 |
@Override |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
58 |
public int getBaseType() throws SQLException { |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
59 |
return baseType.getCode(); |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
60 |
} |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
61 |
|
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
62 |
@Override |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
63 |
public Object getArray() throws SQLException { |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
64 |
return data; |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
65 |
} |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
66 |
|
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
67 |
@Override |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
68 |
public Object getArray(Map<String, Class<?>> map) throws SQLException { |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
69 |
throw exception; |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
70 |
} |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
71 |
|
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
72 |
@Override |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
73 |
public Object getArray(long index, int count) throws SQLException { |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
74 |
throw exception; |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
75 |
} |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
76 |
|
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
77 |
@Override |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
78 |
public Object getArray(long index, int count, Map<String, Class<?>> map) throws SQLException { |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
79 |
throw exception; |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
80 |
} |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
81 |
|
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
82 |
@Override |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
83 |
public ResultSet getResultSet() throws SQLException { |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
84 |
throw exception; |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
85 |
} |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
86 |
|
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
87 |
@Override |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
88 |
public ResultSet getResultSet(Map<String, Class<?>> map) throws SQLException { |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
89 |
throw exception; |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
90 |
} |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
91 |
|
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
92 |
@Override |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
93 |
public ResultSet getResultSet(long index, int count) throws SQLException { |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
94 |
throw exception; |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
95 |
} |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
96 |
|
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
97 |
@Override |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
98 |
public ResultSet getResultSet(long index, int count, Map<String, Class<?>> map) throws SQLException { |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
99 |
throw exception; |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
100 |
} |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
101 |
|
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
102 |
@Override |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
103 |
public void free() throws SQLException { |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
104 |
throw exception; |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
105 |
} |
9632b23df30c
InfoLister: list configured and configurable JDBC driver properties – option: --list-jdbc-properties
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
106 |
} |