X-Git-Url: http://git.phpeclipse.com diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/util/sql/TypesHelper.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/util/sql/TypesHelper.java index e8b87f6..feed61e 100644 --- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/util/sql/TypesHelper.java +++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/util/sql/TypesHelper.java @@ -2,10 +2,15 @@ package com.quantum.util.sql; import java.lang.reflect.Field; +import java.lang.reflect.Modifier; import java.sql.Types; /** - * @author holmesbc + * This class provides some utilities for working with Types, as well as providing some + * support around SQL types that exist in certain versions of the JDK. + * + * @author BC Holmes + * @see java.lang.Types */ public class TypesHelper { @@ -37,6 +42,14 @@ public class TypesHelper { public static final int BLOB = Types.BLOB; public static final int CLOB = Types.CLOB; public static final int REF = Types.REF; + /** + *

The constant in the Java programming language, somtimes referred to + * as a type code, that identifies the generic SQL type DATALINK. + * + *

Note: For some reason, some versions of DB2 and/or the DB2 driver use an invalid + * type code for DATALINK. The correct value should be 70, but DB2/NT 7.01.00 uses + * -400. + */ public static final int DATALINK; public static final int BOOLEAN; @@ -56,4 +69,22 @@ public class TypesHelper { return defaultValue; } + public static String getTypeName(int type) { + String name = null; + try { + Field[] fields = TypesHelper.class.getFields(); + for (int i = 0, length = fields == null ? 0 : fields.length; + name == null && i < length; i++) { + if (Modifier.isStatic(fields[i].getModifiers()) + && Modifier.isPublic(fields[i].getModifiers()) + && fields[i].getType() == Integer.TYPE + && type == fields[i].getInt(null)) { + name = fields[i].getName(); + } + } + } catch (IllegalAccessException e) { + } + return name; + } + }