org.apache.derbyTesting.functionTests.util
Class BigDecimalHandler

java.lang.Object
  extended by org.apache.derbyTesting.functionTests.util.BigDecimalHandler

public class BigDecimalHandler
extends java.lang.Object

BigDecimalHandler provides wrappers for JDBC API methods which use BigDecimal. When writing tests which use BigDecimal, the methods in this class can be called instead of directly calling JDBC methods. This way the same test can be used in JVMs like J2ME/CDC/Foundation Profile 1.0, which do not have BigDecimal class, or JSR169 Profile, which does not support method calls using BigDecimal (such as ResultSet.getBigDecimal(..).


Field Summary
private static int[] bdConvertibleTypes
           
static int BIGDECIMAL_REPRESENTATION
           
static int representation
           
static int STRING_REPRESENTATION
           
 
Constructor Summary
BigDecimalHandler()
           
 
Method Summary
protected static boolean canConvertToDecimal(int type)
          This method checks that the SQL type can be converted to Decimal
static java.lang.String getBigDecimalString(java.sql.CallableStatement cs, int parameterIndex, int parameterType)
          This method is a wrapper for the CallableStatement method getBigDecimal(int parameterIndex).
static java.lang.String getBigDecimalString(java.sql.ResultSet rs, int columnIndex)
          This method is a wrapper for the ResultSet method getBigDecimal(int columnIndex).
static java.lang.String getBigDecimalString(java.sql.ResultSet rs, java.lang.String columnName, int columnIndex)
          This method is a wrapper for ResultSet method getBigDecimal(String columnName).
static java.lang.String getObjectString(java.sql.ResultSet rs, int columnIndex)
          This method is a wrapper for ResultSet method getObject(int columnIndex)
static java.lang.String getObjectString(java.sql.ResultSet rs, java.lang.String columnName, int columnIndex)
          This method is a wrapper for ResultSet method getObject(String columnName)
static void setBigDecimalString(java.sql.PreparedStatement ps, int parameterIndex, java.lang.String bdString)
          This method is a wrapper for the PreparedStatement method setBigDecimal(int parameterIndex,BigDecimal x)
static void setObjectString(java.sql.PreparedStatement ps, int parameterIndex, java.lang.String objectString)
          This method is a wrapper for the PreparedStatement method setObject(int parameterIndex, Object x)
static void updateBigDecimalString(java.sql.ResultSet rs, int columnIndex, java.lang.String bdString)
          This method is a wrapper for ResultSet method updateBigDecimal(int columnIndex, BigDecimal x)
static void updateBigDecimalString(java.sql.ResultSet rs, java.lang.String columnName, java.lang.String bdString)
          This method is a wrapper for ResultSet method updateBigDecimal(String columnName, BigDecimal x)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

representation

public static int representation

STRING_REPRESENTATION

public static final int STRING_REPRESENTATION
See Also:
Constant Field Values

BIGDECIMAL_REPRESENTATION

public static final int BIGDECIMAL_REPRESENTATION
See Also:
Constant Field Values

bdConvertibleTypes

private static final int[] bdConvertibleTypes
Constructor Detail

BigDecimalHandler

public BigDecimalHandler()
Method Detail

getBigDecimalString

public static java.lang.String getBigDecimalString(java.sql.ResultSet rs,
                                                   int columnIndex)
                                            throws java.sql.SQLException
This method is a wrapper for the ResultSet method getBigDecimal(int columnIndex).

Parameters:
rs - ResultSet
columnIndex - Column Index
Returns:
String value of getXXX(columnIndex)method on the ResultSet
Throws:
java.sql.SQLException

getBigDecimalString

public static java.lang.String getBigDecimalString(java.sql.ResultSet rs,
                                                   java.lang.String columnName,
                                                   int columnIndex)
                                            throws java.sql.SQLException
This method is a wrapper for ResultSet method getBigDecimal(String columnName).

Parameters:
rs - ResultSet
columnName - Column Name
columnIndex - Coulumn Index
Returns:
String value of getXXX(columnName)method on the ResultSet
Throws:
java.sql.SQLException

getObjectString

public static java.lang.String getObjectString(java.sql.ResultSet rs,
                                               int columnIndex)
                                        throws java.sql.SQLException
This method is a wrapper for ResultSet method getObject(int columnIndex)

Parameters:
rs - ResultSet
columnIndex - ColumnIndex
Returns:
String value of getXXX(columnIndex) method on the ResultSet
Throws:
java.sql.SQLException

getObjectString

public static java.lang.String getObjectString(java.sql.ResultSet rs,
                                               java.lang.String columnName,
                                               int columnIndex)
                                        throws java.sql.SQLException
This method is a wrapper for ResultSet method getObject(String columnName)

Parameters:
rs - ResultSet
columnName - Column Name
columnIndex - Column Index
Returns:
String value of getXXX(columnName) method on the ResultSet
Throws:
java.sql.SQLException

updateBigDecimalString

public static void updateBigDecimalString(java.sql.ResultSet rs,
                                          int columnIndex,
                                          java.lang.String bdString)
                                   throws java.sql.SQLException
This method is a wrapper for ResultSet method updateBigDecimal(int columnIndex, BigDecimal x)

Parameters:
rs - ResultSet
columnIndex - Column Index
bdString - String to be used in updateXXX method
Throws:
java.sql.SQLException

updateBigDecimalString

public static void updateBigDecimalString(java.sql.ResultSet rs,
                                          java.lang.String columnName,
                                          java.lang.String bdString)
                                   throws java.sql.SQLException
This method is a wrapper for ResultSet method updateBigDecimal(String columnName, BigDecimal x)

Parameters:
rs - ResultSet
columnName - Column Name
bdString - String to be used in updateXXX method
Throws:
java.sql.SQLException

getBigDecimalString

public static java.lang.String getBigDecimalString(java.sql.CallableStatement cs,
                                                   int parameterIndex,
                                                   int parameterType)
                                            throws java.sql.SQLException
This method is a wrapper for the CallableStatement method getBigDecimal(int parameterIndex). The wrapper method needs the parameterType as an input since ParameterMetaData is not available in JSR169.

Parameters:
cs - CallableStatement
parameterIndex - Parameter Index
parameterType - Parameter Type
Returns:
String value of getXXX(parameterIndex)method on the CallableStatement
Throws:
java.sql.SQLException

setBigDecimalString

public static void setBigDecimalString(java.sql.PreparedStatement ps,
                                       int parameterIndex,
                                       java.lang.String bdString)
                                throws java.sql.SQLException
This method is a wrapper for the PreparedStatement method setBigDecimal(int parameterIndex,BigDecimal x)

Parameters:
ps - PreparedStatement
parameterIndex - Parameter Index
bdString - String to be used in setXXX method
Throws:
java.sql.SQLException

setObjectString

public static void setObjectString(java.sql.PreparedStatement ps,
                                   int parameterIndex,
                                   java.lang.String objectString)
                            throws java.sql.SQLException
This method is a wrapper for the PreparedStatement method setObject(int parameterIndex, Object x)

Parameters:
ps - PreparedStatement
parameterIndex - Parameter Index
objectString - String to be used in setObject method
Throws:
java.sql.SQLException

canConvertToDecimal

protected static boolean canConvertToDecimal(int type)
                                      throws java.sql.SQLException
This method checks that the SQL type can be converted to Decimal

Parameters:
type - the type to check
Returns:
true if the SQL type is convertible to DECIMAL, false otherwise.
Throws:
java.sql.SQLException

Built on Sat 2009-11-28 18:44:18-0800, from revision 885187

Apache Derby V10.6 Internals - Copyright © 2004,2008 The Apache Software Foundation. All Rights Reserved.