org.apache.torque.templates.typemapping
Class TypeMap

java.lang.Object
  extended by org.apache.torque.templates.typemapping.TypeMap

public final class TypeMap
extends Object

Various mappings for schema types, e.g. to their corresponding Java object types, and Java native types. These are the official SQL type to Java type mappings. These don't quite correspond to the way the peer system works so we'll have to make some adjustments.

 -------------------------------------------------------
 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:
$Id: TypeMap.java 1331196 2012-04-27 02:56:12Z tfischer $
Author:
Jason van Zyl,
Field Summary
static String BIGINT_OBJECT_TYPE
           
static String BINARY_OBJECT_TYPE
           
static String BIT_OBJECT_TYPE
           
static String BLOB_OBJECT_TYPE
           
static String BOOLEANCHAR_OBJECT_TYPE
           
static String BOOLEANINT_OBJECT_TYPE
           
static String CHAR_OBJECT_TYPE
           
static String CLOB_OBJECT_TYPE
           
static String DATE_OBJECT_TYPE
           
static String DECIMAL_OBJECT_TYPE
           
static String DOUBLE_OBJECT_TYPE
           
static String FLOAT_OBJECT_TYPE
           
static String INTEGER_OBJECT_TYPE
           
static String LONGVARBINARY_OBJECT_TYPE
           
static String LONGVARCHAR_OBJECT_TYPE
           
static String NUMERIC_OBJECT_TYPE
           
static String REAL_OBJECT_TYPE
           
static String SMALLINT_OBJECT_TYPE
           
static String TIME_OBJECT_TYPE
           
static String TIMESTAMP_OBJECT_TYPE
           
static String TINYINT_OBJECT_TYPE
           
static String VARBINARY_OBJECT_TYPE
           
static String VARCHAR_OBJECT_TYPE
           
 
Method Summary
static String getJavaObject(SchemaType jdbcType)
          Return a Java object which corresponds to the JDBC type provided.
static JavaType getJavaObjectType(SchemaType schemaType)
          Returns the java type which corresponds to the schema type provided.
static JavaType getJavaPrimitiveType(SchemaType schemaType)
          Returns the java type which corresponds to the schema type provided.
static ResultSetGetter getResultSetGetter(SchemaType schemaType)
          Returns the result set getter method which corresponds to the Schema type provided.
static boolean isBit(SchemaType type)
          Returns true if the type is boolean in the java object and a Bit "1" or "0" in the db.
static boolean isBooleanChar(SchemaType type)
          Returns true if the type is boolean in the java object and a String "Y" or "N" in the db.
static boolean isBooleanInt(SchemaType type)
          Returns true if the type is boolean in the java object and a numeric (1 or 0) in the db.
static boolean isTextType(SchemaType type)
          Returns true if values for the type need to be quoted.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CHAR_OBJECT_TYPE

public static final String CHAR_OBJECT_TYPE
See Also:
Constant Field Values

VARCHAR_OBJECT_TYPE

public static final String VARCHAR_OBJECT_TYPE
See Also:
Constant Field Values

LONGVARCHAR_OBJECT_TYPE

public static final String LONGVARCHAR_OBJECT_TYPE
See Also:
Constant Field Values

CLOB_OBJECT_TYPE

public static final String CLOB_OBJECT_TYPE
See Also:
Constant Field Values

NUMERIC_OBJECT_TYPE

public static final String NUMERIC_OBJECT_TYPE
See Also:
Constant Field Values

DECIMAL_OBJECT_TYPE

public static final String DECIMAL_OBJECT_TYPE
See Also:
Constant Field Values

BIT_OBJECT_TYPE

public static final String BIT_OBJECT_TYPE
See Also:
Constant Field Values

TINYINT_OBJECT_TYPE

public static final String TINYINT_OBJECT_TYPE
See Also:
Constant Field Values

SMALLINT_OBJECT_TYPE

public static final String SMALLINT_OBJECT_TYPE
See Also:
Constant Field Values

INTEGER_OBJECT_TYPE

public static final String INTEGER_OBJECT_TYPE
See Also:
Constant Field Values

BIGINT_OBJECT_TYPE

public static final String BIGINT_OBJECT_TYPE
See Also:
Constant Field Values

REAL_OBJECT_TYPE

public static final String REAL_OBJECT_TYPE
See Also:
Constant Field Values

FLOAT_OBJECT_TYPE

public static final String FLOAT_OBJECT_TYPE
See Also:
Constant Field Values

DOUBLE_OBJECT_TYPE

public static final String DOUBLE_OBJECT_TYPE
See Also:
Constant Field Values

BINARY_OBJECT_TYPE

public static final String BINARY_OBJECT_TYPE
See Also:
Constant Field Values

VARBINARY_OBJECT_TYPE

public static final String VARBINARY_OBJECT_TYPE
See Also:
Constant Field Values

LONGVARBINARY_OBJECT_TYPE

public static final String LONGVARBINARY_OBJECT_TYPE
See Also:
Constant Field Values

BLOB_OBJECT_TYPE

public static final String BLOB_OBJECT_TYPE
See Also:
Constant Field Values

DATE_OBJECT_TYPE

public static final String DATE_OBJECT_TYPE
See Also:
Constant Field Values

TIME_OBJECT_TYPE

public static final String TIME_OBJECT_TYPE
See Also:
Constant Field Values

TIMESTAMP_OBJECT_TYPE

public static final String TIMESTAMP_OBJECT_TYPE
See Also:
Constant Field Values

BOOLEANCHAR_OBJECT_TYPE

public static final String BOOLEANCHAR_OBJECT_TYPE
See Also:
Constant Field Values

BOOLEANINT_OBJECT_TYPE

public static final String BOOLEANINT_OBJECT_TYPE
See Also:
Constant Field Values
Method Detail

getJavaObject

public static String getJavaObject(SchemaType jdbcType)
Return a Java object which corresponds to the JDBC type provided. Use in MapBuilder generation.

Parameters:
jdbcType - the JDBC type
Returns:
name of the Object

getJavaPrimitiveType

public static JavaType getJavaPrimitiveType(SchemaType schemaType)
Returns the java type which corresponds to the schema type provided. Where possible, primitive types are used.

Parameters:
schemaType - the schema type.
Returns:
name of the native java type

getJavaObjectType

public static JavaType getJavaObjectType(SchemaType schemaType)
Returns the java type which corresponds to the schema type provided. Only Object types are used.

Parameters:
schemaType - the schema type.
Returns:
the corresponding java Type.

getResultSetGetter

public static ResultSetGetter getResultSetGetter(SchemaType schemaType)
Returns the result set getter method which corresponds to the Schema type provided.

Parameters:
schemaType - the schema type
Returns:
the result set getter method.

isBooleanInt

public static boolean isBooleanInt(SchemaType type)
Returns true if the type is boolean in the java object and a numeric (1 or 0) in the db.

Parameters:
type - The type to check.
Returns:
true if the type is BOOLEANINT

isBooleanChar

public static boolean isBooleanChar(SchemaType type)
Returns true if the type is boolean in the java object and a String "Y" or "N" in the db.

Parameters:
type - The type to check.
Returns:
true if the type is BOOLEANCHAR

isBit

public static boolean isBit(SchemaType type)
Returns true if the type is boolean in the java object and a Bit "1" or "0" in the db.

Parameters:
type - The type to check.
Returns:
true if the type is BIT

isTextType

public static boolean isTextType(SchemaType type)
Returns true if values for the type need to be quoted.

Parameters:
type - The type to check.
Returns:
true if values for the type need to be quoted.


Copyright © 2000-2012 The Apache Software Foundation. All Rights Reserved.