You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by yo...@apache.org on 2006/12/22 04:42:07 UTC

svn commit: r489553 - in /jakarta/commons/sandbox/csv/trunk/src: java/org/apache/commons/csv/CSVStrategy.java test/org/apache/commons/csv/CSVParserTest.java test/org/apache/commons/csv/CSVPrinterTest.java test/org/apache/commons/csv/CSVStrategyTest.java

Author: yonik
Date: Thu Dec 21 19:42:06 2006
New Revision: 489553

URL: http://svn.apache.org/viewvc?view=rev&rev=489553
Log:
change excel strategy to use ',' as the separator: SANDBOX-182

Modified:
    jakarta/commons/sandbox/csv/trunk/src/java/org/apache/commons/csv/CSVStrategy.java
    jakarta/commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/CSVParserTest.java
    jakarta/commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/CSVPrinterTest.java
    jakarta/commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/CSVStrategyTest.java

Modified: jakarta/commons/sandbox/csv/trunk/src/java/org/apache/commons/csv/CSVStrategy.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/csv/trunk/src/java/org/apache/commons/csv/CSVStrategy.java?view=diff&rev=489553&r1=489552&r2=489553
==============================================================================
--- jakarta/commons/sandbox/csv/trunk/src/java/org/apache/commons/csv/CSVStrategy.java (original)
+++ jakarta/commons/sandbox/csv/trunk/src/java/org/apache/commons/csv/CSVStrategy.java Thu Dec 21 19:42:06 2006
@@ -35,7 +35,7 @@
     public static char COMMENTS_DISABLED       = (char) 0;
 
     public static CSVStrategy DEFAULT_STRATEGY = new CSVStrategy(',', '"', COMMENTS_DISABLED, true,  false, true);
-    public static CSVStrategy EXCEL_STRATEGY   = new CSVStrategy(';', '"', COMMENTS_DISABLED, false, false, false);
+    public static CSVStrategy EXCEL_STRATEGY   = new CSVStrategy(',', '"', COMMENTS_DISABLED, false, false, false);
     public static CSVStrategy TDF_STRATEGY     = new CSVStrategy('	', '"', COMMENTS_DISABLED, true,  false, true);
 
 

Modified: jakarta/commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/CSVParserTest.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/CSVParserTest.java?view=diff&rev=489553&r1=489552&r2=489553
==============================================================================
--- jakarta/commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/CSVParserTest.java (original)
+++ jakarta/commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/CSVParserTest.java Thu Dec 21 19:42:06 2006
@@ -272,8 +272,8 @@
   
   public void testExcelStrategy1() throws IOException {
     String code = 
-      "value1;value2;value3;value4\r\na;b;c;d\r\n  x;;;"
-      + "\r\n\r\n\"\"\"hello\"\"\";\"  \"\"world\"\"\";\"abc\ndef\";\r\n";
+      "value1,value2,value3,value4\r\na,b,c,d\r\n  x,,,"
+      + "\r\n\r\n\"\"\"hello\"\"\",\"  \"\"world\"\"\",\"abc\ndef\",\r\n";
     String[][] res = {
       {"value1", "value2", "value3", "value4"},
       {"a", "b", "c", "d"},
@@ -281,8 +281,7 @@
       {""},
       {"\"hello\"", "  \"world\"", "abc\ndef", ""}
     };
-    CSVParser parser = new CSVParser(new StringReader(code));
-    parser.setStrategy(CSVStrategy.EXCEL_STRATEGY);
+    CSVParser parser = new CSVParser(new StringReader(code), CSVStrategy.EXCEL_STRATEGY);
     System.out.println("---------\n" + code + "\n-------------");
     String[][] tmp = parser.getAllValues();
     assertEquals(res.length, tmp.length);
@@ -293,7 +292,7 @@
   }
   
   public void testExcelStrategy2() throws Exception {
-    String code = "foo;baar\r\n\r\nhello;\r\n\r\nworld;\r\n";
+    String code = "foo,baar\r\n\r\nhello,\r\n\r\nworld,\r\n";
     String[][] res = {
       {"foo", "baar"},
       {""},
@@ -317,14 +316,14 @@
   
   public void testEndOfFileBehaviourExcel() throws Exception {
     String[] codes = {
-        "hello;\r\n\r\nworld;\r\n",
-        "hello;\r\n\r\nworld;",
-        "hello;\r\n\r\nworld;\"\"\r\n",
-        "hello;\r\n\r\nworld;\"\"",
-        "hello;\r\n\r\nworld;\n",
-        "hello;\r\n\r\nworld;",
-        "hello;\r\n\r\nworld;\"\"\n",
-        "hello;\r\n\r\nworld;\"\""
+        "hello,\r\n\r\nworld,\r\n",
+        "hello,\r\n\r\nworld,",
+        "hello,\r\n\r\nworld,\"\"\r\n",
+        "hello,\r\n\r\nworld,\"\"",
+        "hello,\r\n\r\nworld,\n",
+        "hello,\r\n\r\nworld,",
+        "hello,\r\n\r\nworld,\"\"\n",
+        "hello,\r\n\r\nworld,\"\""
         };
     String[][] res = {
       {"hello", ""},
@@ -384,10 +383,10 @@
   
   public void testEmptyLineBehaviourExcel() throws Exception {
     String[] codes = {
-        "hello;\r\n\r\n\r\n",
-        "hello;\n\n\n",
-        "hello;\"\"\r\n\r\n\r\n",
-        "hello;\"\"\n\n\n"
+        "hello,\r\n\r\n\r\n",
+        "hello,\n\n\n",
+        "hello,\"\"\r\n\r\n\r\n",
+        "hello,\"\"\n\n\n"
         };
     String[][] res = {
       {"hello", ""},

Modified: jakarta/commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/CSVPrinterTest.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/CSVPrinterTest.java?view=diff&rev=489553&r1=489552&r2=489553
==============================================================================
--- jakarta/commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/CSVPrinterTest.java (original)
+++ jakarta/commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/CSVPrinterTest.java Thu Dec 21 19:42:06 2006
@@ -70,16 +70,16 @@
     printer.setStrategy(CSVStrategy.EXCEL_STRATEGY);
     String[] line1 = {"a", "b"};
     printer.println(line1);
-    assertEquals("a;b" + lineSeparator, sw.toString());
+    assertEquals("a,b" + lineSeparator, sw.toString());
   }
 
   public void testExcelPrinter2() {
     StringWriter sw = new StringWriter();
     CSVPrinter printer = new CSVPrinter(sw);
     printer.setStrategy(CSVStrategy.EXCEL_STRATEGY);
-    String[] line1 = {"a;b", "b"};
+    String[] line1 = {"a,b", "b"};
     printer.println(line1);
-    assertEquals("\"a;b\";b" + lineSeparator, sw.toString());
+    assertEquals("\"a,b\",b" + lineSeparator, sw.toString());
   }
 
 }

Modified: jakarta/commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/CSVStrategyTest.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/CSVStrategyTest.java?view=diff&rev=489553&r1=489552&r2=489553
==============================================================================
--- jakarta/commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/CSVStrategyTest.java (original)
+++ jakarta/commons/sandbox/csv/trunk/src/test/org/apache/commons/csv/CSVStrategyTest.java Thu Dec 21 19:42:06 2006
@@ -107,7 +107,7 @@
   
   public void testSetExcelStrategy() {
     CSVStrategy strategy = CSVStrategy.EXCEL_STRATEGY;
-    assertEquals(strategy.getDelimiter(), ';');
+    assertEquals(strategy.getDelimiter(), ',');
     assertEquals(strategy.getEncapsulator(), '"');
     assertEquals(strategy.getCommentStart(), '\0');
     assertEquals(false,  strategy.getIgnoreLeadingWhitespaces());



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org