Versions Compared

Key

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

...

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

not contains

For testinf if not contains in a string based value

regex

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

not regex

For not 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.

not in

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

is

For matching if the left hand side type is an instanceof the value.

not is

For matching if the left hand side type is not an instanceof the value.

range

For matching if the left hand side is within a range of values defined as numbers: from..to

not range

For matching if the left hand side is not within a range of values defined as numbers: from..to

And the following operators can be used to group expressions:

Operator

Description

and

and is used to group two expressions

or

or is used to group two expressions

Notice: Currently and or or can only be used once in a simple language expression. This might change in the future.

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 null
simple("${in.header.baz} == null")

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

...

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>

Using and / or

If you have two expressions you can combine them with the and or or operator.
For instance:

Code Block

simple("${in.header.title} contains 'Camel' and ${in.header.type' == 'gold'")

And of course the or is also supported. The sample example would be:

Code Block

simple("${in.header.title} contains 'Camel' or ${in.header.type' == 'gold'")

Notice: Currently and or or can only be used once in a simple language expression. This might change in the future.
So you cannot do:

Code Block

simple("${in.header.title} contains 'Camel' and ${in.header.type' == 'gold' and ${in.header.number} range 100..200")

Samples

In the Spring XML sample below we filter based on a header value:

...