You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by df...@apache.org on 2009/03/11 05:45:21 UTC

svn commit: r752369 - /commons/proper/dbutils/trunk/src/java/org/apache/commons/dbutils/handlers/KeyedHandler.java

Author: dfabulich
Date: Wed Mar 11 04:45:21 2009
New Revision: 752369

URL: http://svn.apache.org/viewvc?rev=752369&view=rev
Log:
Applying sebb's KeyedHandler.patch from DBUTILS-51

Modified:
    commons/proper/dbutils/trunk/src/java/org/apache/commons/dbutils/handlers/KeyedHandler.java

Modified: commons/proper/dbutils/trunk/src/java/org/apache/commons/dbutils/handlers/KeyedHandler.java
URL: http://svn.apache.org/viewvc/commons/proper/dbutils/trunk/src/java/org/apache/commons/dbutils/handlers/KeyedHandler.java?rev=752369&r1=752368&r2=752369&view=diff
==============================================================================
--- commons/proper/dbutils/trunk/src/java/org/apache/commons/dbutils/handlers/KeyedHandler.java (original)
+++ commons/proper/dbutils/trunk/src/java/org/apache/commons/dbutils/handlers/KeyedHandler.java Wed Mar 11 04:45:21 2009
@@ -63,25 +63,25 @@
      * The RowProcessor implementation to use when converting rows
      * into Objects.
      */
-    protected RowProcessor convert = ArrayHandler.ROW_PROCESSOR;
+    protected final RowProcessor convert;
 
     /**
      * The column index to retrieve key values from.  Defaults to 1.
      */
-    protected int columnIndex = 1;
+    protected final int columnIndex;
 
     /**
      * The column name to retrieve key values from.  Either columnName or 
      * columnIndex will be used but never both.
      */
-    protected String columnName = null;
+    protected final String columnName;
 
     /** 
      * Creates a new instance of KeyedHandler.  The value of the first column 
      * of each row will be a key in the Map.
      */
     public KeyedHandler() {
-        super();
+        this(ArrayHandler.ROW_PROCESSOR, 1, null);
     }
 
     /**
@@ -92,8 +92,7 @@
      * to use when converting rows into Maps
      */
     public KeyedHandler(RowProcessor convert) {
-        super();
-        this.convert = convert;
+        this(convert, 1, null);
     }
 
     /** 
@@ -103,8 +102,7 @@
      * retrieved from the column at this index.
      */
     public KeyedHandler(int columnIndex) {
-        super();
-        this.columnIndex = columnIndex;
+        this(ArrayHandler.ROW_PROCESSOR, columnIndex, null);
     }
 
     /** 
@@ -114,7 +112,15 @@
      * retrieved from the column with this name.
      */
     public KeyedHandler(String columnName) {
+        this(ArrayHandler.ROW_PROCESSOR, 1, columnName);
+    }
+
+    // Helper
+    private KeyedHandler(RowProcessor convert, int columnIndex,
+            String columnName) {
         super();
+        this.convert = convert;
+        this.columnIndex = columnIndex;
         this.columnName = columnName;
     }