JWare Logo  “Strategies in (*)ability” [iDareMedia] [JWare] [PET] [CI-Dashboard]
<JWare/AntXtras Foundation>

 [home]    [overview] [download] [learning] [problems] [ourplans]    [contacts] [legalese

[guide] condition URIsUG

home » learning » guides » valueuris » condition 

The condition value uris let you perform simple boolean tests without having to create independent <condition> or <criteria> objects. This is a small set of uris where the test is defined by the uri’s scheme name which must match one of the AntX builtin conditions. These short hand conditions are most useful as tests for optionally executed tasksets like <do> and <domatch>. You must explicitly install this uri’s handler; read the Examples section to see how this is done.

Parameters

The general form of the URI is: $condition:sourcevalue[?options] where condition is one of the predefined short hand conditions like “isdirectory” and sourcevalue is the value against which the condition is applied. Exactly what options are available depends on the short hand condition being used; see each condition’s javadocs for details. Below is a partial listing of the predefined condition schemes with examples; please see the valueuris.xml file for a complete listing and each handler’s javadocs for options.

Scheme Example Usage
$isdefined:<do true="${$isdefined:@{classpath}}">
$istype:<do false="${$istype:checkstyle}">
$noneset:<emma enabled="${$noneset:disable.emma,disable.metrics}"…>
$anyset:<property value="${$anyset:get-jars.errs,get-config.errs}"…/>
$notwhitespace:<domatch value="${$notwhitespace:@{prefix}}">
$filenotempty:<do true="${$filenotempty:@(filtersfile)}">
$iszero:<domatch value="${$list:@{filters}?size|$iszero:">
$not:<javac debug="@{debug}" optimize="${$not:@{debug}}"…>
$issettrue:<arg line="--failquick ${$issettrue:DEBUGMODE}"/>

Examples

1) The following snippet declares the default scheme names for the short hand condition uri handlers. The snippet has been abbreviated for space considerations. This is usually done by an “init” target or at the project’s top level.

    <manageuris action="install">
        <parameter name="isset"
            value="com.idaremedia.antx.condition.ShortHandValueURIHandler"/>
        <parameter name="allset"
            value="com.idaremedia.antx.condition.ShortHandValueURIHandler"/>
        ...
        <parameter name="zero"
            value="com.idaremedia.antx.valueuri.condition.ZeroCheckValueURIHandler"/>
    </manageuris>

2) The following macrodef snippet uses two short hand condition uris to determine if a failproperty should be set or not.

    <do true="${$isdefined:@{failproperty}}">
      <do false="${$var:_errorcount|$iszero:}">
        <copyproperty name="@{failproperty}" var="_errorcount"/>
      </do>
    </do>

Related Topics

SourceForge.net Logo
Copyright ©2005-2006 iDare Media, Inc. All rights reserved.
 
JWare/AntXtras uses software developed by and on behalf of the Apache Software Foundation, http://www.apache.org/.
All other product names mentioned on this website are trademarks of their respective owners; refer to full legalese statement.