You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by to...@apache.org on 2007/06/19 17:26:25 UTC

svn commit: r548764 - in /harmony/enhanced/classlib/branches/java6/modules/sql/src: main/java/java/sql/SQLException.java test/java/org/apache/harmony/sql/tests/java/sql/SQLExceptionTest.java

Author: tonywu
Date: Tue Jun 19 08:26:24 2007
New Revision: 548764

URL: http://svn.apache.org/viewvc?view=rev&rev=548764
Log:
Apply patch HARMONY-4227 ([classlib][sql][java6] 4 new constructors in java.sql.SQLException)

Modified:
    harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/java/sql/SQLException.java
    harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/SQLExceptionTest.java

Modified: harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/java/sql/SQLException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/java/sql/SQLException.java?view=diff&rev=548764&r1=548763&r2=548764
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/java/sql/SQLException.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/sql/src/main/java/java/sql/SQLException.java Tue Jun 19 08:26:24 2007
@@ -17,7 +17,8 @@
 
 package java.sql;
 
-import java.io.Serializable;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
 
 /**
  * An Exception class that is used in conjunction with JDBC operations. It
@@ -40,7 +41,7 @@
  * additional error information.
  * </ul>
  */
-public class SQLException extends Exception implements Serializable {
+public class SQLException extends Exception implements Iterable<Throwable> {
 
     private static final long serialVersionUID = 2135244094396331484L;
 
@@ -103,6 +104,80 @@
     }
 
     /**
+     * Creates an SQLException object. The Reason string is set to the null if
+     * cause == null or cause.toString() if cause!=null,and the cause Throwable
+     * object is set to the given cause Throwable object.
+     * 
+     * @param theCause
+     *            the Throwable object for the underlying reason this
+     *            SQLException
+     *            
+     * @since 1.6
+     */
+    public SQLException(Throwable theCause) {
+        this(theCause == null ? null : theCause.toString(), null, 0, theCause);
+    }
+
+    /**
+     * Creates an SQLException object. The Reason string is set to the given and
+     * the cause Throwable object is set to the given cause Throwable object.
+     * 
+     * @param theReason
+     *            the string to use as the Reason string
+     * @param theCause
+     *            the Throwable object for the underlying reason this
+     *            SQLException
+     *            
+     * @since 1.6
+     */
+    public SQLException(String theReason, Throwable theCause) {
+        super(theReason, theCause);
+    }
+
+    /**
+     * Creates an SQLException object. The Reason string is set to the given
+     * reason string, the SQLState string is set to the given SQLState string
+     * and the cause Throwable object is set to the given cause Throwable
+     * object.
+     * 
+     * @param theReason
+     *            the string to use as the Reason string
+     * @param theSQLState
+     *            the string to use as the SQLState string
+     * @param theCause
+     *            the Throwable object for the underlying reason this
+     *            SQLException
+     * @since 1.6
+     */
+    public SQLException(String theReason, String theSQLState, Throwable theCause) {
+        super(theReason, theCause);
+        SQLState = theSQLState;
+    }
+
+    /**
+     * Creates an SQLException object. The Reason string is set to the given
+     * reason string, the SQLState string is set to the given SQLState string ,
+     * the Error Code is set to the given error code value, and the cause
+     * Throwable object is set to the given cause Throwable object.
+     * 
+     * @param theReason
+     *            the string to use as the Reason string
+     * @param theSQLState
+     *            the string to use as the SQLState string
+     * @param theErrorCode
+     *            the integer value for the error code
+     * @param theCause
+     *            the Throwable object for the underlying reason this
+     *            SQLException
+     * @since 1.6
+     */
+    public SQLException(String theReason, String theSQLState, int theErrorCode,
+            Throwable theCause) {
+        this(theReason, theSQLState, theCause);
+        vendorCode = theErrorCode;
+    }
+
+    /**
      * Returns the integer error code for this SQLException
      * 
      * @return The integer error code for this SQLException. The meaning of the
@@ -148,6 +223,38 @@
             next.setNextException(ex);
         } else {
             next = ex;
+        }
+    }
+    /**
+     * Answer an iterator over the chained SQLExceptions.
+     */
+    public Iterator<Throwable> iterator() {
+        return new InternalIterator(this);
+    }
+
+    private static class InternalIterator implements Iterator<Throwable> {
+
+        SQLException current;
+
+        InternalIterator(SQLException e) {
+            current = e;
+        }
+
+        public boolean hasNext() {
+            return null != current;
+        }
+
+        public Throwable next() {
+            if (null == current) {
+                throw new NoSuchElementException();
+            }
+            SQLException ret = current;
+            current = current.next;
+            return ret;
+        }
+
+        public void remove() {
+            throw new UnsupportedOperationException();
         }
     }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/SQLExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/SQLExceptionTest.java?view=diff&rev=548764&r1=548763&r2=548764
==============================================================================
Binary files /tmp/tmpMH_Jtr and /tmp/tmpsW84E_ differ