Return-Path: Delivered-To: apmail-commons-user-archive@www.apache.org Received: (qmail 3311 invoked from network); 29 Aug 2009 18:10:30 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 29 Aug 2009 18:10:30 -0000 Received: (qmail 18589 invoked by uid 500); 29 Aug 2009 18:10:29 -0000 Delivered-To: apmail-commons-user-archive@commons.apache.org Received: (qmail 18489 invoked by uid 500); 29 Aug 2009 18:10:29 -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 18479 invoked by uid 99); 29 Aug 2009 18:10:29 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 29 Aug 2009 18:10:29 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of ralph.goers@dslextreme.com designates 209.85.212.198 as permitted sender) Received: from [209.85.212.198] (HELO mail-vw0-f198.google.com) (209.85.212.198) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 29 Aug 2009 18:10:19 +0000 Received: by vws36 with SMTP id 36so2031924vws.10 for ; Sat, 29 Aug 2009 11:09:58 -0700 (PDT) Received: by 10.220.89.2 with SMTP id c2mr3234696vcm.16.1251569398430; Sat, 29 Aug 2009 11:09:58 -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 20sm1354944yxe.6.2009.08.29.11.09.57 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 29 Aug 2009 11:09:58 -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: Date: Sat, 29 Aug 2009 11:09:55 -0700 Content-Transfer-Encoding: 7bit Message-Id: References: <4A8A5F40.7020203@gmx.de> <4A992E18.9050209@gmx.de> To: Commons Users List X-Mailer: Apple Mail (2.1075.2) X-Virus-Checked: Checked by ClamAV on apache.org 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