From a7bd28c496457aa7c32db4ea529c4f3df7e78fe9 Mon Sep 17 00:00:00 2001 From: Emmanuel Bourg Date: Wed, 9 Nov 2011 22:04:01 +0000 Subject: [PATCH] Renamed CSVParser.getAllValues() to getRecords() git-svn-id: https://svn.apache.org/repos/asf/commons/sandbox/csv/trunk@1199997 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/commons/csv/CSVParser.java | 6 ++-- .../java/org/apache/commons/csv/CSVUtils.java | 2 +- .../org/apache/commons/csv/CSVParserTest.java | 32 +++++++++---------- .../apache/commons/csv/CSVPrinterTest.java | 2 +- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/main/java/org/apache/commons/csv/CSVParser.java b/src/main/java/org/apache/commons/csv/CSVParser.java index a3a59efc..4add9a99 100644 --- a/src/main/java/org/apache/commons/csv/CSVParser.java +++ b/src/main/java/org/apache/commons/csv/CSVParser.java @@ -33,13 +33,13 @@ import static org.apache.commons.csv.CSVParser.Token.Type.*; *

Parsing of a csv-string having tabs as separators, * '"' as an optional value encapsulator, and comments starting with '#':

*
- *  String[][] data =
+ *  String[][] record =
  *   (new CSVParser(new StringReader("a\tb\nc\td"), new CSVFormat('\t','"','#'))).getAllValues();
  * 
* *

Parsing of a csv-string in Excel CSV format

*
- *  String[][] data =
+ *  String[][] record =
  *   (new CSVParser(new StringReader("a;b\nc;d"), CSVFormat.EXCEL)).getAllValues();
  * 
* @@ -150,7 +150,7 @@ public class CSVParser { * @return matrix of records x values ('null' when end of file) * @throws IOException on parse error or input read-failure */ - public String[][] getAllValues() throws IOException { + public String[][] getRecords() throws IOException { List records = new ArrayList(); String[] values; String[][] ret = null; diff --git a/src/main/java/org/apache/commons/csv/CSVUtils.java b/src/main/java/org/apache/commons/csv/CSVUtils.java index f1374719..cb1c2321 100644 --- a/src/main/java/org/apache/commons/csv/CSVUtils.java +++ b/src/main/java/org/apache/commons/csv/CSVUtils.java @@ -88,7 +88,7 @@ public class CSVUtils { if (s == null) { throw new IllegalArgumentException("Null argument not allowed."); } - String[][] result = (new CSVParser(new StringReader(s))).getAllValues(); + String[][] result = (new CSVParser(new StringReader(s))).getRecords(); if (result == null) { // since CSVFormat ignores empty lines an empty array is returned // (i.e. not "result = new String[][] {{""}};") diff --git a/src/test/java/org/apache/commons/csv/CSVParserTest.java b/src/test/java/org/apache/commons/csv/CSVParserTest.java index ff608dee..56eb9b5e 100644 --- a/src/test/java/org/apache/commons/csv/CSVParserTest.java +++ b/src/test/java/org/apache/commons/csv/CSVParserTest.java @@ -221,7 +221,7 @@ public class CSVParserTest extends TestCase { public void testGetAllValues() throws IOException { CSVParser parser = new CSVParser(new StringReader(code)); - String[][] tmp = parser.getAllValues(); + String[][] tmp = parser.getRecords(); assertEquals(res.length, tmp.length); assertTrue(tmp.length > 0); for (int i = 0; i < res.length; i++) { @@ -241,7 +241,7 @@ public class CSVParserTest extends TestCase { {"\"hello\"", " \"world\"", "abc\ndef", ""} }; CSVParser parser = new CSVParser(new StringReader(code), CSVFormat.EXCEL); - String[][] tmp = parser.getAllValues(); + String[][] tmp = parser.getRecords(); assertEquals(res.length, tmp.length); assertTrue(tmp.length > 0); for (int i = 0; i < res.length; i++) { @@ -259,7 +259,7 @@ public class CSVParserTest extends TestCase { {"world", ""} }; CSVParser parser = new CSVParser(new StringReader(code), CSVFormat.EXCEL); - String[][] tmp = parser.getAllValues(); + String[][] tmp = parser.getRecords(); assertEquals(res.length, tmp.length); assertTrue(tmp.length > 0); for (int i = 0; i < res.length; i++) { @@ -286,7 +286,7 @@ public class CSVParserTest extends TestCase { for (String code : codes) { CSVParser parser = new CSVParser(new StringReader(code), CSVFormat.EXCEL); - String[][] tmp = parser.getAllValues(); + String[][] tmp = parser.getRecords(); assertEquals(res.length, tmp.length); assertTrue(tmp.length > 0); for (int i = 0; i < res.length; i++) { @@ -314,7 +314,7 @@ public class CSVParserTest extends TestCase { for (int codeIndex = 0; codeIndex < codes.length; codeIndex++) { code = codes[codeIndex]; CSVParser parser = new CSVParser(new StringReader(code)); - String[][] tmp = parser.getAllValues(); + String[][] tmp = parser.getRecords(); assertEquals(res.length, tmp.length); assertTrue(tmp.length > 0); for (int i = 0; i < res.length; i++) { @@ -339,7 +339,7 @@ public class CSVParserTest extends TestCase { for (int codeIndex = 0; codeIndex < codes.length; codeIndex++) { code = codes[codeIndex]; CSVParser parser = new CSVParser(new StringReader(code), CSVFormat.EXCEL); - String[][] tmp = parser.getAllValues(); + String[][] tmp = parser.getRecords(); assertEquals(res.length, tmp.length); assertTrue(tmp.length > 0); for (int i = 0; i < res.length; i++) { @@ -362,7 +362,7 @@ public class CSVParserTest extends TestCase { for (int codeIndex = 0; codeIndex < codes.length; codeIndex++) { code = codes[codeIndex]; CSVParser parser = new CSVParser(new StringReader(code)); - String[][] tmp = parser.getAllValues(); + String[][] tmp = parser.getRecords(); assertEquals(res.length, tmp.length); assertTrue(tmp.length > 0); for (int i = 0; i < res.length; i++) { @@ -394,7 +394,7 @@ public class CSVParserTest extends TestCase { {"a\\\\,b"} // backslash in quotes only escapes a delimiter (",") }; CSVParser parser = new CSVParser(new StringReader(code)); - String[][] tmp = parser.getAllValues(); + String[][] tmp = parser.getRecords(); assertEquals(res.length, tmp.length); assertTrue(tmp.length > 0); for (int i = 0; i < res.length; i++) { @@ -437,7 +437,7 @@ public class CSVParserTest extends TestCase { CSVFormat format = new CSVFormat(',', '\'', CSVFormat.COMMENTS_DISABLED, '/', false, false, true, true); CSVParser parser = new CSVParser(new StringReader(code), format); - String[][] tmp = parser.getAllValues(); + String[][] tmp = parser.getRecords(); assertTrue(tmp.length > 0); for (int i = 0; i < res.length; i++) { assertTrue(Arrays.equals(res[i], tmp[i])); @@ -465,7 +465,7 @@ public class CSVParserTest extends TestCase { CSVFormat format = new CSVFormat(',', CSVFormat.ENCAPSULATOR_DISABLED, CSVFormat.COMMENTS_DISABLED, '/', false, false, true, true); CSVParser parser = new CSVParser(new StringReader(code), format); - String[][] tmp = parser.getAllValues(); + String[][] tmp = parser.getRecords(); assertTrue(tmp.length > 0); if (!CSVPrinterTest.equals(res, tmp)) { @@ -492,7 +492,7 @@ public class CSVParserTest extends TestCase { assertEquals(CSVFormat.COMMENTS_DISABLED, format.getCommentStart()); CSVParser parser = new CSVParser(new StringReader(code), format); - String[][] tmp = parser.getAllValues(); + String[][] tmp = parser.getRecords(); assertTrue(tmp.length > 0); if (!CSVPrinterTest.equals(res, tmp)) { @@ -507,7 +507,7 @@ public class CSVParserTest extends TestCase { format = new CSVFormat(',', '"', '#'); parser = new CSVParser(new StringReader(code), format); - tmp = parser.getAllValues(); + tmp = parser.getRecords(); if (!CSVPrinterTest.equals(res_comments, tmp)) { assertTrue(false); @@ -527,21 +527,21 @@ public class CSVParserTest extends TestCase { public void testCarriageReturnLineFeedEndings() throws IOException { String code = "foo\r\nbaar,\r\nhello,world\r\n,kanu"; CSVParser parser = new CSVParser(new StringReader(code)); - String[][] data = parser.getAllValues(); + String[][] data = parser.getRecords(); assertEquals(4, data.length); } public void testCarriageReturnEndings() throws IOException { String code = "foo\rbaar,\rhello,world\r,kanu"; CSVParser parser = new CSVParser(new StringReader(code)); - String[][] data = parser.getAllValues(); + String[][] data = parser.getRecords(); assertEquals(4, data.length); } public void testLineFeedEndings() throws IOException { String code = "foo\nbaar,\nhello,world\n,kanu"; CSVParser parser = new CSVParser(new StringReader(code)); - String[][] data = parser.getAllValues(); + String[][] data = parser.getRecords(); assertEquals(4, data.length); } @@ -550,7 +550,7 @@ public class CSVParserTest extends TestCase { //String code = "world\r\n\n"; //String code = "foo;baar\r\n\r\nhello;\r\n\r\nworld;\r\n"; CSVParser parser = new CSVParser(new StringReader(code)); - String[][] data = parser.getAllValues(); + String[][] data = parser.getRecords(); assertEquals(3, data.length); } diff --git a/src/test/java/org/apache/commons/csv/CSVPrinterTest.java b/src/test/java/org/apache/commons/csv/CSVPrinterTest.java index 0f8d2ce7..d97028a5 100644 --- a/src/test/java/org/apache/commons/csv/CSVPrinterTest.java +++ b/src/test/java/org/apache/commons/csv/CSVPrinterTest.java @@ -152,7 +152,7 @@ public class CSVPrinterTest extends TestCase { StringReader reader = new StringReader(result); CSVParser parser = new CSVParser(reader, format); - String[][] parseResult = parser.getAllValues(); + String[][] parseResult = parser.getRecords(); if (!equals(lines, parseResult)) { System.out.println("Printer output :" + printable(result));