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