Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.cayenne.dba
Class TypesMapping

    java.lang.Object
      org.apache.cayenne.dba.TypesMapping

    public class TypesMapping

extends java.lang.Object

A utility class that handles mappings of JDBC data types to the database types and Java types. Also contains methods that provide information about JDBC types.

Author:
  Michael Shengaout, Andrei Adamchik

Field Summary
`protected java.util.Map` | `databaseTypes`
`static java.lang.String` | `JAVA_BIGDECIMAL`
`static java.lang.String` | `JAVA_BOOLEAN`
`static java.lang.String` | `JAVA_BYTE`
`static java.lang.String` | `JAVA_BYTES`
`static java.lang.String` | `JAVA_DOUBLE`
`static java.lang.String` | `JAVA_FLOAT`
`static java.lang.String` | `JAVA_INTEGER`
`static java.lang.String` | `JAVA_LONG`
`static java.lang.String` | `JAVA_SHORT`
`static java.lang.String` | `JAVA_SQLDATE`
`static java.lang.String` | `JAVA_STRING`
`static java.lang.String` | `JAVA_TIME`
`static java.lang.String` | `JAVA_TIMESTAMP`
`static java.lang.String` | `JAVA_UTILDATE`
`static int` | `NOT_DEFINED`
`static java.lang.String` | `SQL_ARRAY`
`static java.lang.String` | `SQL_BIGINT`
`static java.lang.String` | `SQL_BINARY`
`static java.lang.String` | `SQL_BIT`
`static java.lang.String` | `SQL_BLOB`
`static java.lang.String` | `SQL_BOOLEAN`
`static java.lang.String` | `SQL_CHAR`
`static java.lang.String` | `SQL_CLOB`
`static java.lang.String` | `SQL_DATE`
`static java.lang.String` | `SQL_DECIMAL`
`static java.lang.String` | `SQL_DOUBLE`
`static java.lang.String` | `SQL_FLOAT`
`static java.lang.String` | `SQL_INTEGER`
`static java.lang.String` | `SQL_LONGVARBINARY`
`static java.lang.String` | `SQL_LONGVARCHAR`
`static java.lang.String` | `SQL_NUMERIC`
`static java.lang.String` | `SQL_OTHER`
`static java.lang.String` | `SQL_REAL`
`static java.lang.String` | `SQL_SMALLINT`
`static java.lang.String` | `SQL_TIME`
`static java.lang.String` | `SQL_TIMESTAMP`
`static java.lang.String` | `SQL_TINYINT`
`static java.lang.String` | `SQL_VARBINARY`
`static java.lang.String` | `SQL_VARCHAR`

Constructor Summary
`TypesMapping(java.sql.DatabaseMetaData metaData)`

Method Summary
`static java.lang.String[]` | `getDatabaseTypes()` Returns an array of string names of the default JDBC data types.
`static java.lang.String` | `getJavaBySqlType(int type)` Get the corresponding Java type by its java.sql.Types counterpart.
`static java.lang.String` | `getJavaBySqlType(int type, int length, int precision)` Get the corresponding Java type by its java.sql.Types counterpart.
`static java.lang.String` | `getSqlNameByType(int type)` Returns a String representation of the SQL type from its JDBC code.
`static int` | `getSqlTypeByJava(java.lang.Class javaClass)` Guesses a default JDBC type for the Java class.
`static int` | `getSqlTypeByJava(java.lang.String javaTypeName)` Returns default java.sql.Types type by the Java type name.
`static int` | `getSqlTypeByName(java.lang.String typeName)` Returns a JDBC int type for SQL typem name.
`static boolean` | `isDecimal(int type)` Returns true if supplied type is a decimal type.
`static boolean` | `isNumeric(int type)` Returns true if supplied type is a numeric type.
`protected static java.lang.String` | `pickDataType(int jdbcType, org.apache.cayenne.dba.TypesMapping.TypeInfo[] alts)` Method implements an algorithm to pick a data type from a list of alternatives that most closely matches JDBC data type.
`static boolean` | `supportsLength(int type)` Returns true if supplied type can have a length attribute as a part of column definition.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### NOT_DEFINED

    public static final int NOT_DEFINED

See Also:
  Constant Field Values

### SQL_ARRAY

    public static final java.lang.String SQL_ARRAY

See Also:
  Constant Field Values

### SQL_BIGINT

    public static final java.lang.String SQL_BIGINT

See Also:
  Constant Field Values

### SQL_BINARY

    public static final java.lang.String SQL_BINARY

See Also:
  Constant Field Values

### SQL_BIT

    public static final java.lang.String SQL_BIT

See Also:
  Constant Field Values

### SQL_BLOB

    public static final java.lang.String SQL_BLOB

See Also:
  Constant Field Values

### SQL_BOOLEAN

    public static final java.lang.String SQL_BOOLEAN

Since:
  1.2
See Also:
  Constant Field Values

### SQL_CLOB

    public static final java.lang.String SQL_CLOB

See Also:
  Constant Field Values

### SQL_CHAR

    public static final java.lang.String SQL_CHAR

See Also:
  Constant Field Values

### SQL_DATE

    public static final java.lang.String SQL_DATE

See Also:
  Constant Field Values

### SQL_DECIMAL

    public static final java.lang.String SQL_DECIMAL

See Also:
  Constant Field Values

### SQL_DOUBLE

    public static final java.lang.String SQL_DOUBLE

See Also:
  Constant Field Values

### SQL_FLOAT

    public static final java.lang.String SQL_FLOAT

See Also:
  Constant Field Values

### SQL_INTEGER

    public static final java.lang.String SQL_INTEGER

See Also:
  Constant Field Values

### SQL_LONGVARCHAR

    public static final java.lang.String SQL_LONGVARCHAR

See Also:
  Constant Field Values

### SQL_LONGVARBINARY

    public static final java.lang.String SQL_LONGVARBINARY

See Also:
  Constant Field Values

### SQL_NUMERIC

    public static final java.lang.String SQL_NUMERIC

See Also:
  Constant Field Values

### SQL_REAL

    public static final java.lang.String SQL_REAL

See Also:
  Constant Field Values

### SQL_SMALLINT

    public static final java.lang.String SQL_SMALLINT

See Also:
  Constant Field Values

### SQL_TINYINT

    public static final java.lang.String SQL_TINYINT

See Also:
  Constant Field Values

### SQL_TIME

    public static final java.lang.String SQL_TIME

See Also:
  Constant Field Values

### SQL_TIMESTAMP

    public static final java.lang.String SQL_TIMESTAMP

See Also:
  Constant Field Values

### SQL_VARBINARY

    public static final java.lang.String SQL_VARBINARY

See Also:
  Constant Field Values

### SQL_VARCHAR

    public static final java.lang.String SQL_VARCHAR

See Also:
  Constant Field Values

### SQL_OTHER

    public static final java.lang.String SQL_OTHER

See Also:
  Constant Field Values

### JAVA_LONG

    public static final java.lang.String JAVA_LONG

See Also:
  Constant Field Values

### JAVA_BYTES

    public static final java.lang.String JAVA_BYTES

See Also:
  Constant Field Values

### JAVA_BOOLEAN

    public static final java.lang.String JAVA_BOOLEAN

See Also:
  Constant Field Values

### JAVA_STRING

    public static final java.lang.String JAVA_STRING

See Also:
  Constant Field Values

### JAVA_SQLDATE

    public static final java.lang.String JAVA_SQLDATE

See Also:
  Constant Field Values

### JAVA_UTILDATE

    public static final java.lang.String JAVA_UTILDATE

See Also:
  Constant Field Values

### JAVA_BIGDECIMAL

    public static final java.lang.String JAVA_BIGDECIMAL

See Also:
  Constant Field Values

### JAVA_DOUBLE

    public static final java.lang.String JAVA_DOUBLE

See Also:
  Constant Field Values

### JAVA_FLOAT

    public static final java.lang.String JAVA_FLOAT

See Also:
  Constant Field Values

### JAVA_INTEGER

    public static final java.lang.String JAVA_INTEGER

See Also:
  Constant Field Values

### JAVA_SHORT

    public static final java.lang.String JAVA_SHORT

See Also:
  Constant Field Values

### JAVA_BYTE

    public static final java.lang.String JAVA_BYTE

See Also:
  Constant Field Values

### JAVA_TIME

    public static final java.lang.String JAVA_TIME

See Also:
  Constant Field Values

### JAVA_TIMESTAMP

    public static final java.lang.String JAVA_TIMESTAMP

See Also:
  Constant Field Values

### databaseTypes

    protected java.util.Map databaseTypes

Constructor Detail

### TypesMapping

    public TypesMapping(java.sql.DatabaseMetaData metaData)
                 throws java.sql.SQLException

Throws:
  `java.sql.SQLException`

Method Detail

### supportsLength

    public static boolean supportsLength(int type)

  Returns true if supplied type can have a length attribute as a part of column definition.

### isNumeric

    public static boolean isNumeric(int type)

  Returns true if supplied type is a numeric type.

### isDecimal

    public static boolean isDecimal(int type)

  Returns true if supplied type is a decimal type.

### getDatabaseTypes

    public static java.lang.String[] getDatabaseTypes()

  Returns an array of string names of the default JDBC data types.

### pickDataType

    protected static java.lang.String pickDataType(int jdbcType,
                                                   org.apache.cayenne.dba.TypesMapping.TypeInfo[] alts)

  Method implements an algorithm to pick a data type from a list of alternatives that most closely matches JDBC data type.

### getSqlTypeByName

    public static int getSqlTypeByName(java.lang.String typeName)

  Returns a JDBC int type for SQL typem name.

### getSqlNameByType

    public static java.lang.String getSqlNameByType(int type)

  Returns a String representation of the SQL type from its JDBC code.

### getSqlTypeByJava

    public static int getSqlTypeByJava(java.lang.String javaTypeName)

  Returns default java.sql.Types type by the Java type name.

  Parameters:
    `javaTypeName` - Fully qualified Java Class name.
  Returns:
    The SQL type or NOT_DEFINED if no type found.

### getSqlTypeByJava

    public static int getSqlTypeByJava(java.lang.Class javaClass)

  Guesses a default JDBC type for the Java class.

  Since:
    1.1

### getJavaBySqlType

    public static java.lang.String getJavaBySqlType(int type)

  Get the corresponding Java type by its java.sql.Types counterpart.

  Returns:
    Fully qualified Java type name or null if not found.

### getJavaBySqlType

    public static java.lang.String getJavaBySqlType(int type,
                                                    int length,
                                                    int precision)

  Get the corresponding Java type by its java.sql.Types counterpart.

  Returns:
    Fully qualified Java type name or null if not found.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2006 Apache.org All Rights Reserved.