org.brains2b.sql.meta
Class TypesInfo

java.lang.Object
  extended by org.brains2b.sql.meta.TypesInfo

public class TypesInfo
extends java.lang.Object

Types to Java Static class to translate java.sql.Types into appropriate Java types At the moment only primitives, String and java.sql.Date,Time,Timestamp are used

Version:
0.32.1 [13-04-2008]
Author:
dennis@brains2b.nl

Field Summary
static TypesInfo DEFAULT
           
static int LARGE
           
static int OPTIMIZE
           
static int SMALLEST
           
 
Constructor Summary
TypesInfo(java.sql.Connection con)
           
 
Method Summary
 int getDataType(java.lang.Class c)
          get the java.sql.Types value for a given class
 java.lang.Class getJavaType(int dataType, int columnsize, int decimaldigits)
          gets a Class as a valid java type on the basis of JDBC column information
 java.lang.String getJavaTypeName(int dataType, int columnsize, int decimaldigits)
          gets a String representation of a valid java type on the basis of JDBC column information
 java.lang.String getLimitRows(int count)
           
 java.lang.String getSQLType(int dataType)
           
 java.util.Collection getTypeNames()
           
 java.util.HashMap getTypes()
           
 boolean isPrimitive(int dataType)
          get the JavaType for a specific dataType as defined in java.sql.Types
 void setDataModel(int dataModel)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT

public static final TypesInfo DEFAULT

SMALLEST

public static final int SMALLEST
See Also:
Constant Field Values

OPTIMIZE

public static final int OPTIMIZE
See Also:
Constant Field Values

LARGE

public static final int LARGE
See Also:
Constant Field Values
Constructor Detail

TypesInfo

public TypesInfo(java.sql.Connection con)
Method Detail

getDataType

public int getDataType(java.lang.Class c)
get the java.sql.Types value for a given class

Parameters:
c - Class, the class for which the java.sql.Types value is requested
Returns:
int, a number representing a constant from java.sql.Types

getJavaTypeName

public java.lang.String getJavaTypeName(int dataType,
                                        int columnsize,
                                        int decimaldigits)
gets a String representation of a valid java type on the basis of JDBC column information

Normally the dataType is enough to make a good determination, except in the case of Numbers.


isPrimitive

public boolean isPrimitive(int dataType)
get the JavaType for a specific dataType as defined in java.sql.Types

This method returns only one of two values PRIMITIVE or CLASS

Parameters:
dataType - int, the datatype as defined in java.sql.Types
Returns:
int, the java type for the dataType submitted, either returns one of the constants PRIMITIVE or CLASS

Note:Please be sure to understand that the determination is not done for all Types if you miss one add it yourself or mail me.


getJavaType

public java.lang.Class getJavaType(int dataType,
                                   int columnsize,
                                   int decimaldigits)
gets a Class as a valid java type on the basis of JDBC column information

Normally the dataType is enough to make a good determination, except in the case of Numbers.


getLimitRows

public java.lang.String getLimitRows(int count)

getSQLType

public java.lang.String getSQLType(int dataType)

getTypeNames

public java.util.Collection getTypeNames()

getTypes

public java.util.HashMap getTypes()

setDataModel

public void setDataModel(int dataModel)