com.ninja_squad.dbsetup.bind
Class Binders

java.lang.Object
  extended by com.ninja_squad.dbsetup.bind.Binders

public final class Binders
extends java.lang.Object

Utility class allowing to get various kinds of binders. The DefaultBinderConfiguration uses binders returned by this class, based on the type of the parameter.


Method Summary
static Binder dateBinder()
          Returns a binder suitable for columns of type DATE.
static Binder decimalBinder()
          Returns a binder suitable for numeric, decimal columns.
static Binder defaultBinder()
          Returns the default binder, which uses stmt.setObject() to bind the parameter.
static Binder integerBinder()
          Returns a binder suitable for numeric, integer columns.
static Binder stringBinder()
          Returns a binder suitable for columns of type CHAR and VARCHAR.
static Binder timeBinder()
          Returns a binder suitable for columns of type TIME.
static Binder timestampBinder()
          Returns a binder suitable for columns of type TIMESTAMP.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

defaultBinder

public static Binder defaultBinder()
Returns the default binder, which uses stmt.setObject() to bind the parameter.


stringBinder

public static Binder stringBinder()
Returns a binder suitable for columns of type CHAR and VARCHAR. The returned binder supports values of type


dateBinder

public static Binder dateBinder()
Returns a binder suitable for columns of type DATE. The returned binder supports values of type If the value is none of these types, stmt.setObject() is used to bind the value.


timestampBinder

public static Binder timestampBinder()
Returns a binder suitable for columns of type TIMESTAMP. The returned binder supports values of type If the value is none of these types, stmt.setObject() is used to bind the value.


timeBinder

public static Binder timeBinder()
Returns a binder suitable for columns of type TIME. The returned binder supports values of type
  • java.sql.Time
  • java.util.Date: the milliseconds of the date are used to construct a java.sql.Time
  • java.util.Calendar: the milliseconds of the calendar are used to construct a java.sql.Time
  • String: the string is transformed to a java.sql.Time using the Time.valueOf() method
If the value is none of these types, stmt.setObject() is used to bind the value.


decimalBinder

public static Binder decimalBinder()
Returns a binder suitable for numeric, decimal columns. The returned binder supports values of type
  • String: the string is transformed to a java.math.BigDecimal using its constructor
If the value is none of these types, stmt.setObject() is used to bind the value.


integerBinder

public static Binder integerBinder()
Returns a binder suitable for numeric, integer columns. The returned binder supports values of type
  • enum: the enum is transformed into an integer by taking its ordinal
  • String: the string is transformed to a java.math.BigInteger using its constructor
If the value is none of these types, stmt.setObject() is used to bind the value.