Return-Path: Delivered-To: apmail-commons-user-archive@www.apache.org Received: (qmail 24031 invoked from network); 29 Aug 2009 20:10:54 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 29 Aug 2009 20:10:54 -0000 Received: (qmail 76218 invoked by uid 500); 29 Aug 2009 20:10:53 -0000 Delivered-To: apmail-commons-user-archive@commons.apache.org Received: (qmail 76107 invoked by uid 500); 29 Aug 2009 20:10:52 -0000 Mailing-List: contact user-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Users List" Delivered-To: mailing list user@commons.apache.org Received: (qmail 76097 invoked by uid 99); 29 Aug 2009 20:10:52 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 29 Aug 2009 20:10:52 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of ralph.goers@dslextreme.com designates 209.85.132.244 as permitted sender) Received: from [209.85.132.244] (HELO an-out-0708.google.com) (209.85.132.244) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 29 Aug 2009 20:10:42 +0000 Received: by an-out-0708.google.com with SMTP id c2so1445399anc.15 for ; Sat, 29 Aug 2009 13:10:20 -0700 (PDT) Received: by 10.101.65.19 with SMTP id s19mr3219796ank.3.1251576620222; Sat, 29 Aug 2009 13:10:20 -0700 (PDT) Received: from ?192.168.10.130? (adsl-66-51-196-164.dslextreme.com [66.51.196.164]) by mx.google.com with ESMTPS id 20sm47048yxe.2.2009.08.29.13.10.18 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 29 Aug 2009 13:10:19 -0700 (PDT) Content-Type: text/plain; charset=us-ascii; format=flowed; delsp=yes Mime-Version: 1.0 (Apple Message framework v1075.2) Subject: Re: [Configuration]JEXL question From: Ralph Goers In-Reply-To: <4A997354.2090704@gmx.de> Date: Sat, 29 Aug 2009 13:10:17 -0700 Content-Transfer-Encoding: 7bit Message-Id: <78CB4600-96ED-46FB-9492-0D63895CC633@dslextreme.com> References: <4A8A5F40.7020203@gmx.de> <4A992E18.9050209@gmx.de> <4A997354.2090704@gmx.de> To: "Commons Users List" X-Mailer: Apple Mail (2.1075.2) X-Virus-Checked: Checked by ClamAV on apache.org Sure, by all means. Ralph On Aug 29, 2009, at 11:28 AM, rzo wrote: > Ralph, > > thanks for the fast reply. > In the mean time i decided to try it with groovy. > I have written a groovy expression interpolation which I will be > using in my project. > If you are interested in this i could put the files on jira. > > - Ron > > > Ralph Goers wrote: >> >> 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 >> >> conf.getSubstitutor().setVariablePrefix('`'); >> conf.getSubstitutor().setVariablesuffix('`'); >> >> and then use test="$`expr:if (System.getProperty >> ("user.home").startsWith("C")) {"x";} else {"z";}` >> >> It also supports using strings so you could do: >> >> conf.getSubstitutor.setVariableSuffix("$}"; >> >> 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. >> >> Ralph >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org >> For additional commands, e-mail: user-help@commons.apache.org >> >> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@commons.apache.org > For additional commands, e-mail: user-help@commons.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@commons.apache.org For additional commands, e-mail: user-help@commons.apache.org