org.codehaus.modello.generator.database.model

Class TypeMap


public class TypeMap
extends java.lang.Object

A class that maps SQL type names to their JDBC type ID found in java.sql.Types.

 -------------------------------------------------------
 SQL Type      | Java Type            | Peer Type
 -------------------------------------------------------
 CHAR          | String               | String
 VARCHAR       | String               | String
 LONGVARCHAR   | String               | String
 NUMERIC       | java.math.BigDecimal | java.math.BigDecimal
 DECIMAL       | java.math.BigDecimal | java.math.BigDecimal
 BIT           | boolean OR Boolean   | Boolean
 TINYINT       | byte OR Byte         | Byte
 SMALLINT      | short OR Short       | Short
 INTEGER       | int OR Integer       | Integer
 BIGINT        | long OR Long         | Long
 REAL          | float OR Float       | Float
 FLOAT         | double OR Double     | Double
 DOUBLE        | double OR Double     | Double
 BINARY        | byte[]               | ?
 VARBINARY     | byte[]               | ?
 LONGVARBINARY | byte[]               | ?
 DATE          | java.sql.Date        | java.util.Date
 TIME          | java.sql.Time        | java.util.Date
 TIMESTAMP     | java.sql.Timestamp   | java.util.Date
 

------------------------------------------------------- A couple variations have been introduced to cover cases that may arise, but are not covered above BOOLEANCHAR | boolean OR Boolean | String BOOLEANINT | boolean OR Boolean | Integer

Version:
$Revision: 149 $
Authors:
Jason van Zyl
James Strachan

Field Summary

static String
BIGINT
static String
BINARY
static String
BIT
static String
BLOB
static String
BOOLEANCHAR
static String
BOOLEANINT
static String
CHAR
static String
CLOB
static String
DATE
static String
DECIMAL
static String
DOUBLE
static String
FLOAT
static String
INTEGER
static String
LONGVARBINARY
static String
LONGVARCHAR
static String
NUMERIC
static String
REAL
static String
SMALLINT
static String
TIME
static String
TIMESTAMP
static String
TINYINT
static String
VARBINARY
static String
VARCHAR

Method Summary

static int
getJdbcTypeCode(String typeName)
Returns the JDBC type name which maps to java.sql.Types for the given SQL name of type
static String
getJdbcTypeName(int typeCode)
Returns the name which maps to the given java.sql.Types type code
static boolean
isDecimalType(String type)
Returns true if values for the type need have size and scale measurements
static boolean
isDecimalType(int type)
Returns true if values for the type need have size and scale measurements
static boolean
isTextType(String type)
Returns true if values for the type need to be quoted.
static boolean
isTextType(int type)
Returns true if values for the type need to be quoted.
protected static void
registerSqlTypeID(Integer sqlTypeID, String name)
Registers the fact that the given Integer SQL ID maps to the given SQL name

Field Details

BIGINT

public static final String BIGINT

BINARY

public static final String BINARY

BIT

public static final String BIT

BLOB

public static final String BLOB

BOOLEANCHAR

public static final String BOOLEANCHAR

BOOLEANINT

public static final String BOOLEANINT

CHAR

public static final String CHAR

CLOB

public static final String CLOB

DATE

public static final String DATE

DECIMAL

public static final String DECIMAL

DOUBLE

public static final String DOUBLE

FLOAT

public static final String FLOAT

INTEGER

public static final String INTEGER

LONGVARBINARY

public static final String LONGVARBINARY

LONGVARCHAR

public static final String LONGVARCHAR

NUMERIC

public static final String NUMERIC

REAL

public static final String REAL

SMALLINT

public static final String SMALLINT

TIME

public static final String TIME

TIMESTAMP

public static final String TIMESTAMP

TINYINT

public static final String TINYINT

VARBINARY

public static final String VARBINARY

VARCHAR

public static final String VARCHAR

Method Details

getJdbcTypeCode

public static int getJdbcTypeCode(String typeName)
Returns the JDBC type name which maps to java.sql.Types for the given SQL name of type

getJdbcTypeName

public static String getJdbcTypeName(int typeCode)
Returns the name which maps to the given java.sql.Types type code

isDecimalType

public static final boolean isDecimalType(String type)
Returns true if values for the type need have size and scale measurements
Parameters:
type - The type to check.

isDecimalType

public static final boolean isDecimalType(int type)
Returns true if values for the type need have size and scale measurements
Parameters:
type - The type to check.

isTextType

public static final boolean isTextType(String type)
Returns true if values for the type need to be quoted.
Parameters:
type - The type to check.

isTextType

public static final boolean isTextType(int type)
Returns true if values for the type need to be quoted.
Parameters:
type - The type to check.

registerSqlTypeID

protected static void registerSqlTypeID(Integer sqlTypeID,
                                        String name)
Registers the fact that the given Integer SQL ID maps to the given SQL name