From fc4ccb426eb3934ee1656db9b18c7d797ac6bd1d Mon Sep 17 00:00:00 2001 From: Emmanuel Bourg Date: Wed, 9 Nov 2011 14:54:05 +0000 Subject: [PATCH] Removed CSVParser.nextValue() (SANDBOX-220) git-svn-id: https://svn.apache.org/repos/asf/commons/sandbox/csv/trunk@1199780 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/commons/csv/CSVParser.java | 29 ------------------- .../org/apache/commons/csv/CSVParserTest.java | 27 ----------------- 2 files changed, 56 deletions(-) diff --git a/src/main/java/org/apache/commons/csv/CSVParser.java b/src/main/java/org/apache/commons/csv/CSVParser.java index 38e344ef..6af298c1 100644 --- a/src/main/java/org/apache/commons/csv/CSVParser.java +++ b/src/main/java/org/apache/commons/csv/CSVParser.java @@ -165,35 +165,6 @@ public class CSVParser { return ret; } - /** - * Parses the CSV according to the given strategy - * and returns the next csv-value as string. - * - * @return next value in the input stream ('null' when end of file) - * @throws IOException on parse error or input read-failure - */ - public String nextValue() throws IOException { - Token tkn = nextToken(); - String ret = null; - switch (tkn.type) { - case TT_TOKEN: - case TT_EORECORD: - ret = tkn.content.toString(); - break; - case TT_EOF: - ret = null; - break; - case TT_INVALID: - default: - // error no token available (or error) - throw new IOException( - "(line " + getLineNumber() - + ") invalid parse sequence"); - // unreachable: break; - } - return ret; - } - /** * Parses from the current point in the stream til * the end of the current line. diff --git a/src/test/java/org/apache/commons/csv/CSVParserTest.java b/src/test/java/org/apache/commons/csv/CSVParserTest.java index ecee9c7e..e77670fe 100644 --- a/src/test/java/org/apache/commons/csv/CSVParserTest.java +++ b/src/test/java/org/apache/commons/csv/CSVParserTest.java @@ -221,19 +221,6 @@ public class CSVParserTest extends TestCase { assertTrue(tmp == null); } - public void testNextValue() throws IOException { - CSVParser parser = new CSVParser(new StringReader(code)); - String tmp = null; - for (int i = 0; i < res.length; i++) { - for (int j = 0; j < res[i].length; j++) { - tmp = parser.nextValue(); - assertEquals(res[i][j], tmp); - } - } - tmp = parser.nextValue(); - assertTrue(tmp == null); - } - public void testGetAllValues() throws IOException { CSVParser parser = new CSVParser(new StringReader(code)); String[][] tmp = parser.getAllValues(); @@ -571,20 +558,6 @@ public class CSVParserTest extends TestCase { assertEquals(3, data.length); } - public void testLineTokenConsistency() throws IOException { - String code = "\nfoo,baar\n\r\n,\n\n,world\r\n\n"; - CSVParser parser = new CSVParser(new StringReader(code)); - String[][] data = parser.getAllValues(); - parser = new CSVParser(new StringReader(code)); - CSVParser parser1 = new CSVParser(new StringReader(code)); - for (int i = 0; i < data.length; i++) { - assertTrue(Arrays.equals(parser1.getLine(), data[i])); - for (int j = 0; j < data[i].length; j++) { - assertEquals(parser.nextValue(), data[i][j]); - } - } - } - // From SANDBOX-153 public void testDelimiterIsWhitespace() throws IOException { String code = "one\ttwo\t\tfour \t five\t six";