Author: markt
Date: Tue Jul 19 23:41:33 2011
New Revision: 1148584

URL: http://svn.apache.org/viewvc?rev=1148584&view=rev
Log:
More generics and supporting refactoring

Added:
    
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/cpdsadapter/PStmtKey.java
   (with props)
Modified:
    commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/PStmtKey.java
    
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/PoolingConnection.java
    
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/cpdsadapter/PooledConnectionImpl.java

Modified: 
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/PStmtKey.java
URL: 
http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/PStmtKey.java?rev=1148584&r1=1148583&r2=1148584&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/PStmtKey.java 
(original)
+++ commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/PStmtKey.java 
Tue Jul 19 23:41:33 2011
@@ -21,55 +21,55 @@ import java.sql.PreparedStatement;
 /**
  * A key uniquely identifying {@link PreparedStatement}s.
  */
-class PStmtKey {
+public class PStmtKey {
     
     /** SQL defining Prepared or Callable Statement */
-    protected String _sql = null;
+    private String _sql = null;
     
     /** Result set type */
-    protected Integer _resultSetType = null;
+    private Integer _resultSetType = null;
     
     /** Result set concurrency */
-    protected Integer _resultSetConcurrency = null;
+    private Integer _resultSetConcurrency = null;
     
     /** Database catalog */
-    protected String _catalog = null;
+    private String _catalog = null;
     
     /** 
      *  Statement type. Either STATEMENT_PREPAREDSTMT (PreparedStatement)
      *  or STATEMENT_CALLABLESTMT (CallableStatement) 
      */
-    protected byte _stmtType = PoolingConnection.STATEMENT_PREPAREDSTMT;
+    private byte _stmtType = PoolingConnection.STATEMENT_PREPAREDSTMT;
     
-    PStmtKey(String sql) {
+    public PStmtKey(String sql) {
         _sql = sql;
     }
 
-    PStmtKey(String sql, String catalog) {
+    public PStmtKey(String sql, String catalog) {
         _sql = sql;
         _catalog = catalog;
     }
     
-    PStmtKey(String sql, String catalog, byte stmtType) {
+    public PStmtKey(String sql, String catalog, byte stmtType) {
         _sql = sql;
         _catalog = catalog;
         _stmtType = stmtType;
     }
 
-    PStmtKey(String sql, int resultSetType, int resultSetConcurrency) {
+    public  PStmtKey(String sql, int resultSetType, int resultSetConcurrency) {
         _sql = sql;
         _resultSetType = new Integer(resultSetType);
         _resultSetConcurrency = new Integer(resultSetConcurrency);
     }
 
-    PStmtKey(String sql, String catalog, int resultSetType, int 
resultSetConcurrency) {
+    public PStmtKey(String sql, String catalog, int resultSetType, int 
resultSetConcurrency) {
         _sql = sql;
         _catalog = catalog;
         _resultSetType = new Integer(resultSetType);
         _resultSetConcurrency = new Integer(resultSetConcurrency);
     }
     
-    PStmtKey(String sql, String catalog, int resultSetType, int 
resultSetConcurrency, byte stmtType) {
+    public PStmtKey(String sql, String catalog, int resultSetType, int 
resultSetConcurrency, byte stmtType) {
         _sql = sql;
         _catalog = catalog;
         _resultSetType = new Integer(resultSetType);
@@ -77,6 +77,27 @@ class PStmtKey {
         _stmtType = stmtType;
     }
 
+    
+    public String getSql() {
+        return _sql;
+    }
+
+    public Integer getResultSetType() {
+        return _resultSetType;
+    }
+
+    public Integer getResultSetConcurrency() {
+        return _resultSetConcurrency;
+    }
+
+    public String getCatalog() {
+        return _catalog;
+    }
+
+    public byte getStmtType() {
+        return _stmtType;
+    }
+
     @Override
     public boolean equals(Object that) {
         try {

Modified: 
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/PoolingConnection.java
URL: 
http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/PoolingConnection.java?rev=1148584&r1=1148583&r2=1148584&view=diff
==============================================================================
--- 
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/PoolingConnection.java
 (original)
+++ 
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/PoolingConnection.java
 Tue Jul 19 23:41:33 2011
@@ -284,19 +284,19 @@ public class PoolingConnection extends D
         if(null == key) {
             throw new IllegalArgumentException("Prepared statement key is null 
or invalid.");
         } else {
-            if( null == key._resultSetType && null == 
key._resultSetConcurrency ) {
-                if (key._stmtType == STATEMENT_PREPAREDSTMT ) {
-                    return new 
PoolablePreparedStatement(getDelegate().prepareStatement( key._sql), key, 
_pstmtPool, this); 
+            if( null == key.getResultSetType() && null == 
key.getResultSetConcurrency()) {
+                if (key.getStmtType() == STATEMENT_PREPAREDSTMT ) {
+                    return new 
PoolablePreparedStatement(getDelegate().prepareStatement( key.getSql()), key, 
_pstmtPool, this); 
                 } else {
-                    return new 
PoolableCallableStatement(getDelegate().prepareCall( key._sql), key, 
_pstmtPool, this);
+                    return new 
PoolableCallableStatement(getDelegate().prepareCall( key.getSql()), key, 
_pstmtPool, this);
                 }
             } else { // Both _resultSetType and _resultSetConcurrency are 
non-null here (both or neither are set by constructors)
-                if(key._stmtType == STATEMENT_PREPAREDSTMT) {
+                if(key.getStmtType() == STATEMENT_PREPAREDSTMT) {
                     return new 
PoolablePreparedStatement(getDelegate().prepareStatement(
-                        key._sql, 
key._resultSetType.intValue(),key._resultSetConcurrency.intValue()), key, 
_pstmtPool, this);
+                        key.getSql(), 
key.getResultSetType().intValue(),key.getResultSetConcurrency().intValue()), 
key, _pstmtPool, this);
                 } else {
                     return new PoolableCallableStatement( 
getDelegate().prepareCall(
-                        key._sql,key._resultSetType.intValue(), 
key._resultSetConcurrency.intValue()), key, _pstmtPool, this);
+                        key.getSql(),key.getResultSetType().intValue(), 
key.getResultSetConcurrency().intValue()), key, _pstmtPool, this);
                 }
             }
         }

Added: 
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/cpdsadapter/PStmtKey.java
URL: 
http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/cpdsadapter/PStmtKey.java?rev=1148584&view=auto
==============================================================================
--- 
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/cpdsadapter/PStmtKey.java
 (added)
+++ 
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/cpdsadapter/PStmtKey.java
 Tue Jul 19 23:41:33 2011
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.dbcp2.cpdsadapter;
+
+import java.util.Arrays;
+
+/**
+ * A key uniquely identifying {*link PreparedStatement}s.
+ */
+public class PStmtKey extends org.apache.commons.dbcp2.PStmtKey {
+    private Integer _autoGeneratedKeys = null;
+    private Integer _resultSetHoldability = null;
+    private int _columnIndexes[] = null;
+    private String _columnNames[] = null;
+    
+    public PStmtKey(String sql) {
+        super(sql);
+    }
+
+    public PStmtKey(String sql, int autoGeneratedKeys) {
+        super(sql);
+        _autoGeneratedKeys = new Integer(autoGeneratedKeys);
+    }
+
+    public PStmtKey(String sql, int resultSetType, int resultSetConcurrency) {
+        super(sql, resultSetType, resultSetConcurrency);
+    }
+
+    public PStmtKey(String sql, int resultSetType, int resultSetConcurrency,
+            int resultSetHoldability) {
+        super(sql, resultSetType, resultSetConcurrency);
+        _resultSetHoldability = new Integer(resultSetHoldability);
+    }
+
+    public PStmtKey(String sql, int columnIndexes[]) {
+        super(sql);
+        _columnIndexes = columnIndexes;
+    }
+
+    public PStmtKey(String sql, String columnNames[]) {
+        super(sql);
+        _columnNames = columnNames;
+    }
+
+    
+    public Integer getAutoGeneratedKeys() {
+        return _autoGeneratedKeys;
+    }
+
+    public Integer getResultSetHoldability() {
+        return _resultSetHoldability;
+    }
+
+    public int[] getColumnIndexes() {
+        return _columnIndexes;
+    }
+
+    public String[] getColumnNames() {
+        return _columnNames;
+    }
+
+    @Override
+    public boolean equals(Object that) {
+        try {
+            PStmtKey key = (PStmtKey) that;
+            return(((null == getSql() && null == key.getSql()) || 
getSql().equals(key.getSql())) &&
+                   ((null == getCatalog() && null == key.getCatalog()) || 
getCatalog().equals(key.getCatalog())) &&
+                   ((null == getResultSetType() && null == 
key.getResultSetType()) || getResultSetType().equals(key.getResultSetType())) &&
+                   ((null == getResultSetConcurrency() && null == 
key.getResultSetConcurrency()) || 
getResultSetConcurrency().equals(key.getResultSetConcurrency())) &&
+                   (getStmtType() == key.getStmtType()) &&
+                   ((null == _autoGeneratedKeys && null == 
key._autoGeneratedKeys) || _autoGeneratedKeys.equals(key._autoGeneratedKeys)) &&
+                   ((null == _resultSetHoldability && null == 
key._resultSetHoldability) || 
_resultSetHoldability.equals(key._resultSetHoldability)) &&
+                   ((null == _columnIndexes && null == key._columnIndexes) || 
Arrays.equals(_columnIndexes, key._columnIndexes)) &&
+                   ((null == _columnNames && null == key._columnNames) || 
Arrays.equals(_columnNames, key._columnNames))
+                  );
+        } catch (ClassCastException e) {
+            return false;
+        } catch (NullPointerException e) {
+            return false;
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuffer buf = new StringBuffer();
+        buf.append("PStmtKey: sql=");
+        buf.append(getSql());
+        buf.append(", catalog=");
+        buf.append(getCatalog());
+        buf.append(", resultSetType=");
+        buf.append(getResultSetType());
+        buf.append(", resultSetConcurrency=");
+        buf.append(getResultSetConcurrency());
+        buf.append(", statmentType=");
+        buf.append(getStmtType());
+        buf.append(", autoGeneratedKeys=");
+        buf.append(_autoGeneratedKeys);
+        buf.append(", resultSetHoldability=");
+        buf.append(_resultSetHoldability);
+        buf.append(", columnIndexes=");
+        buf.append(Arrays.toString(_columnIndexes));
+        buf.append(", columnNames=");
+        buf.append(Arrays.toString(_columnNames));
+        return buf.toString();
+    }
+}
\ No newline at end of file

Propchange: 
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/cpdsadapter/PStmtKey.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/cpdsadapter/PooledConnectionImpl.java
URL: 
http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/cpdsadapter/PooledConnectionImpl.java?rev=1148584&r1=1148583&r2=1148584&view=diff
==============================================================================
--- 
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/cpdsadapter/PooledConnectionImpl.java
 (original)
+++ 
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/cpdsadapter/PooledConnectionImpl.java
 Tue Jul 19 23:41:33 2011
@@ -20,7 +20,6 @@ package org.apache.commons.dbcp2.cpdsada
 import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.SQLException;
-import java.util.Arrays;
 import java.util.Vector;
 
 import javax.sql.ConnectionEvent;
@@ -31,7 +30,6 @@ import javax.sql.StatementEventListener;
 /* JDBC_4_ANT_KEY_END */
 
 import org.apache.commons.dbcp2.DelegatingConnection;
-import org.apache.commons.dbcp2.DelegatingPreparedStatement;
 import org.apache.commons.pool2.KeyedObjectPool;
 import org.apache.commons.pool2.KeyedPoolableObjectFactory;
 
@@ -42,8 +40,9 @@ import org.apache.commons.pool2.KeyedPoo
  * @author John D. McNally
  * @version $Revision$ $Date$
  */
-class PooledConnectionImpl 
-        implements PooledConnection, KeyedPoolableObjectFactory {
+class PooledConnectionImpl implements PooledConnection,
+        KeyedPoolableObjectFactory<PStmtKey,PoolablePreparedStatementStub> {
+    
     private static final String CLOSED 
             = "Attempted to use PooledConnection after closed() was called.";
 
@@ -65,12 +64,13 @@ class PooledConnectionImpl 
     /**
      * ConnectionEventListeners
      */
-    private final Vector eventListeners;
+    private final Vector<ConnectionEventListener> eventListeners;
 
     /**
      * StatementEventListeners
      */
-    private final Vector statementEventListeners = new Vector();
+    private final Vector<StatementEventListener> statementEventListeners =
+        new Vector<StatementEventListener>();
 
     /**
      * flag set to true, once close() is called.
@@ -79,7 +79,7 @@ class PooledConnectionImpl 
 
     /** My pool of {*link PreparedStatement}s. */
     // TODO - make final?
-    protected KeyedObjectPool pstmtPool = null;
+    protected KeyedObjectPool<PStmtKey,PoolablePreparedStatementStub> 
pstmtPool = null;
 
     /** 
      * Controls access to the underlying connection 
@@ -98,11 +98,12 @@ class PooledConnectionImpl 
         } else {
             this.delegatingConnection = new DelegatingConnection(connection);
         }
-        eventListeners = new Vector();
+        eventListeners = new Vector<ConnectionEventListener>();
         isClosed = false;
     }
     
-    public void setStatementPool(KeyedObjectPool statementPool) {
+    public void setStatementPool(
+            KeyedObjectPool<PStmtKey,PoolablePreparedStatementStub> 
statementPool) {
         pstmtPool = statementPool;
     }
 
@@ -249,8 +250,7 @@ class PooledConnectionImpl 
             return connection.prepareStatement(sql);
         } else {
             try {
-                return (PreparedStatement) 
-                        pstmtPool.borrowObject(createKey(sql));
+                return pstmtPool.borrowObject(createKey(sql));
             } catch (RuntimeException e) {
                 throw e;
             } catch (Exception e) {
@@ -282,8 +282,8 @@ class PooledConnectionImpl 
             return connection.prepareStatement(sql, resultSetType, 
resultSetConcurrency);
         } else {
             try {
-                return (PreparedStatement) pstmtPool.borrowObject(
-                    createKey(sql,resultSetType,resultSetConcurrency));
+                return pstmtPool.borrowObject(
+                        createKey(sql,resultSetType,resultSetConcurrency));
             } catch (RuntimeException e) {
                 throw e;
             } catch (Exception e) {
@@ -309,8 +309,7 @@ class PooledConnectionImpl 
             return connection.prepareStatement(sql, autoGeneratedKeys);
         } else {
             try {
-                return (PreparedStatement) pstmtPool.borrowObject(
-                    createKey(sql,autoGeneratedKeys));
+                return 
pstmtPool.borrowObject(createKey(sql,autoGeneratedKeys));
             } catch (RuntimeException e) {
                 throw e;
             } catch (Exception e) {
@@ -327,9 +326,8 @@ class PooledConnectionImpl 
                     resultSetConcurrency, resultSetHoldability);
         } else {
             try {
-                return (PreparedStatement) pstmtPool.borrowObject(
-                    createKey(sql, resultSetType, resultSetConcurrency,
-                            resultSetHoldability));
+                return pstmtPool.borrowObject(createKey(sql, resultSetType,
+                        resultSetConcurrency, resultSetHoldability));
             } catch (RuntimeException e) {
                 throw e;
             } catch (Exception e) {
@@ -344,8 +342,7 @@ class PooledConnectionImpl 
             return connection.prepareStatement(sql, columnIndexes);
         } else {
             try {
-                return (PreparedStatement) pstmtPool.borrowObject(
-                    createKey(sql, columnIndexes));
+                return pstmtPool.borrowObject(createKey(sql, columnIndexes));
             } catch (RuntimeException e) {
                 throw e;
             } catch (Exception e) {
@@ -360,8 +357,7 @@ class PooledConnectionImpl 
             return connection.prepareStatement(sql, columnNames);
         } else {
             try {
-                return (PreparedStatement) pstmtPool.borrowObject(
-                    createKey(sql, columnNames));
+                return pstmtPool.borrowObject(createKey(sql, columnNames));
             } catch (RuntimeException e) {
                 throw e;
             } catch (Exception e) {
@@ -373,14 +369,14 @@ class PooledConnectionImpl 
     /**
      * Create a {*link PooledConnectionImpl.PStmtKey} for the given arguments.
      */
-    protected Object createKey(String sql, int autoGeneratedKeys) {
+    protected PStmtKey createKey(String sql, int autoGeneratedKeys) {
         return new PStmtKey(normalizeSQL(sql), autoGeneratedKeys);
     }
 
     /**
      * Create a {*link PooledConnectionImpl.PStmtKey} for the given arguments.
      */
-    protected Object createKey(String sql, int resultSetType,
+    protected PStmtKey createKey(String sql, int resultSetType,
             int resultSetConcurrency, int resultSetHoldability) {
         return new PStmtKey(normalizeSQL(sql), resultSetType,
                 resultSetConcurrency, resultSetHoldability);
@@ -389,21 +385,21 @@ class PooledConnectionImpl 
     /**
      * Create a {*link PooledConnectionImpl.PStmtKey} for the given arguments.
      */
-    protected Object createKey(String sql, int columnIndexes[]) {
+    protected PStmtKey createKey(String sql, int columnIndexes[]) {
         return new PStmtKey(normalizeSQL(sql), columnIndexes);
     }
 
     /**
      * Create a {*link PooledConnectionImpl.PStmtKey} for the given arguments.
      */
-    protected Object createKey(String sql, String columnNames[]) {
+    protected PStmtKey createKey(String sql, String columnNames[]) {
         return new PStmtKey(normalizeSQL(sql), columnNames);
     }
 
     /**
      * Create a {*link PooledConnectionImpl.PStmtKey} for the given arguments.
      */
-    protected Object createKey(String sql, int resultSetType, 
+    protected PStmtKey createKey(String sql, int resultSetType, 
                                int resultSetConcurrency) {
         return new PStmtKey(normalizeSQL(sql), resultSetType,
                             resultSetConcurrency);
@@ -412,7 +408,7 @@ class PooledConnectionImpl 
     /**
      * Create a {*link PooledConnectionImpl.PStmtKey} for the given arguments.
      */
-    protected Object createKey(String sql) {
+    protected PStmtKey createKey(String sql) {
         return new PStmtKey(normalizeSQL(sql));
     }
 
@@ -430,29 +426,28 @@ class PooledConnectionImpl 
      * @param obj the key for the {*link PreparedStatement} to be created
      */
     @Override
-    public Object makeObject(Object obj) throws Exception {
-        if (null == obj || !(obj instanceof PStmtKey)) {
+    public PoolablePreparedStatementStub makeObject(PStmtKey key) throws 
Exception {
+        if (null == key) {
             throw new IllegalArgumentException();
         } else {
             // _openPstmts++;
-            PStmtKey key = (PStmtKey)obj;
-            if (null == key._resultSetType 
-                    && null == key._resultSetConcurrency) {
-                if (null == key._autoGeneratedKeys) {
+            if (null == key.getResultSetType()
+                    && null == key.getResultSetConcurrency()) {
+                if (null == key.getAutoGeneratedKeys()) {
                     return new PoolablePreparedStatementStub(
-                            connection.prepareStatement(key._sql),
+                            connection.prepareStatement(key.getSql()),
                             key, pstmtPool, delegatingConnection);
                 } else {
                     return new PoolablePreparedStatementStub(
-                            connection.prepareStatement(key._sql,
-                                    key._autoGeneratedKeys.intValue()),
+                            connection.prepareStatement(key.getSql(),
+                                    key.getAutoGeneratedKeys().intValue()),
                             key, pstmtPool, delegatingConnection);
                 }
             } else {
                 return new PoolablePreparedStatementStub(
-                        connection.prepareStatement(key._sql,
-                        key._resultSetType.intValue(),
-                        key._resultSetConcurrency.intValue()),
+                        connection.prepareStatement(key.getSql(),
+                        key.getResultSetType().intValue(),
+                        key.getResultSetConcurrency().intValue()),
                         key, pstmtPool, delegatingConnection);
             }
         }
@@ -465,13 +460,9 @@ class PooledConnectionImpl 
      * @param obj the {*link PreparedStatement} to be destroyed.
      */
     @Override
-    public void destroyObject(Object key, Object obj) throws Exception {
-        //_openPstmts--;
-        if (obj instanceof DelegatingPreparedStatement) {
-            ((DelegatingPreparedStatement) obj).getInnermostDelegate().close();
-        } else {
-            ((PreparedStatement) obj).close();
-        }
+    public void destroyObject(PStmtKey key, PoolablePreparedStatementStub ppss)
+            throws Exception {
+        ppss.getInnermostDelegate().close();
     }
 
     /**
@@ -482,7 +473,7 @@ class PooledConnectionImpl 
      * @return <tt>true</tt>
      */
     @Override
-    public boolean validateObject(Object key, Object obj) {
+    public boolean validateObject(PStmtKey key, PoolablePreparedStatementStub 
ppss) {
         return true;
     }
 
@@ -493,8 +484,9 @@ class PooledConnectionImpl 
      * @param obj ignored
      */
     @Override
-    public void activateObject(Object key, Object obj) throws Exception {
-        ((PoolablePreparedStatementStub) obj).activate();
+    public void activateObject(PStmtKey key, PoolablePreparedStatementStub 
ppss)
+            throws Exception {
+        ppss.activate();
     }
 
     /**
@@ -504,9 +496,10 @@ class PooledConnectionImpl 
      * @param obj a {*link PreparedStatement}
      */
     @Override
-    public void passivateObject(Object key, Object obj) throws Exception {
-        ((PreparedStatement) obj).clearParameters();
-        ((PoolablePreparedStatementStub) obj).passivate();
+    public void passivateObject(PStmtKey key, PoolablePreparedStatementStub 
ppss)
+            throws Exception {
+        ppss.clearParameters();
+        ppss.passivate();
     }
 
     /**
@@ -528,125 +521,4 @@ class PooledConnectionImpl 
     public synchronized void setAccessToUnderlyingConnectionAllowed(boolean 
allow) {
         this.accessToUnderlyingConnectionAllowed = allow;
     }
-    
-    /**
-     * A key uniquely identifying {*link PreparedStatement}s.
-     */
-    static class PStmtKey {
-        protected String _sql = null;
-        protected Integer _resultSetType = null;
-        protected Integer _resultSetConcurrency = null;
-        protected Integer _autoGeneratedKeys = null;
-        protected Integer _resultSetHoldability = null;
-        protected int _columnIndexes[] = null;
-        protected String _columnNames[] = null;
-        
-        PStmtKey(String sql) {
-            _sql = sql;
-        }
-
-        PStmtKey(String sql, int resultSetType, int resultSetConcurrency) {
-            _sql = sql;
-            _resultSetType = new Integer(resultSetType);
-            _resultSetConcurrency = new Integer(resultSetConcurrency);
-        }
-
-        PStmtKey(String sql, int autoGeneratedKeys) {
-            _sql = sql;
-            _autoGeneratedKeys = new Integer(autoGeneratedKeys);
-        }
-
-        PStmtKey(String sql, int resultSetType, int resultSetConcurrency,
-                int resultSetHoldability) {
-            _sql = sql;
-            _resultSetType = new Integer(resultSetType);
-            _resultSetConcurrency = new Integer(resultSetConcurrency);
-            _resultSetHoldability = new Integer(resultSetHoldability);
-        }
-
-        PStmtKey(String sql, int columnIndexes[]) {
-            _sql = sql;
-            _columnIndexes = columnIndexes;
-        }
-
-        PStmtKey(String sql, String columnNames[]) {
-            _sql = sql;
-            _columnNames = columnNames;
-        }
-
-        
-        @Override
-        public boolean equals(Object that) {
-            try {
-                PStmtKey key = (PStmtKey) that;
-                return(((null == _sql && null == key._sql) || 
_sql.equals(key._sql)) &&
-                       ((null == _resultSetType && null == key._resultSetType) 
|| _resultSetType.equals(key._resultSetType)) &&
-                       ((null == _resultSetConcurrency && null == 
key._resultSetConcurrency) || 
_resultSetConcurrency.equals(key._resultSetConcurrency)) &&
-                       ((null == _autoGeneratedKeys && null == 
key._autoGeneratedKeys) || _autoGeneratedKeys.equals(key._autoGeneratedKeys)) &&
-                       ((null == _resultSetHoldability && null == 
key._resultSetHoldability) || 
_resultSetHoldability.equals(key._resultSetHoldability)) &&
-                       ((null == _columnIndexes && null == key._columnIndexes) 
|| Arrays.equals(_columnIndexes, key._columnIndexes)) &&
-                       ((null == _columnNames && null == key._columnNames) || 
Arrays.equals(_columnNames, key._columnNames))
-                      );
-            } catch (ClassCastException e) {
-                return false;
-            } catch (NullPointerException e) {
-                return false;
-            }
-        }
-
-        @Override
-        public int hashCode() {
-            return(null == _sql ? 0 : _sql.hashCode());
-        }
-
-        @Override
-        public String toString() {
-            StringBuffer buf = new StringBuffer();
-            buf.append("PStmtKey: sql=");
-            buf.append(_sql);
-            buf.append(", resultSetType=");
-            buf.append(_resultSetType);
-            buf.append(", resultSetConcurrency=");
-            buf.append(_resultSetConcurrency);
-            buf.append(", autoGeneratedKeys=");
-            buf.append(_autoGeneratedKeys);
-            buf.append(", resultSetHoldability=");
-            buf.append(_resultSetHoldability);
-            buf.append(", columnIndexes=");
-// JDK1.5   buf.append(Arrays.toString(_columnIndexes));
-            arrayToString(buf,_columnIndexes);
-            buf.append(", columnNames=");
-// JDK1.5   buf.append(Arrays.toString(_columnNames));
-            arrayToString(buf,_columnNames);
-            return buf.toString();
-        }
-        private void arrayToString(StringBuffer sb, int[] array){
-            if (array == null) {
-                sb.append("null");
-                return;
-            }
-            sb.append('[');
-            for(int i=0; i<array.length; i++){
-                if (i>0){
-                    sb.append(',');
-                }
-                sb.append(array[i]);
-            }
-            sb.append(']');
-        }
-        private void arrayToString(StringBuffer sb, String[] array){
-            if (array == null) {
-                sb.append("null");
-                return;
-            }
-            sb.append('[');
-            for(int i=0; i<array.length; i++){
-                if (i>0){
-                    sb.append(',');
-                }
-                sb.append(array[i]);
-            }
-            sb.append(']');
-        }
-    }
 }


Reply via email to