--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/java/sql-dk/src/main/java/info/globalcode/sql/dk/SQLType.java Mon Mar 04 20:15:24 2019 +0100
@@ -0,0 +1,95 @@
+/**
+ * SQL-DK
+ * Copyright © 2013 František Kučera (frantovo.cz)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package info.globalcode.sql.dk;
+
+import java.sql.Types;
+
+/**
+ * Data types of SQL parameters.
+ *
+ * @author Ing. František Kučera (frantovo.cz)
+ */
+public enum SQLType {
+
+ /**
+ * Names must be upper case – user input is also converted to upper case → case insensitive
+ */
+ BIT(Types.BIT),
+ TINYINT(Types.TINYINT),
+ SMALLINT(Types.SMALLINT),
+ INTEGER(Types.INTEGER),
+ BIGINT(Types.BIGINT),
+ FLOAT(Types.FLOAT),
+ REAL(Types.REAL),
+ DOUBLE(Types.DOUBLE),
+ NUMERIC(Types.NUMERIC),
+ DECIMAL(Types.DECIMAL),
+ CHAR(Types.CHAR),
+ VARCHAR(Types.VARCHAR),
+ LONGVARCHAR(Types.LONGVARCHAR),
+ DATE(Types.DATE),
+ TIME(Types.TIME),
+ TIMESTAMP(Types.TIMESTAMP),
+ BINARY(Types.BINARY),
+ VARBINARY(Types.VARBINARY),
+ LONGVARBINARY(Types.LONGVARBINARY),
+ NULL(Types.NULL),
+ OTHER(Types.OTHER),
+ JAVA_OBJECT(Types.JAVA_OBJECT),
+ DISTINCT(Types.DISTINCT),
+ STRUCT(Types.STRUCT),
+ ARRAY(Types.ARRAY),
+ BLOB(Types.BLOB),
+ CLOB(Types.CLOB),
+ REF(Types.REF),
+ DATALINK(Types.DATALINK),
+ BOOLEAN(Types.BOOLEAN),
+ ROWID(Types.ROWID),
+ NCHAR(Types.NCHAR),
+ NVARCHAR(Types.NVARCHAR),
+ LONGNVARCHAR(Types.LONGNVARCHAR),
+ NCLOB(Types.NCLOB),
+ SQLXML(Types.SQLXML);
+ /** value from java.sql.Types */
+ private int code;
+
+ private SQLType(int code) {
+ this.code = code;
+ }
+
+ /**
+ * @see java.sql.Types.Types
+ */
+ public int getCode() {
+ return code;
+ }
+
+ /**
+ * @param code see {@linkplain java.sql.Types.Types}
+ * @return found SQLType
+ * @throws IllegalArgumentException if no data type has given code
+ */
+ public static SQLType valueOf(int code) {
+ for (SQLType t : values()) {
+ if (t.code == code) {
+ return t;
+ }
+ }
+ throw new IllegalArgumentException("No data type has code: " + code);
+ }
+}