org.rimudb.types
Class DatabaseTypes

java.lang.Object
  extended by org.rimudb.types.DatabaseTypes

public class DatabaseTypes
extends java.lang.Object


Field Summary
static AbstractDatabaseType ARRAY
           
static AbstractDatabaseType BIGINT
           
static AbstractDatabaseType BINARY
           
static AbstractDatabaseType BIT
           
static AbstractDatabaseType BLOB
           
static AbstractDatabaseType BOOLEAN
           
static AbstractDatabaseType CHAR
           
static java.util.Map<java.lang.String,AbstractDatabaseType> classTypeMap
           
static AbstractDatabaseType CLOB
           
static AbstractDatabaseType DATALINK
           
static AbstractDatabaseType DATE
           
static AbstractDatabaseType DECIMAL
           
static AbstractDatabaseType DOUBLE
           
static AbstractDatabaseType FLOAT
           
static AbstractDatabaseType INTEGER
           
static AbstractDatabaseType JAVA_OBJECT
           
static AbstractDatabaseType LONGVARBINARY
           
static AbstractDatabaseType LONGVARCHAR
           
static AbstractDatabaseType NUMERIC
           
static AbstractDatabaseType REAL
           
static AbstractDatabaseType SMALLINT
           
static AbstractDatabaseType TIME
           
static AbstractDatabaseType TIMESTAMP
           
static AbstractDatabaseType TINYINT
           
static java.util.Map<java.lang.Integer,AbstractDatabaseType> typeMap
           
static AbstractDatabaseType VARBINARY
           
static AbstractDatabaseType VARCHAR
           
 
Constructor Summary
DatabaseTypes()
           
 
Method Summary
static int convertNameToSQLType(java.lang.String sqlName)
           
static int convertSQLTypeStringToSQLType(java.lang.String sqlTypeStr)
          Return the sqlType for a 'Types.xxxx' value.
static java.lang.String convertSQLTypeToDDS(int sqlType)
          Return the equivalent DDS type code for an sqlType.
static java.lang.String convertSQLTypeToJavaClassOrPrimitive(int sqlType)
          Return the class that is suitable for declaring a variable that will use this sqlType.
static java.lang.String convertSQLTypeToJavaWrapperClass(int sqlType)
          Return the class that is suitable for wrapping this sqlType.
static java.lang.String convertSQLTypeToName(int sqlType)
          Return the name of an SQL type.
static java.lang.String convertSQLTypeToSQLTypeString(int sqlType)
          Return an String containing the equivalent 'Types.xxxx' value for an sqlType.
static java.lang.String[] getAllTypes()
          Return all the database types as an array of Strings.
static java.lang.Object getDefaultValue(int sqlType)
           
static java.lang.Object getResultSetValue(java.sql.ResultSet rs, int columnIndex, int sqlType)
           
static boolean hasPrecision(int sqlType)
           
static boolean hasScale(int sqlType)
           
static boolean isTypeAssignableFromString(int sqlType)
          Return true if this sqlType maps to a String.
static void setParameterValue(java.sql.PreparedStatement ps, int parameterIndex, int sqlType, java.lang.Object value, int valueLength, boolean doVersionIncrement)
           
static void setParameterValue(java.sql.PreparedStatement ps, int parameterIndex, java.lang.Object value, int valueLength)
           
static boolean typeMatchesValueClass(int sqlType, java.lang.Object value)
          Return true if the class of the value matches the sqlType.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ARRAY

public static final AbstractDatabaseType ARRAY

BIGINT

public static final AbstractDatabaseType BIGINT

BINARY

public static final AbstractDatabaseType BINARY

BIT

public static final AbstractDatabaseType BIT

BLOB

public static final AbstractDatabaseType BLOB

BOOLEAN

public static final AbstractDatabaseType BOOLEAN

CHAR

public static final AbstractDatabaseType CHAR

CLOB

public static final AbstractDatabaseType CLOB

DATALINK

public static final AbstractDatabaseType DATALINK

DATE

public static final AbstractDatabaseType DATE

DECIMAL

public static final AbstractDatabaseType DECIMAL

DOUBLE

public static final AbstractDatabaseType DOUBLE

FLOAT

public static final AbstractDatabaseType FLOAT

INTEGER

public static final AbstractDatabaseType INTEGER

JAVA_OBJECT

public static final AbstractDatabaseType JAVA_OBJECT

LONGVARBINARY

public static final AbstractDatabaseType LONGVARBINARY

LONGVARCHAR

public static final AbstractDatabaseType LONGVARCHAR

NUMERIC

public static final AbstractDatabaseType NUMERIC

REAL

public static final AbstractDatabaseType REAL

SMALLINT

public static final AbstractDatabaseType SMALLINT

TINYINT

public static final AbstractDatabaseType TINYINT

TIME

public static final AbstractDatabaseType TIME

TIMESTAMP

public static final AbstractDatabaseType TIMESTAMP

VARBINARY

public static final AbstractDatabaseType VARBINARY

VARCHAR

public static final AbstractDatabaseType VARCHAR

typeMap

public static java.util.Map<java.lang.Integer,AbstractDatabaseType> typeMap

classTypeMap

public static java.util.Map<java.lang.String,AbstractDatabaseType> classTypeMap
Constructor Detail

DatabaseTypes

public DatabaseTypes()
Method Detail

getAllTypes

public static java.lang.String[] getAllTypes()
Return all the database types as an array of Strings.

Returns:
String[]

convertSQLTypeToName

public static java.lang.String convertSQLTypeToName(int sqlType)
Return the name of an SQL type.

Parameters:
sqlType - int
Returns:
String

convertSQLTypeStringToSQLType

public static int convertSQLTypeStringToSQLType(java.lang.String sqlTypeStr)
Return the sqlType for a 'Types.xxxx' value.

Parameters:
sqlTypeStr - String
Returns:
int

convertSQLTypeToDDS

public static java.lang.String convertSQLTypeToDDS(int sqlType)
Return the equivalent DDS type code for an sqlType. Note that DDS only supports the most basic column types.

Parameters:
sqlType - int
Returns:
String

convertSQLTypeToSQLTypeString

public static java.lang.String convertSQLTypeToSQLTypeString(int sqlType)
Return an String containing the equivalent 'Types.xxxx' value for an sqlType.

Parameters:
sqlType -
Returns:
String

convertSQLTypeToJavaWrapperClass

public static java.lang.String convertSQLTypeToJavaWrapperClass(int sqlType)
Return the class that is suitable for wrapping this sqlType.

Parameters:
sqlType - int
Returns:
String

convertSQLTypeToJavaClassOrPrimitive

public static java.lang.String convertSQLTypeToJavaClassOrPrimitive(int sqlType)
Return the class that is suitable for declaring a variable that will use this sqlType.

Parameters:
sqlType - int
Returns:
String

hasScale

public static boolean hasScale(int sqlType)

hasPrecision

public static boolean hasPrecision(int sqlType)

convertNameToSQLType

public static int convertNameToSQLType(java.lang.String sqlName)

getResultSetValue

public static java.lang.Object getResultSetValue(java.sql.ResultSet rs,
                                                 int columnIndex,
                                                 int sqlType)
                                          throws java.sql.SQLException
Throws:
java.sql.SQLException

getDefaultValue

public static java.lang.Object getDefaultValue(int sqlType)

setParameterValue

public static void setParameterValue(java.sql.PreparedStatement ps,
                                     int parameterIndex,
                                     int sqlType,
                                     java.lang.Object value,
                                     int valueLength,
                                     boolean doVersionIncrement)
                              throws java.sql.SQLException
Throws:
java.sql.SQLException

setParameterValue

public static void setParameterValue(java.sql.PreparedStatement ps,
                                     int parameterIndex,
                                     java.lang.Object value,
                                     int valueLength)
                              throws java.sql.SQLException
Throws:
java.sql.SQLException

typeMatchesValueClass

public static boolean typeMatchesValueClass(int sqlType,
                                            java.lang.Object value)
Return true if the class of the value matches the sqlType.

Parameters:
sqlType -
value -
Returns:
boolean

isTypeAssignableFromString

public static boolean isTypeAssignableFromString(int sqlType)
Return true if this sqlType maps to a String.

Parameters:
sqlType -
Returns:
boolean


Copyright © 2008-2011 Simon Ritchie. All Rights Reserved.