1 16 package com.ibatis.sqlmap.engine.type; 17 18 import java.sql.Types ; 19 import java.util.HashMap ; 20 import java.util.Map ; 21 22 25 public class JdbcTypeRegistry { 26 27 30 public static final int UNKNOWN_TYPE = -99999999; 31 32 private static final Map TYPE_MAP = new HashMap (); 33 34 37 public final static int JDBC_30_DATALINK = 70; 38 39 42 public final static int JDBC_30_BOOLEAN = 16; 43 44 static { 45 initializeTypes(); 46 } 47 48 private JdbcTypeRegistry() { 49 } 50 51 private static void setType(String name, int value) { 52 TYPE_MAP.put(name, new Integer (value)); 53 } 54 55 62 public static int getType(String name) { 63 if (name == null) 64 return UNKNOWN_TYPE; 65 Integer i = (Integer ) TYPE_MAP.get(name); 66 if (i != null) { 67 return i.intValue(); 68 } else { 69 return UNKNOWN_TYPE; 70 } 71 } 72 73 private static void initializeTypes() { 74 setType("ARRAY", Types.ARRAY); 75 setType("BIGINT", Types.BIGINT); 76 setType("BINARY", Types.BINARY); 77 setType("BIT", Types.BIT); 78 setType("BLOB", Types.BLOB); 79 setType("BOOLEAN", JDBC_30_BOOLEAN); 80 setType("CHAR", Types.CHAR); 81 setType("CLOB", Types.CLOB); 82 setType("DATALINK", JDBC_30_DATALINK); 83 setType("DATE", Types.DATE); 84 setType("DECIMAL", Types.DECIMAL); 85 setType("DISTINCT", Types.DISTINCT); 86 setType("DOUBLE", Types.DOUBLE); 87 setType("FLOAT", Types.FLOAT); 88 setType("INTEGER", Types.INTEGER); 89 setType("JAVA_OBJECT", Types.JAVA_OBJECT); 90 setType("LONGVARBINARY", Types.LONGVARBINARY); 91 setType("LONGVARCHAR", Types.LONGVARCHAR); 92 setType("NULL", Types.NULL); 93 setType("NUMERIC", Types.NUMERIC); 94 setType("OTHER", Types.OTHER); 95 setType("REAL", Types.REAL); 96 setType("REF", Types.REF); 97 setType("SMALLINT", Types.SMALLINT); 98 setType("STRUCT", Types.STRUCT); 99 setType("TIME", Types.TIME); 100 setType("TIMESTAMP", Types.TIMESTAMP); 101 setType("TINYINT", Types.TINYINT); 102 setType("VARBINARY", Types.VARBINARY); 103 setType("VARCHAR", Types.VARCHAR); 104 105 setType("CH", Types.CHAR); 106 setType("VC", Types.VARCHAR); 107 108 setType("DT", Types.DATE); 109 setType("TM", Types.TIME); 110 setType("TS", Types.TIMESTAMP); 111 112 setType("NM", Types.NUMERIC); 113 setType("II", Types.INTEGER); 114 setType("BI", Types.BIGINT); 115 setType("SI", Types.SMALLINT); 116 setType("TI", Types.TINYINT); 117 118 setType("DC", Types.DECIMAL); 119 setType("DB", Types.DOUBLE); 120 setType("FL", Types.FLOAT); 121 122 setType("ORACLECURSOR", -10); 123 124 } 125 126 } 127 | Popular Tags |