net.sf.farrago.jdbc.param
Class FarragoJdbcParamDef

java.lang.Object
  extended by net.sf.farrago.jdbc.param.FarragoJdbcParamDef
Direct Known Subclasses:
FarragoJdbcApproxParamDef, FarragoJdbcBinaryParamDef, FarragoJdbcBooleanParamDef, FarragoJdbcDateParamDef, FarragoJdbcDecimalParamDef, FarragoJdbcFennelTupleParamDef, FarragoJdbcIntParamDef, FarragoJdbcStringParamDef, FarragoJdbcTimeParamDef, FarragoJdbcTimestampParamDef

public class FarragoJdbcParamDef
extends Object

Handles data conversion for a dynamic parameter (refactored from FarragoJdbcEngineParamDef) Enforces constraints on parameters. The constraints are:

  1. Ensures that null values cannot be inserted into not-null columns.
  2. Ensures that value is the right paramMetaData.
  3. Ensures that the value is within range. For example, you can't insert a 10001 into a DECIMAL(5) column.

TODO: Actually enfore these constraints. This class is JDK 1.4 compatible.

Version:
$Id: //open/dev/farrago/src/net/sf/farrago/jdbc/param/FarragoJdbcParamDef.java#10 $
Author:
Angel Chang

Field Summary
(package private)  FarragoParamFieldMetaData paramMetaData
           
(package private)  String paramName
           
 
Constructor Summary
FarragoJdbcParamDef(String paramName, FarragoParamFieldMetaData paramMetaData)
           
 
Method Summary
protected  void checkNullable()
           
protected  void checkRange(BigInteger value, BigInteger min, BigInteger max)
           
protected  void checkRange(double value, double min, double max)
           
protected  void checkRange(long value, long min, long max)
           
 FarragoParamFieldMetaData getParamMetaData()
           
 String getParamName()
           
protected  EigenbaseException newInvalidFormat(Object x)
          Returns an error that the value cannot be converted to the desired SQL type.
protected  EigenbaseException newInvalidType(Object x)
          Returns an error that the value is not valid for the desired SQL type.
protected  EigenbaseException newNotNullable()
          Returns an error that the value is not nullable
protected  EigenbaseException newValueOutOfRange(Object x)
          Returns an error the value is out of range and cannot be converted to the desired SQL type.
protected  EigenbaseException newValueTooLong(Object x)
          Returns an error the value is too long to be converted to the desired SQL type.
 Object scrubValue(Object x)
           
 Object scrubValue(Object x, Calendar cal)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

paramMetaData

final FarragoParamFieldMetaData paramMetaData

paramName

final String paramName
Constructor Detail

FarragoJdbcParamDef

FarragoJdbcParamDef(String paramName,
                    FarragoParamFieldMetaData paramMetaData)
Method Detail

getParamName

public String getParamName()

getParamMetaData

public FarragoParamFieldMetaData getParamMetaData()

scrubValue

public Object scrubValue(Object x)

scrubValue

public Object scrubValue(Object x,
                         Calendar cal)

checkNullable

protected void checkNullable()

checkRange

protected void checkRange(BigInteger value,
                          BigInteger min,
                          BigInteger max)

checkRange

protected void checkRange(long value,
                          long min,
                          long max)

checkRange

protected void checkRange(double value,
                          double min,
                          double max)

newInvalidType

protected EigenbaseException newInvalidType(Object x)
Returns an error that the value is not valid for the desired SQL type.


newNotNullable

protected EigenbaseException newNotNullable()
Returns an error that the value is not nullable


newInvalidFormat

protected EigenbaseException newInvalidFormat(Object x)
Returns an error that the value cannot be converted to the desired SQL type.


newValueTooLong

protected EigenbaseException newValueTooLong(Object x)
Returns an error the value is too long to be converted to the desired SQL type.


newValueOutOfRange

protected EigenbaseException newValueOutOfRange(Object x)
Returns an error the value is out of range and cannot be converted to the desired SQL type.