commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1397876 - in /commons/proper/csv/trunk/src: main/java/org/apache/commons/csv/CSVFormat.java test/java/org/apache/commons/csv/CSVFormatTest.java
Date Sat, 13 Oct 2012 16:08:44 GMT
Author: ggregory
Date: Sat Oct 13 16:08:44 2012
New Revision: 1397876

URL: http://svn.apache.org/viewvc?rev=1397876&view=rev
Log:
CSVFormat.validate() throws IllegalStateException instead of IllegalArgumentException because
the method validates the state of the object.

Modified:
    commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java
    commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatTest.java

Modified: commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java
URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java?rev=1397876&r1=1397875&r2=1397876&view=diff
==============================================================================
--- commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java (original)
+++ commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java Sat Oct 13
16:08:44 2012
@@ -168,29 +168,31 @@ public class CSVFormat implements Serial
     }
 
     /**
-     * Verifies the consistency of the parameters and throws an IllegalArgumentException
if necessary.
+     * Verifies the consistency of the parameters and throws an IllegalStateException if
necessary.
+     * 
+     * @throws IllegalStateException
      */
-    void validate() throws IllegalArgumentException {
+    void validate() throws IllegalStateException {
         if (delimiter == encapsulator) {
-            throw new IllegalArgumentException("The encapsulator character and the delimiter
cannot be the same ('" + encapsulator + ")");
+            throw new IllegalStateException("The encapsulator character and the delimiter
cannot be the same ('" + encapsulator + ")");
         }
 
         if (delimiter == escape) {
-            throw new IllegalArgumentException("The escape character and the delimiter cannot
be the same ('" + escape + "')");
+            throw new IllegalStateException("The escape character and the delimiter cannot
be the same ('" + escape + "')");
         }
 
         if (delimiter == commentStart) {
-            throw new IllegalArgumentException("The comment start character and the delimiter
cannot be the same ('" + commentStart + 
+            throw new IllegalStateException("The comment start character and the delimiter
cannot be the same ('" + commentStart + 
                     "')");
         }
 
         if (encapsulator != null && encapsulator == commentStart) {
-            throw new IllegalArgumentException("The comment start character and the encapsulator
cannot be the same ('" + commentStart + 
+            throw new IllegalStateException("The comment start character and the encapsulator
cannot be the same ('" + commentStart + 
                     "')");
         }
 
         if (escape != null && escape == commentStart) {
-            throw new IllegalArgumentException("The comment start and the escape character
cannot be the same ('" + commentStart + "')");
+            throw new IllegalStateException("The comment start and the escape character cannot
be the same ('" + commentStart + "')");
         }
     }
 

Modified: commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatTest.java
URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatTest.java?rev=1397876&r1=1397875&r2=1397876&view=diff
==============================================================================
--- commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatTest.java (original)
+++ commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatTest.java Sat Oct
13 16:08:44 2012
@@ -113,21 +113,21 @@ public class CSVFormatTest {
         try {
             format.withDelimiter('!').withEscape('!').validate();
             fail();
-        } catch (final IllegalArgumentException e) {
+        } catch (final IllegalStateException e) {
             // expected
         }
 
         try {
             format.withDelimiter('!').withCommentStart('!').validate();
             fail();
-        } catch (final IllegalArgumentException e) {
+        } catch (final IllegalStateException e) {
             // expected
         }
 
         try {
             format.withEncapsulator('!').withCommentStart('!').validate();
             fail();
-        } catch (final IllegalArgumentException e) {
+        } catch (final IllegalStateException e) {
             // expected
         }
 
@@ -136,7 +136,7 @@ public class CSVFormatTest {
         try {
             format.withEscape('!').withCommentStart('!').validate();
             fail();
-        } catch (final IllegalArgumentException e) {
+        } catch (final IllegalStateException e) {
             // expected
         }
 
@@ -146,7 +146,7 @@ public class CSVFormatTest {
         try {
             format.withEncapsulator('!').withDelimiter('!').validate();
             fail();
-        } catch (final IllegalArgumentException e) {
+        } catch (final IllegalStateException e) {
             // expected
         }
     }



Mime
View raw message