commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1397900 - in /commons/proper/csv/trunk/src: main/java/org/apache/commons/csv/CSVParser.java test/java/org/apache/commons/csv/CSVParserTest.java
Date Sat, 13 Oct 2012 17:13:18 GMT
Author: ggregory
Date: Sat Oct 13 17:13:18 2012
New Revision: 1397900

URL: http://svn.apache.org/viewvc?rev=1397900&view=rev
Log:
Rename getRecord() to nextRecord()

Modified:
    commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVParser.java
    commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVParserTest.java

Modified: commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVParser.java
URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVParser.java?rev=1397900&r1=1397899&r2=1397900&view=diff
==============================================================================
--- commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVParser.java (original)
+++ commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVParser.java Sat Oct 13
17:13:18 2012
@@ -161,7 +161,7 @@ public class CSVParser implements Iterab
      * @throws IOException
      *             on parse error or input read-failure
      */
-    CSVRecord getRecord() throws IOException {
+    CSVRecord nextRecord() throws IOException {
         CSVRecord result = new CSVRecord(null, headerMap, null, recordNumber + 1);
         record.clear();
         StringBuilder sb = null;
@@ -217,7 +217,7 @@ public class CSVParser implements Iterab
     public List<CSVRecord> getRecords() throws IOException {
         final List<CSVRecord> records = new ArrayList<CSVRecord>();
         CSVRecord rec;
-        while ((rec = getRecord()) != null) {
+        while ((rec = nextRecord()) != null) {
             records.add(rec);
         }
         return records;
@@ -234,7 +234,7 @@ public class CSVParser implements Iterab
             String[] header = null;
             if (format.getHeader().length == 0) {
                 // read the header from the first line of the file
-                final CSVRecord rec = getRecord();
+                final CSVRecord rec = nextRecord();
                 if (rec != null) {
                     header = rec.values();
                 }
@@ -262,7 +262,7 @@ public class CSVParser implements Iterab
 
             private CSVRecord getNextRecord() {
                 try {
-                    return getRecord();
+                    return nextRecord();
                 } catch (final IOException e) {
                     throw new RuntimeException(e);
                 }

Modified: commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVParserTest.java
URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVParserTest.java?rev=1397900&r1=1397899&r2=1397900&view=diff
==============================================================================
--- commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVParserTest.java (original)
+++ commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVParserTest.java Sat Oct
13 17:13:18 2012
@@ -70,10 +70,10 @@ public class CSVParserTest {
     public void testGetLine() throws IOException {
         final CSVParser parser = new CSVParser(new StringReader(CSVINPUT), CSVFormat.DEFAULT.withIgnoreSurroundingSpaces(true));
         for (final String[] re : RESULT) {
-            assertArrayEquals(re, parser.getRecord().values());
+            assertArrayEquals(re, parser.nextRecord().values());
         }
 
-        assertNull(parser.getRecord());
+        assertNull(parser.nextRecord());
     }
 
     @Test
@@ -232,7 +232,7 @@ public class CSVParserTest {
     @Test
     public void testEmptyFile() throws Exception {
         final CSVParser parser = new CSVParser("", CSVFormat.DEFAULT);
-        assertNull(parser.getRecord());
+        assertNull(parser.nextRecord());
     }
 
     @Test
@@ -612,19 +612,19 @@ public class CSVParserTest {
         CSVRecord record;
         assertEquals(0, parser.getRecordNumber());
         assertEquals(0, parser.getLineNumber());
-        assertNotNull(record = parser.getRecord());
+        assertNotNull(record = parser.nextRecord());
         assertEquals(3, parser.getLineNumber());
         assertEquals(1, record.getRecordNumber());
         assertEquals(1, parser.getRecordNumber());
-        assertNotNull(record = parser.getRecord());
+        assertNotNull(record = parser.nextRecord());
         assertEquals(6, parser.getLineNumber());
         assertEquals(2, record.getRecordNumber());
         assertEquals(2, parser.getRecordNumber());
-        assertNotNull(record = parser.getRecord());
+        assertNotNull(record = parser.nextRecord());
         assertEquals(8, parser.getLineNumber());
         assertEquals(3, record.getRecordNumber());
         assertEquals(3, parser.getRecordNumber());
-        assertNull(record = parser.getRecord());
+        assertNull(record = parser.nextRecord());
         assertEquals(8, parser.getLineNumber());
         assertEquals(3, parser.getRecordNumber());
     }
@@ -643,30 +643,30 @@ public class CSVParserTest {
         final CSVParser parser = new CSVParser("a" + lineSeparator + "b" + lineSeparator
+ "c", CSVFormat.DEFAULT.withLineSeparator(lineSeparator));
         CSVRecord record;
         assertEquals(0, parser.getRecordNumber());
-        assertNotNull(record = parser.getRecord());
+        assertNotNull(record = parser.nextRecord());
         assertEquals(1, record.getRecordNumber());        
         assertEquals(1, parser.getRecordNumber());
-        assertNotNull(record = parser.getRecord());
+        assertNotNull(record = parser.nextRecord());
         assertEquals(2, record.getRecordNumber());        
         assertEquals(2, parser.getRecordNumber());
-        assertNotNull(record = parser.getRecord());
+        assertNotNull(record = parser.nextRecord());
         assertEquals(3, record.getRecordNumber());        
         assertEquals(3, parser.getRecordNumber());
-        assertNull(record = parser.getRecord());
+        assertNull(record = parser.nextRecord());
         assertEquals(3, parser.getRecordNumber());
     }
 
     private void validateLineNumbers(String lineSeparator) throws IOException {
         final CSVParser parser = new CSVParser("a" + lineSeparator + "b" + lineSeparator
+ "c", CSVFormat.DEFAULT.withLineSeparator(lineSeparator));
         assertEquals(0, parser.getLineNumber());
-        assertNotNull(parser.getRecord());
+        assertNotNull(parser.nextRecord());
         assertEquals(1, parser.getLineNumber());
-        assertNotNull(parser.getRecord());
+        assertNotNull(parser.nextRecord());
         assertEquals(2, parser.getLineNumber());
-        assertNotNull(parser.getRecord());
+        assertNotNull(parser.nextRecord());
         // Still 2 because the last line is does not have EOL chars
         assertEquals(2, parser.getLineNumber());
-        assertNull(parser.getRecord());
+        assertNull(parser.nextRecord());
         // Still 2 because the last line is does not have EOL chars
         assertEquals(2, parser.getLineNumber());
     }



Mime
View raw message