Author: cmoulliard
Date: Tue Aug 11 08:45:24 2009
New Revision: 803033
URL: http://svn.apache.org/viewvc?rev=803033&view=rev
Log:
Code modified to put "null" in the CSV file created when the field of the model
is null
Modified:
camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyCsvFactory.java
camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvNullMarshallTest.java
Modified:
camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyCsvFactory.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyCsvFactory.java?rev=803033&r1=803032&r2=803033&view=diff
==============================================================================
---
camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyCsvFactory.java
(original)
+++
camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyCsvFactory.java
Tue Aug 11 08:45:24 2009
@@ -251,6 +251,10 @@
Object modelField = model.get(field.getDeclaringClass().getName());
if (modelField != null) {
+
+ // Get field value
+ Object value = field.get(modelField);
+ String strValue = null;
if (this.isMessageOrdered()) {
@@ -265,33 +269,34 @@
}
// Get field value
- Object value = field.get(modelField);
+ //Object value = field.get(modelField);
- // Add value to the list if not null
if (value != null) {
-
// Format field value
- String valueFormated = format.format(value);
+ strValue = format.format(value);
+ }
+
+ // Add the content to the TreeMap according to the
+ // position defined
+ positions.put(keyGenerated, strValue);
- // Add the content to the TreeMap according to the
- // position defined
- positions.put(keyGenerated, valueFormated);
-
- if (LOG.isDebugEnabled()) {
- LOG.debug("Positions size : " + positions.size());
- }
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Positions size : " + positions.size());
}
+
} else {
// Get field value
- Object value = field.get(modelField);
+ //Object value = field.get(modelField);
+ //String strValue = null;
// Add value to the list if not null
if (value != null) {
// Format field value
- String valueFormated = format.format(value);
- builder.append(valueFormated);
+ strValue = format.format(value);
+
}
+ builder.append(strValue);
if (it.hasNext()) {
builder.append(separator);
Modified:
camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvNullMarshallTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvNullMarshallTest.java?rev=803033&r1=803032&r2=803033&view=diff
==============================================================================
---
camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvNullMarshallTest.java
(original)
+++
camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvNullMarshallTest.java
Tue Aug 11 08:45:24 2009
@@ -42,7 +42,7 @@
public class BindySimpleCsvNullMarshallTest extends
AbstractJUnit4SpringContextTests {
private List<Map<String, Object>> models = new ArrayList<Map<String,
Object>>();
- private String result =
"1,B2,Keira,Knightley,ISIN,XX23456789,BUY,,450.45,EUR,14-01-2009\r\n";
+ private String result =
"1,B2,Keira,Knightley,ISIN,XX23456789,BUY,null,450.45,EUR,14-01-2009\r\n";
@Produce(uri = "direct:start")
private ProducerTemplate template;