Return-Path: Delivered-To: apmail-ant-notifications-archive@minotaur.apache.org Received: (qmail 99459 invoked from network); 10 Feb 2010 14:21:02 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 10 Feb 2010 14:21:01 -0000 Received: (qmail 4634 invoked by uid 500); 10 Feb 2010 14:21:01 -0000 Delivered-To: apmail-ant-notifications-archive@ant.apache.org Received: (qmail 4593 invoked by uid 500); 10 Feb 2010 14:21:01 -0000 Mailing-List: contact notifications-help@ant.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ant.apache.org Delivered-To: mailing list notifications@ant.apache.org Received: (qmail 4540 invoked by uid 99); 10 Feb 2010 14:21:01 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 10 Feb 2010 14:21:01 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 10 Feb 2010 14:21:00 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 67BF2238897F; Wed, 10 Feb 2010 14:20:40 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r908513 - in /ant/antlibs/props/trunk: docs/index.html src/main/org/apache/ant/props/ConditionEvaluator.java src/tests/antunit/condition-test.xml Date: Wed, 10 Feb 2010 14:20:40 -0000 To: notifications@ant.apache.org From: bodewig@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100210142040.67BF2238897F@eris.apache.org> Author: bodewig Date: Wed Feb 10 14:20:39 2010 New Revision: 908513 URL: http://svn.apache.org/viewvc?rev=908513&view=rev Log: minimal docs, a bit more tests, tiny optimization and better whitespace handling for the conditions evaluator Modified: ant/antlibs/props/trunk/docs/index.html ant/antlibs/props/trunk/src/main/org/apache/ant/props/ConditionEvaluator.java ant/antlibs/props/trunk/src/tests/antunit/condition-test.xml Modified: ant/antlibs/props/trunk/docs/index.html URL: http://svn.apache.org/viewvc/ant/antlibs/props/trunk/docs/index.html?rev=908513&r1=908512&r2=908513&view=diff ============================================================================== --- ant/antlibs/props/trunk/docs/index.html (original) +++ ant/antlibs/props/trunk/docs/index.html Wed Feb 10 14:20:39 2010 @@ -128,6 +128,18 @@ then (arg). + + types + PropertyEvaluator + Given condition([arg1=value1,arg2=value2,...]), + attempts to invoke an Ant condition of the given name + setting the given attibute values and evaluates to either + Boolean.TRUE or Boolean.FALSE. Usage looks + like ${os(family=unix)}. This is probably most + useful together with the if/unless attributes of tasks or + targets. + + encodeURL PropertyEvaluator Modified: ant/antlibs/props/trunk/src/main/org/apache/ant/props/ConditionEvaluator.java URL: http://svn.apache.org/viewvc/ant/antlibs/props/trunk/src/main/org/apache/ant/props/ConditionEvaluator.java?rev=908513&r1=908512&r2=908513&view=diff ============================================================================== --- ant/antlibs/props/trunk/src/main/org/apache/ant/props/ConditionEvaluator.java (original) +++ ant/antlibs/props/trunk/src/main/org/apache/ant/props/ConditionEvaluator.java Wed Feb 10 14:20:39 2010 @@ -16,6 +16,7 @@ */ package org.apache.ant.props; +import java.util.regex.Pattern; import org.apache.tools.ant.ComponentHelper; import org.apache.tools.ant.IntrospectionHelper; import org.apache.tools.ant.Project; @@ -31,6 +32,9 @@ * for example os(family=unix). */ public class ConditionEvaluator extends RegexBasedEvaluator { + private static final Pattern COMMA = Pattern.compile(","); + private static final Pattern EQ = Pattern.compile("="); + public ConditionEvaluator() { super("^(.+?)\\(((?:(?:.+?)=(?:.+?))?(?:,(?:.+?)=(?:.+?))*?)\\)$"); } @@ -44,10 +48,11 @@ if (groups[2].length() > 0) { IntrospectionHelper ih = IntrospectionHelper.getHelper(instance.getClass()); - String[] attributes = groups[2].split(","); + String[] attributes = COMMA.split(groups[2]); for (int i = 0; i < attributes.length; i++) { - String[] keyValue = attributes[i].split("="); - ih.setAttribute(p, instance, keyValue[0], keyValue[1]); + String[] keyValue = EQ.split(attributes[i]); + ih.setAttribute(p, instance, keyValue[0].trim(), + keyValue[1].trim()); } } return Boolean.valueOf(cond.eval()); Modified: ant/antlibs/props/trunk/src/tests/antunit/condition-test.xml URL: http://svn.apache.org/viewvc/ant/antlibs/props/trunk/src/tests/antunit/condition-test.xml?rev=908513&r1=908512&r2=908513&view=diff ============================================================================== --- ant/antlibs/props/trunk/src/tests/antunit/condition-test.xml (original) +++ ant/antlibs/props/trunk/src/tests/antunit/condition-test.xml Wed Feb 10 14:20:39 2010 @@ -24,10 +24,41 @@ - - - + + + + + true + + + + org.apache.ant.props.ConditionEvaluator must be there + + + + + + + + + + + + equal + + + + not equal + + + + + +