camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Block <andy.bl...@gmail.com>
Subject Re: Can simple() be made to compare strings in a case insensitive way?
Date Mon, 01 Jun 2015 14:14:40 GMT
Slavisa,

Since the value you are comparing against is a String, you can call the toLowerCase method
to convert test to lowercase and compare against that.

In your example, it would be:

.when().simple(“${property.Service?.toLowerCase()} == ‘myservice’)

The ? is added to ensure the value is not null before performing actions on the object. 

- Andy

-- 
Andrew Block


On June 1, 2015 at 5:34:53 AM, s.marjanovic (slavisa.marjanovic.83@gmail.com) wrote:

Hello,  

Is there a way to make simple() perform string comparison in a case  
insensitive way ?  

The use case is described below:  

.setProperty("Service", ns.xpath("/MyMessage/Service", String.class))  
.choice()  
.when().simple("${property.Service} == 'myService'")  

If the value of /MyMessage/Service is "myService", simple() will evaluate to  
true, but if /MyMessage/Service is "myservice" it will evaluate to false.  

I can think of a number of hacks for this but I'd like to hear what is the  
camel recommended way to deal with a situation like this.  

Thanks,  
Slavisa  



--  
View this message in context: http://camel.465427.n5.nabble.com/Can-simple-be-made-to-compare-strings-in-a-case-insensitive-way-tp5767732.html
 
Sent from the Camel - Users mailing list archive at Nabble.com.  

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message