Holger's
Java API

com.antelmann.sql
Class BaseRowMapper<T extends Resource>

java.lang.Object
  extended by com.antelmann.sql.BaseRowMapper<T>
All Implemented Interfaces:
ObjectRowMapper<T>

public abstract class BaseRowMapper<T extends Resource>
extends Object
implements ObjectRowMapper<T>

serves as a base class for implementations of ObjectRowMapper. The methods left to be implemented directly depend on the class to be mapped:

Author:
Holger Antelmann
See Also:
SimpleEntityFilter

Field Summary
protected  ConnectionHelper helper
           
protected  String idColumn
           
protected  String tableName
           
 
Constructor Summary
BaseRowMapper(Connection con, String tableName, String idColumn)
           
 
Method Summary
protected abstract  Map<String,Object> generateRowProperties(T entry)
          generates a map that contains all columns mapped to their values, so that the map can be used to store the object into a row.
 String getIDColumnName()
           
 ResultSet getResultSet(Filter<T> filter)
          constructs the ResultSet that corresponds closesd to the filter; note that the filter may be null, in which case the select statement should return all rows.
 ResultSet getResultSet(SimpleEntityFilter<? extends Entity> filter)
           
 String getTableName()
          generates a (blank) RowItem that tells the caller in what table to look for what value in what field to find the object.
 RowItem mapToRow(T entry)
          uses the abstract generateRowProperties(T) method to generate the RowItem
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.antelmann.sql.ObjectRowMapper
generateNewID, instanciate
 

Field Detail

helper

protected ConnectionHelper helper

tableName

protected String tableName

idColumn

protected String idColumn
Constructor Detail

BaseRowMapper

public BaseRowMapper(Connection con,
                     String tableName,
                     String idColumn)
Method Detail

getTableName

public String getTableName()
Description copied from interface: ObjectRowMapper
generates a (blank) RowItem that tells the caller in what table to look for what value in what field to find the object. Other than null, any parameter should be accepted. The return value must not be null for any ID. An implementation can hence use this method to get a sample RowItem for accessing table and idColumn.

Specified by:
getTableName in interface ObjectRowMapper<T extends Resource>

getIDColumnName

public String getIDColumnName()
Specified by:
getIDColumnName in interface ObjectRowMapper<T extends Resource>

generateRowProperties

protected abstract Map<String,Object> generateRowProperties(T entry)
generates a map that contains all columns mapped to their values, so that the map can be used to store the object into a row. The ID column and the corresponding ID should not be put in there, as this will happen automatically later.


mapToRow

public RowItem mapToRow(T entry)
uses the abstract generateRowProperties(T) method to generate the RowItem

Specified by:
mapToRow in interface ObjectRowMapper<T extends Resource>

getResultSet

public ResultSet getResultSet(SimpleEntityFilter<? extends Entity> filter)
                       throws SQLException
Throws:
SQLException

getResultSet

public ResultSet getResultSet(Filter<T> filter)
                       throws SQLException
Description copied from interface: ObjectRowMapper
constructs the ResultSet that corresponds closesd to the filter; note that the filter may be null, in which case the select statement should return all rows. The returned PreparedStatement should allow at least for all objects accepted by the filter; it may include more, which would then be filtered out by the filter itself.

Specified by:
getResultSet in interface ObjectRowMapper<T extends Resource>
Throws:
SQLException


(c) 2001-2006 Holger Antelmann - all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads