I am parsing XML document and am getting strings for various data types as "java.sql.Types.FLOAT","java.sql.Types.INTEGER", "java.sql.Types.VARCHAR" etc..... I have to compare these strings with java.sql.Types constants. Do I need to create a map of all possible java.sql.Types and do
String to integer mapping? Is there better way than creating hashmap of strings to integers. I have this fix but I have to find all possibe java.sql types.
Any better way??
-Mccoy
public static String[] keys = { "java.sql.Types.FLOAT" , "java.sql.Types.INTEGER", "java.sql.Types.VARCHAR" };
public static int[] values = { java.sql.Types.FLOAT,java.sql.Types.INTEGER, java.sql.Types.VARCHAR};
static HashMap theMap = new HashMap();
static {
for (int i = 0; i < values.length ; i++ )
{ theMap.put(keys[i], new Integer(values[i])); }
}
public static int getValue(String token) {
return( ((Integer) theMap.get(token)).intValue() );
}