sf logo

sf.qof.adapter
Class BooleanAdapter

java.lang.Object
  extended by sf.qof.adapter.BooleanAdapter
All Implemented Interfaces:
GeneratorMappingAdapter, MappingAdapter

public class BooleanAdapter
extends Object
implements GeneratorMappingAdapter

BooleanAdapter is a generator mapping adapter for boolean data types.

It maps VARCHAR columns to boolean and Boolean and vice versa.

Examples:

(1) BooleanAdapter.register("yesno", "Y", "N", false, true); (2) BooleanAdapter.register("true-false", "true", "false", true, false); (3) BooleanAdapter.register("bigX", "X", null, true, true);

(1) Maps boolean types to "Y" and "N", is not case-sensitive ("y" is true as well) and allows null values (a SQL null value gets mapped to false if the type is boolean).

(2) Maps boolean types to the strings "true" and "false", is case-sensitive and does not allow null values.

(3) Maps boolean types to "X" and null, is case-sensitive and allows nulls.

See Also:
registerYesNo(), register(String, String, String, boolean, boolean)

Method Summary
 void generateFromResult(ResultMapping resultMapping, net.sf.cglib.core.CodeEmitter co, net.sf.cglib.core.Local result, int[] indexes)
          Method to map the current record of a result set or the result of a callable statement to an object on the stack.
 void generateFromResultSet(ResultMapping resultMapping, net.sf.cglib.core.CodeEmitter co, net.sf.cglib.core.Local resultSet, String[] columns)
          Method to map the current record of a result set to an object on the stack.
 void generateRegisterOutputParameters(ResultMapping resultMapping, net.sf.cglib.core.CodeEmitter co, net.sf.cglib.core.Local callableStatement, int[] indexes)
          Method to register an output parameter in a callable statement.
 void generateToPreparedStatement(ParameterMapping parameterMapping, net.sf.cglib.core.CodeEmitter co, net.sf.cglib.core.Local preparedStatement, int[] indexes, net.sf.cglib.core.Local indexOffset)
          Method to map the object on top of the stack to a prepared statement.
 int getNumberOfColumns()
          Returns the number of mapped columns.
 Set<Class<?>> getTypes()
          Returns the set of mappable Java types.
static void register(String typeName, String trueString, String falseString, boolean caseSensitive, boolean allowNull)
          Registers a BooleanAdapter with a given name.
static void registerYesNo()
          Registers a yes/no adapter with name "yesno".
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

generateFromResult

public void generateFromResult(ResultMapping resultMapping,
                               net.sf.cglib.core.CodeEmitter co,
                               net.sf.cglib.core.Local result,
                               int[] indexes)
Description copied from interface: GeneratorMappingAdapter
Method to map the current record of a result set or the result of a callable statement to an object on the stack. indexes defines the SQL indexes for the result set to be used in functions such a getInt(index).

Specified by:
generateFromResult in interface GeneratorMappingAdapter
Parameters:
resultMapping - the result mapping
co - code emitter
result - ResultSet or CallableStatement local variable
indexes - array of SQL indexes

generateFromResultSet

public void generateFromResultSet(ResultMapping resultMapping,
                                  net.sf.cglib.core.CodeEmitter co,
                                  net.sf.cglib.core.Local resultSet,
                                  String[] columns)
Description copied from interface: GeneratorMappingAdapter
Method to map the current record of a result set to an object on the stack. columns defines the SQL column name for the result set to be used in functions such a getInt(name).

Specified by:
generateFromResultSet in interface GeneratorMappingAdapter
Parameters:
resultMapping - the result mapping
co - code emitter
resultSet - ResultSet local variable
columns - array of SQL column names

generateToPreparedStatement

public void generateToPreparedStatement(ParameterMapping parameterMapping,
                                        net.sf.cglib.core.CodeEmitter co,
                                        net.sf.cglib.core.Local preparedStatement,
                                        int[] indexes,
                                        net.sf.cglib.core.Local indexOffset)
Description copied from interface: GeneratorMappingAdapter
Method to map the object on top of the stack to a prepared statement. indexes defines the SQL index for the prepared statement to be used in functions such a setInt(index, value).

Specified by:
generateToPreparedStatement in interface GeneratorMappingAdapter
Parameters:
parameterMapping - the parameter mapping
co - code emitter
preparedStatement - prepared statement local variable
indexes - array of SQL indexes
indexOffset - offset to be added to the indexes if not null

generateRegisterOutputParameters

public void generateRegisterOutputParameters(ResultMapping resultMapping,
                                             net.sf.cglib.core.CodeEmitter co,
                                             net.sf.cglib.core.Local callableStatement,
                                             int[] indexes)
Description copied from interface: GeneratorMappingAdapter
Method to register an output parameter in a callable statement.

Specified by:
generateRegisterOutputParameters in interface GeneratorMappingAdapter
Parameters:
resultMapping - the result mapping
co - code emitter
callableStatement - callable statement local variable
indexes - array of SQL indexes

getNumberOfColumns

public int getNumberOfColumns()
Description copied from interface: MappingAdapter
Returns the number of mapped columns.

Specified by:
getNumberOfColumns in interface MappingAdapter
Returns:
number of mapped columns

getTypes

public Set<Class<?>> getTypes()
Description copied from interface: MappingAdapter
Returns the set of mappable Java types.

Specified by:
getTypes in interface MappingAdapter
Returns:
a set of mappable Java types

registerYesNo

public static void registerYesNo()
Registers a yes/no adapter with name "yesno". It maps "Y" to true, "N" to false, is not case-sensitive and allows null values.


register

public static void register(String typeName,
                            String trueString,
                            String falseString,
                            boolean caseSensitive,
                            boolean allowNull)
Registers a BooleanAdapter with a given name.

Parameters:
typeName - the type name to be used in parameter and result definitions
trueString - a string representing the true value
falseString - a string representing the false value. Can be null
caseSensitive - true if the mapping is case-sensitive
allowNull - true if null values are allowed

sf logo

Copyright © 2007 brunella ltd. All Rights Reserved.