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@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@68: VARCHAR(Types.VARCHAR), franta-hg@68: BOOLEAN(Types.BOOLEAN), franta-hg@68: INTEGER(Types.INTEGER), franta-hg@68: DECIMAL(Types.DECIMAL); franta-hg@68: /** franta-hg@68: * TODO: more types franta-hg@68: */ 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@68: public 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: }