...
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: |
not range | For matching if the left hand side is not within a range of values defined as numbers: |
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 | |||||||
---|---|---|---|---|---|---|---|
| |||||||
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
|
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:
...