001: /* ***** BEGIN LICENSE BLOCK *****
002: * Version: MPL 1.1
003: * The contents of this file are subject to the Mozilla Public License Version
004: * 1.1 (the "License"); you may not use this file except in compliance with
005: * the License. You may obtain a copy of the License at
006: * http://www.mozilla.org/MPL/
007: *
008: * Software distributed under the License is distributed on an "AS IS" basis,
009: * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
010: * for the specific language governing rights and limitations under the
011: * License.
012: *
013: * The Original Code is Riot.
014: *
015: * The Initial Developer of the Original Code is
016: * Neteye GmbH.
017: * Portions created by the Initial Developer are Copyright (C) 2006
018: * the Initial Developer. All Rights Reserved.
019: *
020: * Contributor(s):
021: * Felix Gnass [fgnass at neteye dot de]
022: *
023: * ***** END LICENSE BLOCK ***** */
024: package org.riotfamily.revolt.support;
025:
026: import java.sql.Types;
027: import java.util.HashMap;
028: import java.util.Map;
029:
030: /**
031: * @author Felix Gnass [fgnass at neteye dot de]
032: *
033: */
034: public class TypeMap {
035:
036: public final static String BIT = "BIT";
037:
038: public final static String TINYINT = "TINYINT";
039:
040: public final static String SMALLINT = "SMALLINT";
041:
042: public final static String INTEGER = "INTEGER";
043:
044: public final static String BIGINT = "BIGINT";
045:
046: public final static String FLOAT = "FLOAT";
047:
048: public final static String REAL = "REAL";
049:
050: public final static String DOUBLE = "DOUBLE";
051:
052: public final static String NUMERIC = "NUMERIC";
053:
054: public final static String DECIMAL = "DECIMAL";
055:
056: public final static String CHAR = "CHAR";
057:
058: public final static String VARCHAR = "VARCHAR";
059:
060: public final static String LONGVARCHAR = "LONGVARCHAR";
061:
062: public final static String DATE = "DATE";
063:
064: public final static String TIME = "TIME";
065:
066: public final static String TIMESTAMP = "TIMESTAMP";
067:
068: public final static String BINARY = "BINARY";
069:
070: public final static String VARBINARY = "VARBINARY";
071:
072: public final static String LONGVARBINARY = "LONGVARBINARY";
073:
074: public final static String BLOB = "BLOB";
075:
076: public final static String CLOB = "CLOB";
077:
078: private static HashMap jdbcTypes = new HashMap();
079:
080: static {
081: jdbcTypes.put(BIT, new Integer(Types.BIT));
082: jdbcTypes.put(TINYINT, new Integer(Types.TINYINT));
083: jdbcTypes.put(SMALLINT, new Integer(Types.SMALLINT));
084: jdbcTypes.put(INTEGER, new Integer(Types.INTEGER));
085: jdbcTypes.put(BIGINT, new Integer(Types.BIGINT));
086: jdbcTypes.put(FLOAT, new Integer(Types.FLOAT));
087: jdbcTypes.put(REAL, new Integer(Types.REAL));
088: jdbcTypes.put(DOUBLE, new Integer(Types.DOUBLE));
089: jdbcTypes.put(NUMERIC, new Integer(Types.NUMERIC));
090: jdbcTypes.put(DECIMAL, new Integer(Types.DECIMAL));
091: jdbcTypes.put(CHAR, new Integer(Types.CHAR));
092: jdbcTypes.put(VARCHAR, new Integer(Types.VARCHAR));
093: jdbcTypes.put(LONGVARCHAR, new Integer(Types.LONGVARCHAR));
094: jdbcTypes.put(DATE, new Integer(Types.DATE));
095: jdbcTypes.put(TIME, new Integer(Types.TIME));
096: jdbcTypes.put(TIMESTAMP, new Integer(Types.TIMESTAMP));
097: jdbcTypes.put(BINARY, new Integer(Types.BINARY));
098: jdbcTypes.put(VARBINARY, new Integer(Types.VARBINARY));
099: jdbcTypes.put(LONGVARBINARY, new Integer(Types.LONGVARBINARY));
100: jdbcTypes.put(BLOB, new Integer(Types.BLOB));
101: jdbcTypes.put(CLOB, new Integer(Types.CLOB));
102: }
103:
104: public static int getJdbcType(String name) {
105: Integer i = (Integer) jdbcTypes.get(name.toUpperCase());
106: if (i != null) {
107: return i.intValue();
108: }
109: return Types.NULL;
110: }
111:
112: public static boolean isComplete(Map map) {
113: return map.keySet().containsAll(jdbcTypes.keySet());
114: }
115: }
|