1 19 20 package org.netbeans.modules.dbschema.util; 21 22 import java.util.ResourceBundle ; 23 import java.sql.Types ; 24 25 public class SQLTypeUtil extends Object { 26 27 29 33 public static String getString (String key) { 34 return ResourceBundle.getBundle("org.netbeans.modules.dbschema.resources.Bundle").getString(key); 35 } 36 37 39 43 static public String getSqlTypeString (int sqlType) { 44 switch(sqlType) { 45 case Types.BIGINT: 46 return getString("SQL_BIGINT"); case Types.BINARY: 48 return getString("SQL_BINARY"); case Types.BIT: 50 return getString("SQL_BIT"); case Types.CHAR: 52 return getString("SQL_CHAR"); case Types.DATE: 54 return getString("SQL_DATE"); case Types.DECIMAL: 56 return getString("SQL_DECIMAL"); case Types.DOUBLE: 58 return getString("SQL_DOUBLE"); case Types.FLOAT: 60 return getString("SQL_FLOAT"); case Types.INTEGER: 62 return getString("SQL_INTEGER"); case Types.LONGVARBINARY: 64 return getString("SQL_LONGVARBINARY"); case Types.LONGVARCHAR: 66 return getString("SQL_LONGVARCHAR"); case Types.NULL: 68 return getString("SQL_NULL"); case Types.NUMERIC: 70 return getString("SQL_NUMERIC"); case Types.OTHER: 72 return getString("SQL_OTHER"); case Types.REAL: 74 return getString("SQL_REAL"); case Types.SMALLINT: 76 return getString("SQL_SMALLINT"); case Types.TIME: 78 return getString("SQL_TIME"); case Types.TIMESTAMP: 80 return getString("SQL_TIMESTAMP"); case Types.TINYINT: 82 return getString("SQL_TINYINT"); case Types.VARBINARY: 84 return getString("SQL_VARBINARY"); case Types.VARCHAR: 86 return getString("SQL_VARCHAR"); case Types.JAVA_OBJECT: 88 return getString("SQL_JAVA_OBJECT"); case Types.DISTINCT: 90 return getString("SQL_DISTINCT"); case Types.STRUCT: 92 return getString("SQL_STRUCT"); case Types.ARRAY: 94 return getString("SQL_ARRAY"); case Types.BLOB: 96 return getString("SQL_BLOB"); case Types.CLOB: 98 return getString("SQL_CLOB"); case Types.REF: 100 return getString("SQL_REF"); default: 102 return getString("SQL_UNKNOWN"); } 104 } 105 106 110 static public boolean isNumeric (int type) { 111 switch (type) { 112 case Types.BIGINT: 113 case Types.BIT: 114 case Types.DECIMAL: 115 case Types.DOUBLE: 116 case Types.FLOAT: 117 case Types.INTEGER: 118 case Types.NUMERIC: 119 case Types.REAL: 120 case Types.SMALLINT: 121 case Types.TINYINT: 122 return true; 123 } 124 125 return false; 126 } 127 128 132 static public boolean isCharacter (int type) { 133 switch (type) { 134 case Types.BINARY: 135 case Types.CHAR: 136 case Types.LONGVARCHAR: 137 case Types.VARCHAR: 138 case Types.VARBINARY: 139 return true; 140 } 141 142 return false; 143 } 144 145 150 static public boolean isBlob (int type) { 151 switch (type) { 152 case Types.BLOB: 153 case Types.CLOB: 154 case Types.BINARY: 155 case Types.VARBINARY: 156 case Types.LONGVARBINARY: 157 case Types.OTHER: 158 return true; 159 } 160 161 return false; 162 } 163 164 173 static public boolean isLob (int type) { 174 return (isBlob(type) || (Types.CLOB == type) || 175 (Types.LONGVARCHAR == type)); 176 } 177 178 183 static public boolean isCompatibleType (int type1, int type2) { 184 return ((type1 == type2) 185 || (isCharacter(type1) && isCharacter(type2)) 186 || (isNumeric(type1) && isNumeric(type2)) 187 || (isBlob(type1) && isBlob(type2)) 188 ); 189 } 190 } 191 | Popular Tags |