dgraham     2003/10/18 12:13:52

  Modified:    dbutils/src/java/org/apache/commons/dbutils MapHandler.java
  Log:
  Added ability to configure the RowProcessor used in conversions.
  
  Revision  Changes    Path
  1.6       +29 -4     
jakarta-commons-sandbox/dbutils/src/java/org/apache/commons/dbutils/MapHandler.java
  
  Index: MapHandler.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/dbutils/src/java/org/apache/commons/dbutils/MapHandler.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- MapHandler.java   18 Oct 2003 19:02:22 -0000      1.5
  +++ MapHandler.java   18 Oct 2003 19:13:52 -0000      1.6
  @@ -73,6 +73,31 @@
    * @author David Graham
    */
   public class MapHandler implements ResultSetHandler {
  +    
  +    /**
  +     * The RowProcessor implementation to use when converting rows 
  +     * into Maps.
  +     */
  +    private RowProcessor convert = BasicRowProcessor.instance();
  +    
  +    /** 
  +     * Creates a new instance of MapHandler using a 
  +     * <code>BasicRowProcessor</code> for conversion.
  +     */
  +    public MapHandler() {
  +        super();
  +    }
  +    
  +    /** 
  +     * Creates a new instance of MapHandler.
  +     * 
  +     * @param convert The <code>RowProcessor</code> implementation 
  +     * to use when converting rows into Maps.
  +     */
  +    public MapHandler(RowProcessor convert) {
  +        super();
  +        this.convert = convert;
  +    }
   
       /**
        * Converts the first row in the <code>ResultSet</code> into a 
  @@ -88,7 +113,7 @@
       public Object handle(ResultSet rs, Object[] params, Object userObject)
           throws SQLException {
   
  -        return rs.next() ? BasicRowProcessor.instance().toMap(rs) : null;
  +        return rs.next() ? this.convert.toMap(rs) : null;
       }
   
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to