commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ralph Goers <>
Subject Re: [Configuration]JEXL question
Date Sat, 29 Aug 2009 18:09:55 GMT

On Aug 29, 2009, at 10:35 AM, Ralph Goers wrote:

> On Aug 29, 2009, at 6:33 AM, rzo wrote:
>> Hello,
>> thanks for mentioning jexl scripting.
>> I tried it out and have found the following issue:
>> evaluating the following:
>> test=${expr:if (System.getProperty("user.home").startsWith("C"))  
>> {"x";} else {"z";}}
>> does not seem to work.
>> Debuging shows that the expression forwarded to jexl is:
>> if (System.getProperty("user.home").startsWith("C")) {"x";
>> is this a bug ? or is there a way to escape the brackets within $ 
>> {...} ?
> The "bug" is actually the way  
> org.apache.commons.lang.text.StrSubstitutor works. It can configured  
> be with prefix and suffix characters - the defaults are '{' and '}'  
> and after finding the prefix it just searches for the first  
> occurance of the suffix character - unless it finds a recursive  
> variable. So the string passed to ConfigurationInterpolator is what  
> you show above.
> However, it might be possible to override the suffix matcher to look  
> for an escape character.

It occurs to me though that just using a different suffix matcher will  
not remove the escape character.

One other thought. StrSubstitutor allows the prefix and suffix  
characters to be replaced, so you should be able to do


and then use test="$`expr:if (System.getProperty 
("user.home").startsWith("C")) {"x";} else {"z";}`

It also supports using strings so you could do:


and then test="${expr:if (System.getProperty("user.home").startsWith 
("C")) {"x";} else {"z";}$}

Of course, then you would have to use those prefix and suffix  
characters throughout that configuration.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message