You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ja...@apache.org on 2014/01/31 17:08:59 UTC
[4/8] git commit: CAMEL-7159 - search for Link-ed fields and add them
to the model automatically
CAMEL-7159 - search for Link-ed fields and add them to the model automatically
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/369b9553
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/369b9553
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/369b9553
Branch: refs/heads/camel-2.12.x
Commit: 369b95534c894ee7fb9aeec815a932f3c617b3e1
Parents: d278c01
Author: Jonathan Anstey <ja...@gmail.com>
Authored: Fri Jan 31 12:32:09 2014 -0330
Committer: Jonathan Anstey <ja...@gmail.com>
Committed: Fri Jan 31 12:36:29 2014 -0330
----------------------------------------------------------------------
.../camel/dataformat/bindy/csv/BindyCsvDataFormat.java | 13 +++++++++++++
1 file changed, 13 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/369b9553/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/csv/BindyCsvDataFormat.java
----------------------------------------------------------------------
diff --git a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/csv/BindyCsvDataFormat.java b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/csv/BindyCsvDataFormat.java
index 312ddd0..10bb9e0 100755
--- a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/csv/BindyCsvDataFormat.java
+++ b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/csv/BindyCsvDataFormat.java
@@ -19,6 +19,7 @@ package org.apache.camel.dataformat.bindy.csv;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
+import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -31,6 +32,8 @@ import org.apache.camel.Exchange;
import org.apache.camel.dataformat.bindy.BindyAbstractDataFormat;
import org.apache.camel.dataformat.bindy.BindyAbstractFactory;
import org.apache.camel.dataformat.bindy.BindyCsvFactory;
+import org.apache.camel.dataformat.bindy.annotation.DataField;
+import org.apache.camel.dataformat.bindy.annotation.Link;
import org.apache.camel.dataformat.bindy.util.ConverterUtils;
import org.apache.camel.spi.DataFormat;
import org.apache.camel.spi.PackageScanClassResolver;
@@ -88,6 +91,16 @@ public class BindyCsvDataFormat extends BindyAbstractDataFormat {
String name = model.getClass().getName();
Map<String, Object> row = new HashMap<String, Object>(1);
row.put(name, model);
+ // search for @Link-ed fields and add them to the model
+ for (Field field : model.getClass().getDeclaredFields()) {
+ Link linkField = field.getAnnotation(Link.class);
+ if (linkField != null) {
+ boolean accessible = field.isAccessible();
+ field.setAccessible(true);
+ row.put(field.getType().getName(), field.get(model));
+ field.setAccessible(accessible);
+ }
+ }
models.add(row);
}
}