From: Chad B. <cwb...@us...> - 2004-06-30 23:50:34
|
User: cwbrandon Date: 04/06/30 16:50:28 Added: etc/schema2xmi/src/java/org/andromda/schema2xmi JDBCTypeFinder.java Log: Add JDBCTypeFinder Revision Changes Path 1.1 productbuild/etc/schema2xmi/src/java/org/andromda/schema2xmi/JDBCTypeFinder.java Index: JDBCTypeFinder.java =================================================================== package org.andromda.schema2xmi; import java.lang.reflect.Field; import java.sql.Types; import java.util.HashMap; import java.util.Map; /** * <p> * Provides the ability to find a <code>java.sql.Types</code> field name * based on an int value. * </p> * * @author Chad Brandon */ public class JDBCTypeFinder { private static final Map jdbcTypes = new HashMap(); /** * Initialize the <code>jdbcTypes</code> Map. */ static { try { Field fields[] = Types.class.getFields(); int fieldsNum = fields.length; Field field; for (int ctr = 0; ctr < fieldsNum; ctr++) { field = fields[ctr]; jdbcTypes.put(field.get(null), field.getName()); } } catch (Throwable th) { throw new SchemaTransformerException(th); } } /** * Finds the name of the <code>jdbcType</code> passed in, or null if there * is no type in the java.sql.Types class matching the given * <code>jdbcType</code>. * * @param jdbcType the JDBC type to find. * @return the JDBC type name. */ public static String findTypeName(int jdbcType) { return (String)jdbcTypes.get(new Integer(jdbcType)); } } |