You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2016/05/22 06:38:31 UTC
[2/3] camel git commit: CAMEL-9954: Documentation for changes since
2.18.0
CAMEL-9954: Documentation for changes since 2.18.0
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/4cbf2c11
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/4cbf2c11
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/4cbf2c11
Branch: refs/heads/master
Commit: 4cbf2c11201eedad606e97617707bd37fa477bcb
Parents: 87129c8
Author: Arno Noordover <ar...@noordover.net>
Authored: Sat May 21 18:01:00 2016 +0200
Committer: Arno Noordover <ar...@noordover.net>
Committed: Sat May 21 18:01:00 2016 +0200
----------------------------------------------------------------------
components/camel-bindy/src/main/docs/bindy.adoc | 58 +++++++++++++++++++-
1 file changed, 57 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/4cbf2c11/components/camel-bindy/src/main/docs/bindy.adoc
----------------------------------------------------------------------
diff --git a/components/camel-bindy/src/main/docs/bindy.adoc b/components/camel-bindy/src/main/docs/bindy.adoc
index f236c2b..2a2a306 100644
--- a/components/camel-bindy/src/main/docs/bindy.adoc
+++ b/components/camel-bindy/src/main/docs/bindy.adoc
@@ -67,7 +67,8 @@ the POJO like :
financial messages),
* Section (to identify header, body and footer section),
* OneToMany,
-* BindyConverter (since 2.18.0)
+* BindyConverter (since 2.18.0),
+* FormatFactories (since 2.18.0)
This section will describe them :
@@ -1532,6 +1533,61 @@ Format interface.
...
---------------------------------------------------------------------------------------------------
+[[Bindy-10.FormatFactories]]
+10. FormatFactories
+^^^^^^^^^^^^^^^^^^^
+
+The purpose of the annotation @FormatFactories is to define a set of converters
+at record-level. The provided classes must implement the FormatFactoryInterface interface.
+
+[source,java]
+---------------------------------------------------------------------------------------------------
+ @CsvRecord(separator = ",")
+ @FormatFactories({OrderNumberFormatFactory.class})
+ public static class Order {
+
+ @DataField(pos = 1)
+ private OrderNumber orderNr;
+
+ @DataField(pos = 2)
+ private String firstName;
+
+...
+ }
+
+ public static class OrderNumber {
+ private int orderNr;
+
+ public static OrderNumber ofString(String orderNumber) {
+ OrderNumber result = new OrderNumber();
+ result.orderNr = Integer.valueOf(orderNumber);
+ return result;
+ }
+ }
+
+ public static class OrderNumberFormatFactory extends AbstractFormatFactory {
+
+ {
+ supportedClasses.add(OrderNumber.class);
+ }
+
+ @Override
+ public Format<?> build(FormattingOptions formattingOptions) {
+ return new Format<OrderNumber>() {
+ @Override
+ public String format(OrderNumber object) throws Exception {
+ return String.valueOf(object.orderNr);
+ }
+
+ @Override
+ public OrderNumber parse(String string) throws Exception {
+ return OrderNumber.ofString(string);
+ }
+ };
+ }
+ }
+---------------------------------------------------------------------------------------------------
+
[[Bindy-SupportedDatatypes]]
Supported Datatypes
^^^^^^^^^^^^^^^^^^^