camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r815621 - in /websites/production/camel/content: bindy.html book-dataformat-appendix.html book-in-one-page.html cache/main.pageCache
Date Thu, 03 May 2012 18:20:58 GMT
Author: buildbot
Date: Thu May  3 18:20:57 2012
New Revision: 815621

Log:
Production update by buildbot for camel

Modified:
    websites/production/camel/content/bindy.html
    websites/production/camel/content/book-dataformat-appendix.html
    websites/production/camel/content/book-in-one-page.html
    websites/production/camel/content/cache/main.pageCache

Modified: websites/production/camel/content/bindy.html
==============================================================================
--- websites/production/camel/content/bindy.html (original)
+++ websites/production/camel/content/bindy.html Thu May  3 18:20:57 2012
@@ -116,7 +116,7 @@ to Java Bean using annotations. Using Bi
 
 <div class="table-wrap">
 <table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1"
class="confluenceTh"> Parameter name </th><th colspan="1" rowspan="1" class="confluenceTh">
type </th><th colspan="1" rowspan="1" class="confluenceTh"> Info </th></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd"> separator </td><td colspan="1" rowspan="1"
class="confluenceTd"> string </td><td colspan="1" rowspan="1" class="confluenceTd">
mandatory - can be ',' or ';' or 'anything'. This value is interpreted as a regular expression.
If you want to use a sign which has a special meaning in regular expressions, e.g. the '|'
sign, than you have to mask it, like ' <br clear="none" class="atl-forced-newline">
-|' </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">
skipFirstLine </td><td colspan="1" rowspan="1" class="confluenceTd"> boolean </td><td
colspan="1" rowspan="1" class="confluenceTd"> optional - default value = false - allow
to skip the first line of the CSV file </td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"> crlf </td><td colspan="1" rowspan="1" class="confluenceTd">
string </td><td colspan="1" rowspan="1" class="confluenceTd"> optional - default
value = WINDOWS - allow to define the carriage return character to use </td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd"> generateHeaderColumns </td><td colspan="1"
rowspan="1" class="confluenceTd"> boolean </td><td colspan="1" rowspan="1" class="confluenceTd">
optional - default value = false - uses to generate the header columns of the CSV generates
</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> isOrdered
</td><td colspan="1" rowspan="1" class="confluenceTd"> boolean <
 /td><td colspan="1" rowspan="1" class="confluenceTd"> optional - default value =
false - allow to change the order of the fields when CSV is generated </td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd"> quote </td><td colspan="1" rowspan="1"
class="confluenceTd"> String </td><td colspan="1" rowspan="1" class="confluenceTd">
<b>Camel 2.8.3/2.9:</b> option - allow to specify a quote character of the fields
when CSV is generated </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">&#160;</td><td
colspan="1" rowspan="1" class="confluenceTd">&#160;</td><td colspan="1" rowspan="1"
class="confluenceTd"> This annotation is associated to the root class of the model and
must be declared one time. </td></tr></tbody></table>
+|' </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">
skipFirstLine </td><td colspan="1" rowspan="1" class="confluenceTd"> boolean </td><td
colspan="1" rowspan="1" class="confluenceTd"> optional - default value = false - allow
to skip the first line of the CSV file </td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"> crlf </td><td colspan="1" rowspan="1" class="confluenceTd">
string </td><td colspan="1" rowspan="1" class="confluenceTd"> optional - possible
values = WINDOWS,UNIX,MAC; default value = WINDOWS - allow to define the carriage return character
to use </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">
generateHeaderColumns </td><td colspan="1" rowspan="1" class="confluenceTd"> boolean
</td><td colspan="1" rowspan="1" class="confluenceTd"> optional - default value
= false - uses to generate the header columns of the CSV generates </td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd"> isOrdered </td><td colspan="1" rowspan
 ="1" class="confluenceTd"> boolean </td><td colspan="1" rowspan="1" class="confluenceTd">
optional - default value = false - allow to change the order of the fields when CSV is generated
</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> quote
</td><td colspan="1" rowspan="1" class="confluenceTd"> String </td><td
colspan="1" rowspan="1" class="confluenceTd"> <b>Camel 2.8.3/2.9:</b> option
- allow to specify a quote character of the fields when CSV is generated </td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd">&#160;</td><td colspan="1" rowspan="1"
class="confluenceTd">&#160;</td><td colspan="1" rowspan="1" class="confluenceTd">
This annotation is associated to the root class of the model and must be declared one time.
</td></tr></tbody></table>
 </div>
 
 
@@ -1027,56 +1027,75 @@ package name to initialize the model obj
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
 <pre class="code-java">
 DataFormat bindy = <span class="code-keyword">new</span> CsvBindyDataFormat(<span
class="code-quote">"com.acme.model"</span>);
-
-from(<span class="code-quote">"file:<span class="code-comment">//inbox"</span>).
-</span>  unmarshal(bindy).
-  to(<span class="code-quote">"bean:handleOrder"</span>);
 </pre>
 </div></div>
-<p>The Camel route will pick-up files in the inbox directory, unmarshall CSV records
in a collection of model objects and send the collection<br clear="none">
-to the bean referenced by 'handleOrder'.</p>
 
-<p>The collection is a list of Map. Each Map of the list contains the objects of the
model. Each object can be retrieve using its class name.</p>
+<h4><a shape="rect" name="Bindy-Unmarshaling"></a>Unmarshaling</h4>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
 <pre class="code-java">
-<span class="code-object">int</span> count = 0;
-
-    List&lt;Map&lt;<span class="code-object">String</span>, <span
class="code-object">Object</span>&gt;&gt; models = <span class="code-keyword">new</span>
ArrayList&lt;Map&lt;<span class="code-object">String</span>, <span
class="code-object">Object</span>&gt;&gt;();
-    Map&lt;<span class="code-object">String</span>, <span class="code-object">Object</span>&gt;
model = <span class="code-keyword">new</span> HashMap&lt;<span class="code-object">String</span>,
<span class="code-object">Object</span>&gt;();
+from(<span class="code-quote">"file:<span class="code-comment">//inbox"</span>)
+</span>  .unmarshal(bindy)
+  .to(<span class="code-quote">"direct:handleOrders"</span>);
+</pre>
+</div></div>
 
-    models = (List&lt;Map&lt;<span class="code-object">String</span>,
<span class="code-object">Object</span>&gt;&gt;) exchange.getIn().getBody();
+<p>Alternatively, you can use a named reference to a data format which can then be
defined in your <a shape="rect" href="registry.html" title="Registry">Registry</a>
e.g. your <a shape="rect" href="spring.html" title="Spring">Spring</a> XML file:</p>
+<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
+<pre class="code-java">
+from(<span class="code-quote">"file:<span class="code-comment">//inbox"</span>)
+</span>  .unmarshal(<span class="code-quote">"myBindyDataFormat"</span>)
+  .to(<span class="code-quote">"direct:handleOrders"</span>);
+</pre>
+</div></div>
 
-    Iterator&lt;Map&lt;<span class="code-object">String</span>, <span
class="code-object">Object</span>&gt;&gt; it = models.iterator();
+<p>The Camel route will pick-up files in the inbox directory, unmarshall CSV records
into a collection of model objects and send the collection<br clear="none">
+to the route referenced by 'handleOrders'.</p>
 
-    <span class="code-keyword">while</span>(it.hasNext()){
+<p>The collection returned is a <b>List of Map</b> objects. Each Map within
the list contains the model objects that were marshalled out of each line of the CSV. The
reason behind this is that <em>each line can correspond to more than one object</em>.
This can be confusing when you simply expect one object to be returned per line.</p>
 
-          model = it.next();
+<p>Each object can be retrieve using its class name.</p>
+<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
+<pre class="code-java">
+    List&lt;Map&lt;<span class="code-object">String</span>, <span
class="code-object">Object</span>&gt;&gt; unmarshaledModels = (List&lt;Map&lt;<span
class="code-object">String</span>, <span class="code-object">Object</span>&gt;&gt;)
exchange.getIn().getBody();
 
-	  <span class="code-keyword">for</span>(<span class="code-object">String</span>
key : model.keySet()) {
-	     <span class="code-object">Object</span> obj = model.get(key);
-	     LOG.info(<span class="code-quote">"Count : "</span> + count + <span
class="code-quote">", "</span> + obj.toString());
+    <span class="code-object">int</span> modelCount = 0;
+    <span class="code-keyword">for</span> (Map&lt;<span class="code-object">String</span>,
<span class="code-object">Object</span>&gt; model : unmarshaledModels) {
+	  <span class="code-keyword">for</span> (<span class="code-object">String</span>
className : model.keySet()) {
+	     <span class="code-object">Object</span> obj = model.get(className);
+	     LOG.info(<span class="code-quote">"Count : "</span> + modelCount + <span
class="code-quote">", "</span> + obj.toString());
 	  }
-
-	 count++;
+	 modelCount++;
     }
 
-    LOG.info(<span class="code-quote">"Nber of CSV records received by the csv bean
: "</span> + count);
+    LOG.info(<span class="code-quote">"Total CSV records received by the csv bean :
"</span> + modelCount);
 </pre>
 </div></div>
-<p>To generate CSV records from a collection of model objects, you create the following
route :</p>
+
+<p>Assuming that you want to extract a single Order object from this map for processing
in a route, you could use a combination of a <a shape="rect" href="splitter.html" title="Splitter">Splitter</a>
and a <a shape="rect" href="processor.html" title="Processor">Processor</a> as
per the following:</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
 <pre class="code-java">
-from(<span class="code-quote">"bean:handleOrder"</span>)
-   marshal(bindy)
-   to(<span class="code-quote">"file:<span class="code-comment">//outbox"</span>)</span>
+from(<span class="code-quote">"file:<span class="code-comment">//inbox"</span>)
+</span>    .unmarshal(bindy)
+    .split(body())
+        .process(<span class="code-keyword">new</span> Processor() {
+            <span class="code-keyword">public</span> void process(Exchange exchange)
<span class="code-keyword">throws</span> Exception {
+                Message in = exchange.getIn();
+                Map&lt;<span class="code-object">String</span>, <span
class="code-object">Object</span>&gt; modelMap = (Map&lt;<span class="code-object">String</span>,
<span class="code-object">Object</span>&gt;) in.getBody();
+                in.setBody(modelMap.get(Order.class.getCanonicalName()));
+            }
+        })
+        .to(<span class="code-quote">"direct:handleSingleOrder"</span>)
+    .end();
 </pre>
 </div></div>
-<p>You can if you prefer use a named reference to a data format which can then be defined
in your <a shape="rect" href="registry.html" title="Registry">Registry</a> such
as via your <a shape="rect" href="spring.html" title="Spring">Spring</a> XML file.
e.g.</p>
+
+<h4><a shape="rect" name="Bindy-Marshaling"></a>Marshaling</h4>
+<p>To generate CSV records from a collection of model objects, you create the following
route :</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
 <pre class="code-java">
-from(<span class="code-quote">"file:<span class="code-comment">//inbox"</span>).
-</span>  unmarshal(<span class="code-quote">"myBindyDataFormat"</span>).
-  to(<span class="code-quote">"bean:handleOrder"</span>);
+from(<span class="code-quote">"direct:handleOrders"</span>)
+   .marshal(bindy)
+   .to(<span class="code-quote">"file:<span class="code-comment">//outbox"</span>)</span>
 </pre>
 </div></div>
 

Modified: websites/production/camel/content/book-dataformat-appendix.html
==============================================================================
--- websites/production/camel/content/book-dataformat-appendix.html (original)
+++ websites/production/camel/content/book-dataformat-appendix.html Thu May  3 18:20:57 2012
@@ -1183,7 +1183,7 @@ to Java Bean using annotations. Using Bi
 
 <div class="table-wrap">
 <table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1"
class="confluenceTh"> Parameter name </th><th colspan="1" rowspan="1" class="confluenceTh">
type </th><th colspan="1" rowspan="1" class="confluenceTh"> Info </th></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd"> separator </td><td colspan="1" rowspan="1"
class="confluenceTd"> string </td><td colspan="1" rowspan="1" class="confluenceTd">
mandatory - can be ',' or ';' or 'anything'. This value is interpreted as a regular expression.
If you want to use a sign which has a special meaning in regular expressions, e.g. the '|'
sign, than you have to mask it, like ' <br clear="none" class="atl-forced-newline">
-|' </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">
skipFirstLine </td><td colspan="1" rowspan="1" class="confluenceTd"> boolean </td><td
colspan="1" rowspan="1" class="confluenceTd"> optional - default value = false - allow
to skip the first line of the CSV file </td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"> crlf </td><td colspan="1" rowspan="1" class="confluenceTd">
string </td><td colspan="1" rowspan="1" class="confluenceTd"> optional - default
value = WINDOWS - allow to define the carriage return character to use </td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd"> generateHeaderColumns </td><td colspan="1"
rowspan="1" class="confluenceTd"> boolean </td><td colspan="1" rowspan="1" class="confluenceTd">
optional - default value = false - uses to generate the header columns of the CSV generates
</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> isOrdered
</td><td colspan="1" rowspan="1" class="confluenceTd"> boolean <
 /td><td colspan="1" rowspan="1" class="confluenceTd"> optional - default value =
false - allow to change the order of the fields when CSV is generated </td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd"> quote </td><td colspan="1" rowspan="1"
class="confluenceTd"> String </td><td colspan="1" rowspan="1" class="confluenceTd">
<b>Camel 2.8.3/2.9:</b> option - allow to specify a quote character of the fields
when CSV is generated </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">&#160;</td><td
colspan="1" rowspan="1" class="confluenceTd">&#160;</td><td colspan="1" rowspan="1"
class="confluenceTd"> This annotation is associated to the root class of the model and
must be declared one time. </td></tr></tbody></table>
+|' </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">
skipFirstLine </td><td colspan="1" rowspan="1" class="confluenceTd"> boolean </td><td
colspan="1" rowspan="1" class="confluenceTd"> optional - default value = false - allow
to skip the first line of the CSV file </td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"> crlf </td><td colspan="1" rowspan="1" class="confluenceTd">
string </td><td colspan="1" rowspan="1" class="confluenceTd"> optional - possible
values = WINDOWS,UNIX,MAC; default value = WINDOWS - allow to define the carriage return character
to use </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">
generateHeaderColumns </td><td colspan="1" rowspan="1" class="confluenceTd"> boolean
</td><td colspan="1" rowspan="1" class="confluenceTd"> optional - default value
= false - uses to generate the header columns of the CSV generates </td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd"> isOrdered </td><td colspan="1" rowspan
 ="1" class="confluenceTd"> boolean </td><td colspan="1" rowspan="1" class="confluenceTd">
optional - default value = false - allow to change the order of the fields when CSV is generated
</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> quote
</td><td colspan="1" rowspan="1" class="confluenceTd"> String </td><td
colspan="1" rowspan="1" class="confluenceTd"> <b>Camel 2.8.3/2.9:</b> option
- allow to specify a quote character of the fields when CSV is generated </td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd">&#160;</td><td colspan="1" rowspan="1"
class="confluenceTd">&#160;</td><td colspan="1" rowspan="1" class="confluenceTd">
This annotation is associated to the root class of the model and must be declared one time.
</td></tr></tbody></table>
 </div>
 
 
@@ -2094,56 +2094,75 @@ package name to initialize the model obj
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
 <pre class="code-java">
 DataFormat bindy = <span class="code-keyword">new</span> CsvBindyDataFormat(<span
class="code-quote">"com.acme.model"</span>);
-
-from(<span class="code-quote">"file:<span class="code-comment">//inbox"</span>).
-</span>  unmarshal(bindy).
-  to(<span class="code-quote">"bean:handleOrder"</span>);
 </pre>
 </div></div>
-<p>The Camel route will pick-up files in the inbox directory, unmarshall CSV records
in a collection of model objects and send the collection<br clear="none">
-to the bean referenced by 'handleOrder'.</p>
 
-<p>The collection is a list of Map. Each Map of the list contains the objects of the
model. Each object can be retrieve using its class name.</p>
+<h4><a shape="rect" name="BookDataFormatAppendix-Unmarshaling"></a>Unmarshaling</h4>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
 <pre class="code-java">
-<span class="code-object">int</span> count = 0;
-
-    List&lt;Map&lt;<span class="code-object">String</span>, <span
class="code-object">Object</span>&gt;&gt; models = <span class="code-keyword">new</span>
ArrayList&lt;Map&lt;<span class="code-object">String</span>, <span
class="code-object">Object</span>&gt;&gt;();
-    Map&lt;<span class="code-object">String</span>, <span class="code-object">Object</span>&gt;
model = <span class="code-keyword">new</span> HashMap&lt;<span class="code-object">String</span>,
<span class="code-object">Object</span>&gt;();
+from(<span class="code-quote">"file:<span class="code-comment">//inbox"</span>)
+</span>  .unmarshal(bindy)
+  .to(<span class="code-quote">"direct:handleOrders"</span>);
+</pre>
+</div></div>
 
-    models = (List&lt;Map&lt;<span class="code-object">String</span>,
<span class="code-object">Object</span>&gt;&gt;) exchange.getIn().getBody();
+<p>Alternatively, you can use a named reference to a data format which can then be
defined in your <a shape="rect" href="registry.html" title="Registry">Registry</a>
e.g. your <a shape="rect" href="spring.html" title="Spring">Spring</a> XML file:</p>
+<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
+<pre class="code-java">
+from(<span class="code-quote">"file:<span class="code-comment">//inbox"</span>)
+</span>  .unmarshal(<span class="code-quote">"myBindyDataFormat"</span>)
+  .to(<span class="code-quote">"direct:handleOrders"</span>);
+</pre>
+</div></div>
 
-    Iterator&lt;Map&lt;<span class="code-object">String</span>, <span
class="code-object">Object</span>&gt;&gt; it = models.iterator();
+<p>The Camel route will pick-up files in the inbox directory, unmarshall CSV records
into a collection of model objects and send the collection<br clear="none">
+to the route referenced by 'handleOrders'.</p>
 
-    <span class="code-keyword">while</span>(it.hasNext()){
+<p>The collection returned is a <b>List of Map</b> objects. Each Map within
the list contains the model objects that were marshalled out of each line of the CSV. The
reason behind this is that <em>each line can correspond to more than one object</em>.
This can be confusing when you simply expect one object to be returned per line.</p>
 
-          model = it.next();
+<p>Each object can be retrieve using its class name.</p>
+<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
+<pre class="code-java">
+    List&lt;Map&lt;<span class="code-object">String</span>, <span
class="code-object">Object</span>&gt;&gt; unmarshaledModels = (List&lt;Map&lt;<span
class="code-object">String</span>, <span class="code-object">Object</span>&gt;&gt;)
exchange.getIn().getBody();
 
-	  <span class="code-keyword">for</span>(<span class="code-object">String</span>
key : model.keySet()) {
-	     <span class="code-object">Object</span> obj = model.get(key);
-	     LOG.info(<span class="code-quote">"Count : "</span> + count + <span
class="code-quote">", "</span> + obj.toString());
+    <span class="code-object">int</span> modelCount = 0;
+    <span class="code-keyword">for</span> (Map&lt;<span class="code-object">String</span>,
<span class="code-object">Object</span>&gt; model : unmarshaledModels) {
+	  <span class="code-keyword">for</span> (<span class="code-object">String</span>
className : model.keySet()) {
+	     <span class="code-object">Object</span> obj = model.get(className);
+	     LOG.info(<span class="code-quote">"Count : "</span> + modelCount + <span
class="code-quote">", "</span> + obj.toString());
 	  }
-
-	 count++;
+	 modelCount++;
     }
 
-    LOG.info(<span class="code-quote">"Nber of CSV records received by the csv bean
: "</span> + count);
+    LOG.info(<span class="code-quote">"Total CSV records received by the csv bean :
"</span> + modelCount);
 </pre>
 </div></div>
-<p>To generate CSV records from a collection of model objects, you create the following
route :</p>
+
+<p>Assuming that you want to extract a single Order object from this map for processing
in a route, you could use a combination of a <a shape="rect" href="splitter.html" title="Splitter">Splitter</a>
and a <a shape="rect" href="processor.html" title="Processor">Processor</a> as
per the following:</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
 <pre class="code-java">
-from(<span class="code-quote">"bean:handleOrder"</span>)
-   marshal(bindy)
-   to(<span class="code-quote">"file:<span class="code-comment">//outbox"</span>)</span>
+from(<span class="code-quote">"file:<span class="code-comment">//inbox"</span>)
+</span>    .unmarshal(bindy)
+    .split(body())
+        .process(<span class="code-keyword">new</span> Processor() {
+            <span class="code-keyword">public</span> void process(Exchange exchange)
<span class="code-keyword">throws</span> Exception {
+                Message in = exchange.getIn();
+                Map&lt;<span class="code-object">String</span>, <span
class="code-object">Object</span>&gt; modelMap = (Map&lt;<span class="code-object">String</span>,
<span class="code-object">Object</span>&gt;) in.getBody();
+                in.setBody(modelMap.get(Order.class.getCanonicalName()));
+            }
+        })
+        .to(<span class="code-quote">"direct:handleSingleOrder"</span>)
+    .end();
 </pre>
 </div></div>
-<p>You can if you prefer use a named reference to a data format which can then be defined
in your <a shape="rect" href="registry.html" title="Registry">Registry</a> such
as via your <a shape="rect" href="spring.html" title="Spring">Spring</a> XML file.
e.g.</p>
+
+<h4><a shape="rect" name="BookDataFormatAppendix-Marshaling"></a>Marshaling</h4>
+<p>To generate CSV records from a collection of model objects, you create the following
route :</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
 <pre class="code-java">
-from(<span class="code-quote">"file:<span class="code-comment">//inbox"</span>).
-</span>  unmarshal(<span class="code-quote">"myBindyDataFormat"</span>).
-  to(<span class="code-quote">"bean:handleOrder"</span>);
+from(<span class="code-quote">"direct:handleOrders"</span>)
+   .marshal(bindy)
+   .to(<span class="code-quote">"file:<span class="code-comment">//outbox"</span>)</span>
 </pre>
 </div></div>
 

Modified: websites/production/camel/content/book-in-one-page.html
==============================================================================
--- websites/production/camel/content/book-in-one-page.html (original)
+++ websites/production/camel/content/book-in-one-page.html Thu May  3 18:20:57 2012
@@ -12003,7 +12003,7 @@ to Java Bean using annotations. Using Bi
 
 <div class="table-wrap">
 <table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1"
class="confluenceTh"> Parameter name </th><th colspan="1" rowspan="1" class="confluenceTh">
type </th><th colspan="1" rowspan="1" class="confluenceTh"> Info </th></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd"> separator </td><td colspan="1" rowspan="1"
class="confluenceTd"> string </td><td colspan="1" rowspan="1" class="confluenceTd">
mandatory - can be ',' or ';' or 'anything'. This value is interpreted as a regular expression.
If you want to use a sign which has a special meaning in regular expressions, e.g. the '|'
sign, than you have to mask it, like ' <br clear="none" class="atl-forced-newline">
-|' </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">
skipFirstLine </td><td colspan="1" rowspan="1" class="confluenceTd"> boolean </td><td
colspan="1" rowspan="1" class="confluenceTd"> optional - default value = false - allow
to skip the first line of the CSV file </td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"> crlf </td><td colspan="1" rowspan="1" class="confluenceTd">
string </td><td colspan="1" rowspan="1" class="confluenceTd"> optional - default
value = WINDOWS - allow to define the carriage return character to use </td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd"> generateHeaderColumns </td><td colspan="1"
rowspan="1" class="confluenceTd"> boolean </td><td colspan="1" rowspan="1" class="confluenceTd">
optional - default value = false - uses to generate the header columns of the CSV generates
</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> isOrdered
</td><td colspan="1" rowspan="1" class="confluenceTd"> boolean <
 /td><td colspan="1" rowspan="1" class="confluenceTd"> optional - default value =
false - allow to change the order of the fields when CSV is generated </td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd"> quote </td><td colspan="1" rowspan="1"
class="confluenceTd"> String </td><td colspan="1" rowspan="1" class="confluenceTd">
<b>Camel 2.8.3/2.9:</b> option - allow to specify a quote character of the fields
when CSV is generated </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">&#160;</td><td
colspan="1" rowspan="1" class="confluenceTd">&#160;</td><td colspan="1" rowspan="1"
class="confluenceTd"> This annotation is associated to the root class of the model and
must be declared one time. </td></tr></tbody></table>
+|' </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">
skipFirstLine </td><td colspan="1" rowspan="1" class="confluenceTd"> boolean </td><td
colspan="1" rowspan="1" class="confluenceTd"> optional - default value = false - allow
to skip the first line of the CSV file </td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"> crlf </td><td colspan="1" rowspan="1" class="confluenceTd">
string </td><td colspan="1" rowspan="1" class="confluenceTd"> optional - possible
values = WINDOWS,UNIX,MAC; default value = WINDOWS - allow to define the carriage return character
to use </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">
generateHeaderColumns </td><td colspan="1" rowspan="1" class="confluenceTd"> boolean
</td><td colspan="1" rowspan="1" class="confluenceTd"> optional - default value
= false - uses to generate the header columns of the CSV generates </td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd"> isOrdered </td><td colspan="1" rowspan
 ="1" class="confluenceTd"> boolean </td><td colspan="1" rowspan="1" class="confluenceTd">
optional - default value = false - allow to change the order of the fields when CSV is generated
</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> quote
</td><td colspan="1" rowspan="1" class="confluenceTd"> String </td><td
colspan="1" rowspan="1" class="confluenceTd"> <b>Camel 2.8.3/2.9:</b> option
- allow to specify a quote character of the fields when CSV is generated </td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd">&#160;</td><td colspan="1" rowspan="1"
class="confluenceTd">&#160;</td><td colspan="1" rowspan="1" class="confluenceTd">
This annotation is associated to the root class of the model and must be declared one time.
</td></tr></tbody></table>
 </div>
 
 
@@ -12914,56 +12914,75 @@ package name to initialize the model obj
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
 <pre class="code-java">
 DataFormat bindy = <span class="code-keyword">new</span> CsvBindyDataFormat(<span
class="code-quote">"com.acme.model"</span>);
-
-from(<span class="code-quote">"file:<span class="code-comment">//inbox"</span>).
-</span>  unmarshal(bindy).
-  to(<span class="code-quote">"bean:handleOrder"</span>);
 </pre>
 </div></div>
-<p>The Camel route will pick-up files in the inbox directory, unmarshall CSV records
in a collection of model objects and send the collection<br clear="none">
-to the bean referenced by 'handleOrder'.</p>
 
-<p>The collection is a list of Map. Each Map of the list contains the objects of the
model. Each object can be retrieve using its class name.</p>
+<h4><a shape="rect" name="BookInOnePage-Unmarshaling"></a>Unmarshaling</h4>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
 <pre class="code-java">
-<span class="code-object">int</span> count = 0;
-
-    List&lt;Map&lt;<span class="code-object">String</span>, <span
class="code-object">Object</span>&gt;&gt; models = <span class="code-keyword">new</span>
ArrayList&lt;Map&lt;<span class="code-object">String</span>, <span
class="code-object">Object</span>&gt;&gt;();
-    Map&lt;<span class="code-object">String</span>, <span class="code-object">Object</span>&gt;
model = <span class="code-keyword">new</span> HashMap&lt;<span class="code-object">String</span>,
<span class="code-object">Object</span>&gt;();
+from(<span class="code-quote">"file:<span class="code-comment">//inbox"</span>)
+</span>  .unmarshal(bindy)
+  .to(<span class="code-quote">"direct:handleOrders"</span>);
+</pre>
+</div></div>
 
-    models = (List&lt;Map&lt;<span class="code-object">String</span>,
<span class="code-object">Object</span>&gt;&gt;) exchange.getIn().getBody();
+<p>Alternatively, you can use a named reference to a data format which can then be
defined in your <a shape="rect" href="registry.html" title="Registry">Registry</a>
e.g. your <a shape="rect" href="spring.html" title="Spring">Spring</a> XML file:</p>
+<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
+<pre class="code-java">
+from(<span class="code-quote">"file:<span class="code-comment">//inbox"</span>)
+</span>  .unmarshal(<span class="code-quote">"myBindyDataFormat"</span>)
+  .to(<span class="code-quote">"direct:handleOrders"</span>);
+</pre>
+</div></div>
 
-    Iterator&lt;Map&lt;<span class="code-object">String</span>, <span
class="code-object">Object</span>&gt;&gt; it = models.iterator();
+<p>The Camel route will pick-up files in the inbox directory, unmarshall CSV records
into a collection of model objects and send the collection<br clear="none">
+to the route referenced by 'handleOrders'.</p>
 
-    <span class="code-keyword">while</span>(it.hasNext()){
+<p>The collection returned is a <b>List of Map</b> objects. Each Map within
the list contains the model objects that were marshalled out of each line of the CSV. The
reason behind this is that <em>each line can correspond to more than one object</em>.
This can be confusing when you simply expect one object to be returned per line.</p>
 
-          model = it.next();
+<p>Each object can be retrieve using its class name.</p>
+<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
+<pre class="code-java">
+    List&lt;Map&lt;<span class="code-object">String</span>, <span
class="code-object">Object</span>&gt;&gt; unmarshaledModels = (List&lt;Map&lt;<span
class="code-object">String</span>, <span class="code-object">Object</span>&gt;&gt;)
exchange.getIn().getBody();
 
-	  <span class="code-keyword">for</span>(<span class="code-object">String</span>
key : model.keySet()) {
-	     <span class="code-object">Object</span> obj = model.get(key);
-	     LOG.info(<span class="code-quote">"Count : "</span> + count + <span
class="code-quote">", "</span> + obj.toString());
+    <span class="code-object">int</span> modelCount = 0;
+    <span class="code-keyword">for</span> (Map&lt;<span class="code-object">String</span>,
<span class="code-object">Object</span>&gt; model : unmarshaledModels) {
+	  <span class="code-keyword">for</span> (<span class="code-object">String</span>
className : model.keySet()) {
+	     <span class="code-object">Object</span> obj = model.get(className);
+	     LOG.info(<span class="code-quote">"Count : "</span> + modelCount + <span
class="code-quote">", "</span> + obj.toString());
 	  }
-
-	 count++;
+	 modelCount++;
     }
 
-    LOG.info(<span class="code-quote">"Nber of CSV records received by the csv bean
: "</span> + count);
+    LOG.info(<span class="code-quote">"Total CSV records received by the csv bean :
"</span> + modelCount);
 </pre>
 </div></div>
-<p>To generate CSV records from a collection of model objects, you create the following
route :</p>
+
+<p>Assuming that you want to extract a single Order object from this map for processing
in a route, you could use a combination of a <a shape="rect" href="splitter.html" title="Splitter">Splitter</a>
and a <a shape="rect" href="processor.html" title="Processor">Processor</a> as
per the following:</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
 <pre class="code-java">
-from(<span class="code-quote">"bean:handleOrder"</span>)
-   marshal(bindy)
-   to(<span class="code-quote">"file:<span class="code-comment">//outbox"</span>)</span>
+from(<span class="code-quote">"file:<span class="code-comment">//inbox"</span>)
+</span>    .unmarshal(bindy)
+    .split(body())
+        .process(<span class="code-keyword">new</span> Processor() {
+            <span class="code-keyword">public</span> void process(Exchange exchange)
<span class="code-keyword">throws</span> Exception {
+                Message in = exchange.getIn();
+                Map&lt;<span class="code-object">String</span>, <span
class="code-object">Object</span>&gt; modelMap = (Map&lt;<span class="code-object">String</span>,
<span class="code-object">Object</span>&gt;) in.getBody();
+                in.setBody(modelMap.get(Order.class.getCanonicalName()));
+            }
+        })
+        .to(<span class="code-quote">"direct:handleSingleOrder"</span>)
+    .end();
 </pre>
 </div></div>
-<p>You can if you prefer use a named reference to a data format which can then be defined
in your <a shape="rect" href="registry.html" title="Registry">Registry</a> such
as via your <a shape="rect" href="spring.html" title="Spring">Spring</a> XML file.
e.g.</p>
+
+<h4><a shape="rect" name="BookInOnePage-Marshaling"></a>Marshaling</h4>
+<p>To generate CSV records from a collection of model objects, you create the following
route :</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
 <pre class="code-java">
-from(<span class="code-quote">"file:<span class="code-comment">//inbox"</span>).
-</span>  unmarshal(<span class="code-quote">"myBindyDataFormat"</span>).
-  to(<span class="code-quote">"bean:handleOrder"</span>);
+from(<span class="code-quote">"direct:handleOrders"</span>)
+   .marshal(bindy)
+   .to(<span class="code-quote">"file:<span class="code-comment">//outbox"</span>)</span>
 </pre>
 </div></div>
 

Modified: websites/production/camel/content/cache/main.pageCache
==============================================================================
Binary files - no diff available.



Mime
View raw message