commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yo...@apache.org
Subject svn commit: r608911 - /commons/sandbox/csv/trunk/src/java/org/apache/commons/csv/writer/CSVWriter.java
Date Fri, 04 Jan 2008 16:38:29 GMT
Author: yonik
Date: Fri Jan  4 08:38:28 2008
New Revision: 608911

URL: http://svn.apache.org/viewvc?rev=608911&view=rev
Log:
SANDBOX-202: CSVWriter can't handle missing entries in the Map - or non-String map values

Modified:
    commons/sandbox/csv/trunk/src/java/org/apache/commons/csv/writer/CSVWriter.java

Modified: commons/sandbox/csv/trunk/src/java/org/apache/commons/csv/writer/CSVWriter.java
URL: http://svn.apache.org/viewvc/commons/sandbox/csv/trunk/src/java/org/apache/commons/csv/writer/CSVWriter.java?rev=608911&r1=608910&r2=608911&view=diff
==============================================================================
--- commons/sandbox/csv/trunk/src/java/org/apache/commons/csv/writer/CSVWriter.java (original)
+++ commons/sandbox/csv/trunk/src/java/org/apache/commons/csv/writer/CSVWriter.java Fri Jan
 4 08:38:28 2008
@@ -50,9 +50,12 @@
         try {
             StringBuffer sb = new StringBuffer();
             for (int i = 0; i < fields.length; i++) {
-                String value = (String) map.get(fields[i].getName());
-                value = writeValue(fields[i], value);
-                sb.append(value);
+                Object o = map.get(fields[i].getName());
+                if (o != null) {
+                    String value = o.toString();
+                    value = writeValue(fields[i], value);
+                    sb.append(value);
+                }
                 if (!config.isDelimiterIgnored() && fields.length != (i+1)) {
                     sb.append(config.getDelimiter());
                 }



Mime
View raw message