org.exolab.castor.jdo.engine
Class SQLTypes
java.lang.Object
org.exolab.castor.jdo.engine.SQLTypes
public final class SQLTypes
extends java.lang.Object
$Revision: 1.1.1.1 $ $Date: 2003/03/03 07:08:21 $
static TypeConvertor | getConvertor(Class fromType, Class toType) - Returns a type convertor.
|
static Object | getObject(ResultSet rs, int index, int sqlType)
|
static int | getSQLType(Class javaType) - Returns the SQL type from the specified Java type.
|
static String | javaToSqlName(String javaName) - Convert from Java name to SQL name.
|
static String | paramFromName(String sqlTypeName) - Extracts parameter for type convertor from the name of the SQL type
of the form "SQL_type.domain".
|
static void | setObject(PreparedStatement stmt, int index, Object value, int sqlType)
|
static String | sqlToJavaName(String sqlName, boolean className, String scope) - Convert from SQL name to Java name.
|
static int | sqlTypeFromName(String sqlTypeName) - Returns the Java type from the SQL type name.
|
static Class | typeFromName(String sqlTypeName) - Returns the Java type from the SQL type name.
|
static Class | typeFromSQLType(int sqlType) - Returns the Java type from the SQL type.
|
_typeConvertors
(package private) static SQLTypes.TypeConvertorInfo[] _typeConvertors
List of all the default convertors between Java types.
_typeInfos
(package private) static SQLTypes.TypeInfo[] _typeInfos
List of all the SQL types supported by Castor JDO.
getConvertor
public static TypeConvertor getConvertor(Class fromType,
Class toType)
throws MappingException
Returns a type convertor. A type convertor can be used to convert
an object from Java type fromType to Java type toType.
fromType
- The Java type to convert fromtoType
- The Java type to convert to
getObject
public static Object getObject(ResultSet rs,
int index,
int sqlType)
throws SQLException
getSQLType
public static int getSQLType(Class javaType)
Returns the SQL type from the specified Java type. Returns
OTHER
if the Java type has no suitable SQL type mapping. The argument
sqlType must be the return value from a previous call to
typeFromSQLType(int)
or
typeFromName(String)
.
javaType
- The Java class of the SQL type
- SQL type from the specified Java type
javaToSqlName
public static String javaToSqlName(String javaName)
Convert from Java name to SQL name. Performs trivial conversion
by lowering case of all letters and adding underscore between
words, a word is identifier as starting with an upper case. Only
the last part of the Java name (following the last period) is used.
For example:
prodId becomes prod_id (field -> column)
jdbc.ProdGroup becomes prod_group (object -> table)
hobbies.getALife becomes get_a_life (compound field -> column)
javaName
- The Java identifier name
- An equivalent SQL identifier name
paramFromName
public static String paramFromName(String sqlTypeName)
Extracts parameter for type convertor from the name of the SQL type
of the form "SQL_type.domain".
If the type is not parameterized, returns null.
sqlTypeName
- SQL type name (e.g. char[01])
- Parameter (e.g. "01") or null
setObject
public static void setObject(PreparedStatement stmt,
int index,
Object value,
int sqlType)
throws SQLException
sqlToJavaName
public static String sqlToJavaName(String sqlName,
boolean className,
String scope)
Convert from SQL name to Java name. Performs trivial conversion
by treating each underscore as a word separator and converting the
first letter of each word to upper case. If a scope is specified,
the scope is prepended to the Java name separated by a period.
For example:
prod_id, false becomes prodId (column -> field)
prod_group, true becomes ProdGroup (table -> object)
get_a_life, false, "product" becomes product.getALife (column -> field)
sqlName
- The SQL identifier nameclassName
- True if class name (first letter must be upper case)scope
- Optional scope preceding name (package name, compound field)
- An equivalent Java identifier name
sqlTypeFromName
public static int sqlTypeFromName(String sqlTypeName)
throws MappingException
Returns the Java type from the SQL type name.
sqlTypeName
- SQL type name (e.g. numeric)
typeFromName
public static Class typeFromName(String sqlTypeName)
throws MappingException
Returns the Java type from the SQL type name.
sqlTypeName
- SQL type name (e.g. numeric)
typeFromSQLType
public static Class typeFromSQLType(int sqlType)
throws MappingException
Returns the Java type from the SQL type.
sqlType
- SQL type name (see JDBC API)
Intalio Inc. (C) 1999-2003. All rights reserved http://www.intalio.com