Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The following operators is supported:

Operator

Description

==

equals

>

greather than

>=

greather than or equals

<

less than

<=

...

less than or equals

!=

not equals

contains

For testing if contains in a string based value

regex

For matching against a given regular expression pattern defined as a String value

in

For matching if in a set of values, each element must be separated by comma.

...

Some examples:

Code Block
simple("${in.header.foo} == 'foo'")

// ' ' can be omitted
simple("${in.header.foo} == foo")

// here Camel will type convert '100' into the type of in.header.bar and if its an Integer '100' will also be converter to an Integer
simple("${in.header.bar} == '100'")

simple("${in.header.bar} == 100")

// 100 will be converter to the type of in.header.bar so we can do > comparison
simple("${in.header.bar} > 100")

// testing for not null
simple("${in.header.baz} != null")

...

Code Block
simple("${in.header.date} == ${date:now:yyyyMMdd}")

simple("${in.header.type} == ${bean:orderService?method=getOrderType}")

And an example with contains, testing if the title contains the word Camel

Code Block

simple(${in.header.title} contains 'Camel'")

And an example with regex, testing if the number header is a 4 digit value:

Code Block

simple(${in.header.number} regex '\d{4}'")

And finally an example if the header equals any of the values in the list. Each element must be separated by comma, and no space around.
This also works for numbers etc, as Camel will convert each element into the type of the left hand side.

Code Block

simple(${in.header.type} in 'gold,silver'")
Tip
titleCan be used in Spring XML

As the Spring XML does not have all the power as the Java DSL with all its various builder methods, you had to resort to use some other languages
for testing with simple operators. Now you can do this with the simple language. In the sample below we want to test if the header is a widget order:

Code Block
xml
xml
    <from uri="seda:orders">
       <filter>
           <simple>${in.header.type} == 'widget'</simple>
           <to uri="bean:orderService?method=handleWidget"/>
       </filter>
    </from>

...