org.jaffa.persistence.engines.jdbcengine.querygenerator
Class DataTranslator

java.lang.Object
  extended byorg.jaffa.persistence.engines.jdbcengine.querygenerator.DataTranslator

public class DataTranslator
extends Object

This class has helper routines for passing values in DML strings and PreparedStatements. There are routines to extract appropriate objects from ResultSets and CallableStatements.


Method Summary
static Object getAppObject(CallableStatement cstmt, int parameterIndex, String typeName, String engineType)
          Gets a parameter from the CallableStatement.
static Object getAppObject(ResultSet rs, String columnName, String typeName, String engineType)
          Gets a parameter from the ResultSet.
static String getBeginsWithDml(Object object, String typeName, String engineType)
          Returns the string to be used in SQL statements, appropriate for the datatype.
static String getDml(Object object, String typeName, String engineType)
          Returns the string to be used in SQL statements, appropriate for the datatype.
static String getEndsWithDml(Object object, String typeName, String engineType)
          Returns the string to be used in SQL statements, appropriate for the datatype.
static String getLikeDml(Object object, String typeName, String engineType)
          Returns the string to be used in SQL statements, appropriate for the datatype.
static void setAppObject(PreparedStatement pstmt, int parameterIndex, Object value, String typeName, String engineType)
          Sets a parameter in the PreparedStatement.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getDml

public static String getDml(Object object,
                            String typeName,
                            String engineType)
                     throws IOException
Returns the string to be used in SQL statements, appropriate for the datatype.

Parameters:
object - an object for which the SQL statement is to be generated.
typeName - The sqlType defined in the mapping file.
engineType - The engine type as defined in init.xml
Returns:
the string to be used in SQL statements, appropriate for the datatype.
Throws:
IOException - if any error occurs while extracting the String from the input object.

getLikeDml

public static String getLikeDml(Object object,
                                String typeName,
                                String engineType)
                         throws IOException
Returns the string to be used in SQL statements, appropriate for the datatype.

Parameters:
object - an object for which the SQL statement is to be generated.
typeName - The sqlType defined in the mapping file.
engineType - The engine type as defined in init.xml
Returns:
the string to be used in SQL statements, appropriate for the datatype.
Throws:
IOException - if any error occurs while extracting the String from the input object.

getBeginsWithDml

public static String getBeginsWithDml(Object object,
                                      String typeName,
                                      String engineType)
                               throws IOException
Returns the string to be used in SQL statements, appropriate for the datatype.

Parameters:
object - an object for which the SQL statement is to be generated.
typeName - The sqlType defined in the mapping file.
engineType - The engine type as defined in init.xml
Returns:
the string to be used in SQL statements, appropriate for the datatype.
Throws:
IOException - if any error occurs while extracting the String from the input object.

getEndsWithDml

public static String getEndsWithDml(Object object,
                                    String typeName,
                                    String engineType)
                             throws IOException
Returns the string to be used in SQL statements, appropriate for the datatype.

Parameters:
object - an object for which the SQL statement is to be generated.
typeName - The sqlType defined in the mapping file.
engineType - The engine type as defined in init.xml
Returns:
the string to be used in SQL statements, appropriate for the datatype.
Throws:
IOException - if any error occurs while extracting the String from the input object.

setAppObject

public static void setAppObject(PreparedStatement pstmt,
                                int parameterIndex,
                                Object value,
                                String typeName,
                                String engineType)
                         throws SQLException
Sets a parameter in the PreparedStatement.

Parameters:
pstmt - The PreparedStatement.
parameterIndex - The index of the parameter that is to be set.
value - The object to be assigned to the parameter.
typeName - The sqlType defined in the mapping file.
engineType - The engine type as defined in init.xml
Throws:
SQLException - if a database access error occurs.

getAppObject

public static Object getAppObject(ResultSet rs,
                                  String columnName,
                                  String typeName,
                                  String engineType)
                           throws SQLException,
                                  IOException
Gets a parameter from the ResultSet.

Parameters:
rs - The ResultSet.
columnName - The name of the parameter.
engineType - The engine type as defined in init.xml
typeName - The sqlType defined in the mapping file.
Returns:
the parameter.
Throws:
SQLException - if a database access error occurs.
IOException - if any error occurs in reading the data from the database.

getAppObject

public static Object getAppObject(CallableStatement cstmt,
                                  int parameterIndex,
                                  String typeName,
                                  String engineType)
                           throws SQLException,
                                  IOException
Gets a parameter from the CallableStatement.

Parameters:
cstmt - The CallableStatement.
parameterIndex - The index of the parameter.
engineType - The engine type as defined in init.xml
typeName - The sqlType defined in the mapping file.
Returns:
the parameter.
Throws:
SQLException - if a database access error occurs.
IOException - if any error occurs in reading the data from the database.


Copyright © 2002-2004 JAFFA Project.