1 package org.apache.ojb.tools.mapping.reversedb; 2 3 17 18 19 import java.sql.Types ; 20 21 26 27 public class Utilities 28 { 29 public static final java.util.Map hmJDBCTypeToName 30 = new java.util.HashMap (); 31 public static final java.util.Map mJDBCNameToType 32 = new java.util.TreeMap (); 33 34 public static final java.util.Vector vJDBCTypeNames = new java.util.Vector (); 35 36 public static final java.util.HashMap hmJDBCTypeToJavaType 37 = new java.util.HashMap (); 38 39 public static final java.util.Vector vJavaTypes = new java.util.Vector (); 40 41 static 42 { 43 hmJDBCTypeToName.put(new Integer (Types.ARRAY), "ARRAY"); 44 hmJDBCTypeToName.put(new Integer (Types.BIGINT), "BIGINT"); 45 hmJDBCTypeToName.put(new Integer (Types.BINARY), "BINARY"); 46 hmJDBCTypeToName.put(new Integer (Types.BIT), "BIT"); 47 hmJDBCTypeToName.put(new Integer (Types.BLOB), "BLOB"); 48 hmJDBCTypeToName.put(new Integer (Types.CHAR), "CHAR"); 49 hmJDBCTypeToName.put(new Integer (Types.CLOB), "CLOB"); 50 hmJDBCTypeToName.put(new Integer (Types.DATE), "DATE"); 51 hmJDBCTypeToName.put(new Integer (Types.DECIMAL), "DECIMAL"); 52 hmJDBCTypeToName.put(new Integer (Types.DISTINCT), "DISTINCT"); 53 hmJDBCTypeToName.put(new Integer (Types.DOUBLE), "DOUBLE"); 54 hmJDBCTypeToName.put(new Integer (Types.FLOAT), "FLOAT"); 55 hmJDBCTypeToName.put(new Integer (Types.INTEGER), "INTEGER"); 56 hmJDBCTypeToName.put(new Integer (Types.JAVA_OBJECT), "OBJECT"); 57 hmJDBCTypeToName.put(new Integer (Types.LONGVARBINARY), "LONGVARBINARY"); 58 hmJDBCTypeToName.put(new Integer (Types.LONGVARCHAR), "LONGVARCHAR"); 59 hmJDBCTypeToName.put(new Integer (Types.NULL), "NULL"); 60 hmJDBCTypeToName.put(new Integer (Types.NUMERIC), "NUMERIC"); 61 hmJDBCTypeToName.put(new Integer (Types.OTHER), "OTHER"); 62 hmJDBCTypeToName.put(new Integer (Types.REAL), "REAL"); 63 hmJDBCTypeToName.put(new Integer (Types.REF), "REF"); 64 hmJDBCTypeToName.put(new Integer (Types.SMALLINT), "SMALLINT"); 65 hmJDBCTypeToName.put(new Integer (Types.STRUCT), "STRUCT"); 66 hmJDBCTypeToName.put(new Integer (Types.TIME), "TIME"); 67 hmJDBCTypeToName.put(new Integer (Types.TIMESTAMP), "TIMESTAMP"); 68 hmJDBCTypeToName.put(new Integer (Types.TINYINT), "TINYINT"); 69 hmJDBCTypeToName.put(new Integer (Types.VARBINARY), "VARBINARY"); 70 hmJDBCTypeToName.put(new Integer (Types.VARCHAR), "VARCHAR"); 71 72 java.util.Iterator it = hmJDBCTypeToName.entrySet().iterator(); 74 while (it.hasNext()) 75 { 76 java.util.Map.Entry aEntry = (java.util.Map.Entry)it.next(); 77 mJDBCNameToType.put (aEntry.getValue(), aEntry.getKey()); 78 } 79 80 hmJDBCTypeToJavaType.put(new Integer (Types.ARRAY), "Object[]"); 81 hmJDBCTypeToJavaType.put(new Integer (Types.BIGINT), "Long"); 82 hmJDBCTypeToJavaType.put(new Integer (Types.BINARY), "byte[]"); 83 hmJDBCTypeToJavaType.put(new Integer (Types.BIT), "Byte"); 84 hmJDBCTypeToJavaType.put(new Integer (Types.BLOB), "byte[]"); 85 hmJDBCTypeToJavaType.put(new Integer (Types.CHAR), "String"); 86 hmJDBCTypeToJavaType.put(new Integer (Types.CLOB), "String"); 87 hmJDBCTypeToJavaType.put(new Integer (Types.DATE), "java.sql.Date"); 88 hmJDBCTypeToJavaType.put(new Integer (Types.DECIMAL), "Long"); 89 hmJDBCTypeToJavaType.put(new Integer (Types.DISTINCT), "????"); 90 hmJDBCTypeToJavaType.put(new Integer (Types.DOUBLE), "Double"); 91 hmJDBCTypeToJavaType.put(new Integer (Types.FLOAT), "Double"); 92 hmJDBCTypeToJavaType.put(new Integer (Types.INTEGER), "Long"); 93 hmJDBCTypeToJavaType.put(new Integer (Types.JAVA_OBJECT), "Object"); 94 hmJDBCTypeToJavaType.put(new Integer (Types.LONGVARBINARY), "byte[]"); 95 hmJDBCTypeToJavaType.put(new Integer (Types.LONGVARCHAR), "byte[]"); 96 hmJDBCTypeToJavaType.put(new Integer (Types.NULL), "Object"); 97 hmJDBCTypeToJavaType.put(new Integer (Types.NUMERIC), "Long"); 98 hmJDBCTypeToJavaType.put(new Integer (Types.OTHER), "Object"); 99 hmJDBCTypeToJavaType.put(new Integer (Types.REAL), "Long"); 100 hmJDBCTypeToJavaType.put(new Integer (Types.REF), "Object"); 101 hmJDBCTypeToJavaType.put(new Integer (Types.SMALLINT), "Long"); 102 hmJDBCTypeToJavaType.put(new Integer (Types.STRUCT), "Object"); 103 hmJDBCTypeToJavaType.put(new Integer (Types.TIME), "java.sql.Time"); 104 hmJDBCTypeToJavaType.put(new Integer (Types.TIMESTAMP), "java.sql.Timestamp"); 105 hmJDBCTypeToJavaType.put(new Integer (Types.TINYINT), "Long"); 106 hmJDBCTypeToJavaType.put(new Integer (Types.VARBINARY), "byte[]"); 107 hmJDBCTypeToJavaType.put(new Integer (Types.VARCHAR), "String"); 108 109 vJavaTypes.addAll(new java.util.TreeSet (hmJDBCTypeToJavaType.values())); 110 java.util.Collections.sort(vJavaTypes); 111 112 vJDBCTypeNames.addAll(new java.util.TreeSet (hmJDBCTypeToName.values())); 113 java.util.Collections.sort(vJDBCTypeNames); 114 } 115 116 117 private Utilities () 118 { 119 } 120 121 public static String getTypeNameFromJDBCType(int jdbcType) 122 { 123 return (String )Utilities.hmJDBCTypeToName.get(new Integer (jdbcType)); 124 } 125 } 126 127 187 | Popular Tags |