franta-hg@68
|
1 |
/**
|
franta-hg@68
|
2 |
* SQL-DK
|
franta-hg@68
|
3 |
* Copyright © 2013 František Kučera (frantovo.cz)
|
franta-hg@68
|
4 |
*
|
franta-hg@68
|
5 |
* This program is free software: you can redistribute it and/or modify
|
franta-hg@68
|
6 |
* it under the terms of the GNU General Public License as published by
|
franta-hg@68
|
7 |
* the Free Software Foundation, either version 3 of the License, or
|
franta-hg@68
|
8 |
* (at your option) any later version.
|
franta-hg@68
|
9 |
*
|
franta-hg@68
|
10 |
* This program is distributed in the hope that it will be useful,
|
franta-hg@68
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
franta-hg@68
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
franta-hg@68
|
13 |
* GNU General Public License for more details.
|
franta-hg@68
|
14 |
*
|
franta-hg@68
|
15 |
* You should have received a copy of the GNU General Public License
|
franta-hg@68
|
16 |
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
franta-hg@68
|
17 |
*/
|
franta-hg@68
|
18 |
package info.globalcode.sql.dk;
|
franta-hg@68
|
19 |
|
franta-hg@68
|
20 |
import java.sql.Types;
|
franta-hg@68
|
21 |
|
franta-hg@68
|
22 |
/**
|
franta-hg@68
|
23 |
*
|
franta-hg@68
|
24 |
* @author Ing. František Kučera (frantovo.cz)
|
franta-hg@68
|
25 |
*/
|
franta-hg@68
|
26 |
public enum SQLType {
|
franta-hg@68
|
27 |
|
franta-hg@93
|
28 |
/**
|
franta-hg@93
|
29 |
* Names must be upper case – user input is also converted to upper case → case insensitive
|
franta-hg@93
|
30 |
*/
|
franta-hg@92
|
31 |
BIT(Types.BIT),
|
franta-hg@92
|
32 |
TINYINT(Types.TINYINT),
|
franta-hg@92
|
33 |
SMALLINT(Types.SMALLINT),
|
franta-hg@92
|
34 |
INTEGER(Types.INTEGER),
|
franta-hg@92
|
35 |
BIGINT(Types.BIGINT),
|
franta-hg@92
|
36 |
FLOAT(Types.FLOAT),
|
franta-hg@92
|
37 |
REAL(Types.REAL),
|
franta-hg@92
|
38 |
DOUBLE(Types.DOUBLE),
|
franta-hg@92
|
39 |
NUMERIC(Types.NUMERIC),
|
franta-hg@92
|
40 |
DECIMAL(Types.DECIMAL),
|
franta-hg@92
|
41 |
CHAR(Types.CHAR),
|
franta-hg@68
|
42 |
VARCHAR(Types.VARCHAR),
|
franta-hg@92
|
43 |
LONGVARCHAR(Types.LONGVARCHAR),
|
franta-hg@92
|
44 |
DATE(Types.DATE),
|
franta-hg@92
|
45 |
TIME(Types.TIME),
|
franta-hg@92
|
46 |
TIMESTAMP(Types.TIMESTAMP),
|
franta-hg@92
|
47 |
BINARY(Types.BINARY),
|
franta-hg@92
|
48 |
VARBINARY(Types.VARBINARY),
|
franta-hg@92
|
49 |
LONGVARBINARY(Types.LONGVARBINARY),
|
franta-hg@92
|
50 |
NULL(Types.NULL),
|
franta-hg@92
|
51 |
OTHER(Types.OTHER),
|
franta-hg@92
|
52 |
JAVA_OBJECT(Types.JAVA_OBJECT),
|
franta-hg@92
|
53 |
DISTINCT(Types.DISTINCT),
|
franta-hg@92
|
54 |
STRUCT(Types.STRUCT),
|
franta-hg@92
|
55 |
ARRAY(Types.ARRAY),
|
franta-hg@92
|
56 |
BLOB(Types.BLOB),
|
franta-hg@92
|
57 |
CLOB(Types.CLOB),
|
franta-hg@92
|
58 |
REF(Types.REF),
|
franta-hg@92
|
59 |
DATALINK(Types.DATALINK),
|
franta-hg@68
|
60 |
BOOLEAN(Types.BOOLEAN),
|
franta-hg@92
|
61 |
ROWID(Types.ROWID),
|
franta-hg@92
|
62 |
NCHAR(Types.NCHAR),
|
franta-hg@92
|
63 |
NVARCHAR(Types.NVARCHAR),
|
franta-hg@92
|
64 |
LONGNVARCHAR(Types.LONGNVARCHAR),
|
franta-hg@92
|
65 |
NCLOB(Types.NCLOB),
|
franta-hg@92
|
66 |
SQLXML(Types.SQLXML);
|
franta-hg@92
|
67 |
/** value from java.sql.Types */
|
franta-hg@68
|
68 |
private int code;
|
franta-hg@68
|
69 |
|
franta-hg@68
|
70 |
private SQLType(int code) {
|
franta-hg@68
|
71 |
this.code = code;
|
franta-hg@68
|
72 |
}
|
franta-hg@68
|
73 |
|
franta-hg@68
|
74 |
/**
|
franta-hg@68
|
75 |
* @see java.sql.Types.Types
|
franta-hg@68
|
76 |
*/
|
franta-hg@68
|
77 |
public int getCode() {
|
franta-hg@68
|
78 |
return code;
|
franta-hg@68
|
79 |
}
|
franta-hg@68
|
80 |
|
franta-hg@68
|
81 |
/**
|
franta-hg@68
|
82 |
* @param code see {@linkplain java.sql.Types.Types}
|
franta-hg@68
|
83 |
* @return found SQLType
|
franta-hg@68
|
84 |
* @throws IllegalArgumentException if no data type has given code
|
franta-hg@68
|
85 |
*/
|
franta-hg@68
|
86 |
public SQLType valueOf(int code) {
|
franta-hg@68
|
87 |
for (SQLType t : values()) {
|
franta-hg@68
|
88 |
if (t.code == code) {
|
franta-hg@68
|
89 |
return t;
|
franta-hg@68
|
90 |
}
|
franta-hg@68
|
91 |
}
|
franta-hg@68
|
92 |
throw new IllegalArgumentException("No data type has code: " + code);
|
franta-hg@68
|
93 |
}
|
franta-hg@68
|
94 |
}
|