org.apache.beehive.controls.system.jdbc
Class RowMapperFactory

Object
  extended by RowMapperFactory

public final class RowMapperFactory
extends Object

Factory for creating row mappers.

Row mapper types supported by this factory include: HashMap, Map, Object, XmlObject. The factory determines the proper row mapper to use by checking its List of RowMappers against the type of mapping requested. When performing the lookup, the factory attempts to find the most specific type match. If a match can't be found the most general type of RowMapper is returned, RowToObjectMapper.


Constructor Summary
RowMapperFactory()
           
 
Method Summary
static void addRowMapping(Class returnTypeClass, Class<? extends RowMapper> rowMapperClass)
          Add a new row mapper to the list of available row mappers.
static RowMapper getRowMapper(ResultSet rs, Class returnTypeClass, Calendar cal)
          Get a RowMapper instance which knows how to map a ResultSet row to the given return type.
static Class<? extends RowMapper> removeRowMapping(Class returnTypeClass)
          remove the row mapping for the specified class type.
static Class<? extends RowMapper> replaceRowMapping(Class returnTypeClass, Class<? extends RowMapper> rowMapperClass)
          Replace a row mapping.
static Class<? extends RowMapper> setDefaultRowMapping(Class<? extends RowMapper> rowMapperClass)
          Sets the rowmapper for Object.class
static Class<? extends RowMapper> setDefaultXmlRowMapping(Class mapToClass, Class<? extends RowMapper> rowMapperClass)
          Sets the rowmapper for XmlObject.class
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RowMapperFactory

public RowMapperFactory()
Method Detail

getRowMapper

public static RowMapper getRowMapper(ResultSet rs,
                                     Class returnTypeClass,
                                     Calendar cal)
Get a RowMapper instance which knows how to map a ResultSet row to the given return type.

Parameters:
rs - The ResultSet to map.
returnTypeClass - The class to map a ResultSet row to.
cal - Calendar instance for mapping date/time values.
Returns:
A RowMapper instance.

addRowMapping

public static void addRowMapping(Class returnTypeClass,
                                 Class<? extends RowMapper> rowMapperClass)
Add a new row mapper to the list of available row mappers. The getRowMapper method traverses the list of mappers from beginning to end, checking to see if a mapper can handle the specified returnTypeClass. There is a default mapper which is used if a match cannot be found in the list.

Parameters:
returnTypeClass - Class which this mapper maps a row to.
rowMapperClass - The row mapper class.

replaceRowMapping

public static Class<? extends RowMapper> replaceRowMapping(Class returnTypeClass,
                                                           Class<? extends RowMapper> rowMapperClass)
Replace a row mapping.

Parameters:
returnTypeClass - Class which this mapper maps a row to.
rowMapperClass - The row mapper class.
Returns:
if the mapper was replaced, false mapper for returnTypeClass was not found, no action taken.

removeRowMapping

public static Class<? extends RowMapper> removeRowMapping(Class returnTypeClass)
remove the row mapping for the specified class type.

Parameters:
returnTypeClass -
Returns:
the RowMapper class which was removed, null if returnTypeClass did not match any of the registered row mappers.

setDefaultRowMapping

public static Class<? extends RowMapper> setDefaultRowMapping(Class<? extends RowMapper> rowMapperClass)
Sets the rowmapper for Object.class

Parameters:
rowMapperClass -

setDefaultXmlRowMapping

public static Class<? extends RowMapper> setDefaultXmlRowMapping(Class mapToClass,
                                                                 Class<? extends RowMapper> rowMapperClass)
Sets the rowmapper for XmlObject.class

Parameters:
rowMapperClass -