...
Sort will by default sort the body using a default comparator that handles numeric values or uses the string representation. You can provide your own comparator, and even an expression to return the value to be sorted. Sort requires the value returned from the expression evaluation is convertible to java.util.List
as this is required by the JDK sort operation.
Options
Div |
---|
class | confluenceTableSmall |
---|
|
Wiki Markup |
---|
{div:class=confluenceTableSmall}
|| Name || Default Value || Description ||
| {{comparatorRef}} | | Refers to a custom {{ Name | Default Value | Description |
---|
comparatorRef | | Refers to a custom |
}} |
{div} |
Using from Java DSL
In the route below it will read the file content and tokenize by line breaks so each line can be sorted.
...
In the route below it will read the file content and tokenize by line breaks so each line can be sorted.
Code Block |
---|
| xml |
---|
| xml |
---|
title | Camel 2.7 or betterxml |
---|
|
<route>
<from uri="file://inbox"/>
<sort>
<simple>body</simple>
</sort>
<beanRef ref="myServiceBean" method="processLine"/>
</route>
|
Code Block |
---|
| xml |
---|
| xml |
---|
title | Camel 2.6 or olderxml |
---|
|
<route>
<from uri="file://inbox"/>
<sort>
<expression>
<simple>body</simple>
</expression>
</sort>
<beanRef ref="myServiceBean" method="processLine"/>
</route>
|
And to use our own comparator we can refer to it as a spring bean:
Code Block |
---|
| xml |
---|
| xml |
---|
title | Camel 2.7 or betterxml |
---|
|
<route>
<from uri="file://inbox"/>
<sort comparatorRef="myReverseComparator">
<simple>body</simple>
</sort>
<beanRef ref="MyServiceBean" method="processLine"/>
</route>
<bean id="myReverseComparator" class="com.mycompany.MyReverseComparator"/>
|
Code Block |
---|
| xml |
---|
| xml |
---|
title | Camel 2.6 or olderxml |
---|
|
<route>
<from uri="file://inbox"/>
<sort comparatorRef="myReverseComparator">
<expression>
<simple>body</simple>
</expression>
</sort>
<beanRef ref="MyServiceBean" method="processLine"/>
</route>
<bean id="myReverseComparator" class="com.mycompany.MyReverseComparator"/>
|
...