On Sun, Jun 3, 2012 at 4:30 AM, barry_allen <coldgint...@gmail.com> wrote:
> Ok, just saw these:
>
> http://grokbase.com/t/camel/users/1197q01xk7/unmarshal-csvdataformat-different-behavior-for-one-or-multiples-lines
>
> https://issues.apache.org/jira/browse/CAMEL-4440
>
> Fixed in 2.9.0... Unfortunately I can't upgrade right now. Is there any way
> that I would be able to evaluate the result of the unmarshal().csv() to see
> how many rows there are? I would like to do something like:
>
> unmarshal().csv()
> .choice(when csv_rowCount == 1)    // Need to know how to do this kind of
> evaluation in 2.8.3?
> .split(body().tokenize())
> // will give me a string with the single row data, and I'll parse it here,
> no prob
> .otherwise
> .split(body())       // Will give me the list type, which is fine
>

You can create a predicate that checks the size of the body, and
matches if its 1.

Camel offers a number of languages that can do this, such as simple
http://camel.apache.org/simple

.choice()
  .when(simple("${body.size} == 1"))

Alternative languages could be ognl, mvel, groovy etc
http://camel.apache.org/languages.html

Or write your own java method that checks this and use a method call expression

public boolean oneLine(List body) {
  return body.size() == 1;
}


> Thanks
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Bug-in-Splitter-Implementation-Camel-2-8-3-tp5713873p5713874.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
FuseSource
Email: cib...@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Reply via email to