You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2024/02/16 13:57:13 UTC
(camel) 02/03: CAMEL-20410: documentation fixes for camel-beanio
This is an automated email from the ASF dual-hosted git repository.
orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 9363bb3654d26ee131f8d228763c188ab580305c
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Fri Feb 16 13:33:28 2024 +0100
CAMEL-20410: documentation fixes for camel-beanio
- Fixed samples
- Converted to use tabs
- Fixed grammar and typos
- Fixed punctuation
- Added and/or fixed links
---
.../src/main/docs/beanio-dataformat.adoc | 61 +++++++++++-----------
1 file changed, 31 insertions(+), 30 deletions(-)
diff --git a/components/camel-beanio/src/main/docs/beanio-dataformat.adoc b/components/camel-beanio/src/main/docs/beanio-dataformat.adoc
index 918fa95e037..35a47afbb49 100644
--- a/components/camel-beanio/src/main/docs/beanio-dataformat.adoc
+++ b/components/camel-beanio/src/main/docs/beanio-dataformat.adoc
@@ -15,7 +15,7 @@ The BeanIO Data Format uses
https://beanio.github.io/[BeanIO] to handle flat payloads (such as XML, CSV,
delimited, or fixed length formats).
-BeanIO is configured using a mappings XML file where you define the mapping from the flat format to Objects
+BeanIO is configured using a mapping XML file where you define the mapping from the flat format to Objects
(POJOs). This mapping file is mandatory to use.
== Options
@@ -30,52 +30,36 @@ An example of a
https://svn.apache.org/repos/asf/camel/trunk/components/camel-beanio/src/test/resources/org/apache/camel/dataformat/beanio/mappings.xml[mapping
file is here].
-=== Using Java DSL
+To use the `BeanIODataFormat` you need to configure the data format with the mapping file, as well the name of the stream.
-To use the `BeanIODataFormat` you need to configure the data format with
-the mapping file, as well the name of the stream.
-
-In Java DSL this can be done as shown below. The streamName is "employeeFile".
+This can be done as shown below. The streamName is `employeeFile`.
+[tabs]
+====
+Java::
++
[source,java]
----
DataFormat format = new BeanIODataFormat(
"org/apache/camel/dataformat/beanio/mappings.xml",
"employeeFile");
-// a route which uses the bean io data format to format a CSV data
+// a route which uses the bean io data format to format the CSV data
// to java objects
from("direct:unmarshal")
.unmarshal(format)
- // and then split the message body so we get a message for each row
+ // and then split the message body, so we get a message for each row
.split(body())
.to("mock:beanio-unmarshal");
-// convert list of java objects back to flat format
+// convert a list of java objects back to flat format
from("direct:marshal")
.marshal(format)
.to("mock:beanio-marshal");
----
-Then we have two routes. The first route is for transforming CSV data
-into a `List<Employee>` Java objects. Which we then split, so the mock endpoint receives a message for each row.
-
-The 2nd route is for the reverse operation, to transform a `List<Employee>` into a stream of CSV data.
-
-The CSV data could for example be as below:
-
-[source,text]
-----
-Joe,Smith,Developer,75000,10012009
-Jane,Doe,Architect,80000,01152008
-Jon,Anderson,Manager,85000,03182007
-----
-
-=== Using XML DSL
-
-To use the BeanIO data format in XML, you need to configure it using the
-`<beanio>` XML tag as shown below. The routes are similar to the example above.
-
+XML::
++
[source,xml]
----
<route>
@@ -97,13 +81,30 @@ To use the BeanIO data format in XML, you need to configure it using the
<to uri="mock:beanio-marshal"/>
</route>
----
+To use the BeanIO data format in XML, you need to configure it using the
+`<beanio>` XML tag as shown below. The routes are similar to the example above.
+====
+
+The first route is for transforming CSV data into a `List<Employee>` Java objects.
+Which we then split, so the mock endpoint receives a message for each row.
+
+The second route is for the reverse operation, to transform a `List<Employee>` into a stream of CSV data.
+
+The CSV data could, for example, be as below:
+
+[source,text]
+----
+Joe,Smith,Developer,75000,10012009
+Jane,Doe,Architect,80000,01152008
+Jon,Anderson,Manager,85000,03182007
+----
== Dependencies
-To use BeanIO in your Camel routes you need to add a dependency on
+To use BeanIO in your Camel routes, you need to add a dependency on
*camel-beanio* which implements this data format.
-If you use Maven you can just add the following to your pom.xml,
+If you use Maven, you can just add the following to your pom.xml,
substituting the version number for the latest & greatest release (see
the download page for the latest versions).