Author: peterreilly Date: Mon Sep 25 14:39:08 2006 New Revision: 449826 URL: http://svn.apache.org/viewvc?view=rev&rev=449826 Log: add doc for <matches>
Modified: ant/core/trunk/docs/manual/CoreTasks/conditions.html Modified: ant/core/trunk/docs/manual/CoreTasks/conditions.html URL: http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/CoreTasks/conditions.html?view=diff&rev=449826&r1=449825&r2=449826 ============================================================================== --- ant/core/trunk/docs/manual/CoreTasks/conditions.html (original) +++ ant/core/trunk/docs/manual/CoreTasks/conditions.html Mon Sep 25 14:39:08 2006 @@ -311,10 +311,10 @@ <td valign="top" align="center">Yes</td> </tr> </table> -<pre> - <istrue value="${someproperty}"/> - <istrue value="false"/> -</pre> +<blockquote><pre> +<istrue value="${someproperty}"/> +<istrue value="false"/> +</pre></blockquote> <h4>isfalse</h4> <p>Tests whether a string is not true, the negation of <istrue> @@ -331,10 +331,10 @@ <td valign="top" align="center">Yes</td> </tr> </table> -<pre> - <isfalse value="${someproperty}"/> - <isfalse value="false"/> -</pre> +<blockquote><pre> +<isfalse value="${someproperty}"/> +<isfalse value="false"/> +</pre></blockquote> <h4>isreference</h4> @@ -424,12 +424,11 @@ <p> Example usage: </p> - <blockquote> - <pre> - <isfileselected file="a.xml"> - <date datetime="06/28/2000 2:02 pm" when="equal"/> - </isfileselected> - </pre></blockquote> +<blockquote><pre> +<isfileselected file="a.xml"> + <date datetime="06/28/2000 2:02 pm" when="equal"/> +</isfileselected> +</pre></blockquote> <h4>typefound</h4> <p>Test whether a given type is defined, and that @@ -461,11 +460,10 @@ <p> Example usages: </p> - <blockquote> - <pre> - <typefound name="junit"/> - <typefound uri="antlib:org.apache.maven.artifact.ant" name="artifact"/> - </pre></blockquote> +<blockquote><pre> +<typefound name="junit"/> +<typefound uri="antlib:org.apache.maven.artifact.ant" name="artifact"/> +</pre></blockquote> <h4>scriptcondition</h4> @@ -510,12 +508,12 @@ <p> Example: </p> -<pre> - <scriptcondition language="javascript" - value="true"> - self.setValue(false); - </scriptcondition> -</pre> +<blockquote><pre> +<scriptcondition language="javascript" + value="true"> + self.setValue(false); +</scriptcondition> +</pre></blockquote> Sets the default value of the condition to true, then in the script, sets the value to false. This condition always evaluates to "false" @@ -551,27 +549,26 @@ </tr> </table> -<pre> +<blockquote><pre> <parsersupports feature="http://xml.org/sax/features/namespaces"/> -</pre> +</pre></blockquote> Check for namespace support. All SAX2 parsers should have this. -<pre> +<blockquote><pre> <or> <parsersupports feature="http://apache.org/xml/features/validation/schema"/> <parsersupports feature="http://java.sun.com/xml/jaxp/properties/schemaSource"/> </or> -</pre> +</pre></blockquote> Check for XML Schema support. -<pre> - +<blockquote><pre> <parsersupports property="http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation" value="document.xsd"/> -</pre> +</pre></blockquote> Check for Xerces-specific definition of the location of the no namespace schema. @@ -628,21 +625,21 @@ </tr> </table> -<pre> +<blockquote><pre> <condition property="offline"> <isreachable url="http://ibiblio.org/maven/" /> </condition> -</pre> +</pre></blockquote> <p> Probe for the maven repository being reachable. </p> -<pre> +<blockquote><pre> <condition property="offline"> <isreachable host="ibiblio.org" timeout="10" /> </condition> -</pre> +</pre></blockquote> <p> Probe for the maven repository being reachable using the hostname, ten second timeout.. @@ -654,14 +651,14 @@ <b>Since Ant 1.6.3</b> </p> -<pre> -<length string=" foo " trim="true" length="3" /> -</pre> +<blockquote><pre> +<length string=" foo " trim="true" length="3" /> +</pre></blockquote> <p>Verify a string is of a certain length.</p> -<pre> +<blockquote><pre> <length file="foo" when="greater" length="0" /> -</pre> +</pre></blockquote> <p>Verify that file <i>foo</i> is not empty.</p> <h4>isfailure</h4> @@ -690,9 +687,9 @@ <b>Since Ant 1.7</b> </p> -<pre> +<blockquote><pre> <resourcecount refid="myresourcecollection" when="greater" length="0" /> -</pre> +</pre></blockquote> <p>Verify that a resource collection is not empty.</p> <h4>resourcesmatch</h4> @@ -773,14 +770,116 @@ There is also a nested <classpath> element, which can be used to specify a classpath. </p> -<pre> - <hasmethod classname="java.util.ArrayList" method="trimToSize" /> -</pre> +<blockquote><pre> +<hasmethod classname="java.util.ArrayList" method="trimToSize" /> +</pre></blockquote> <p>Looks for the method trimToSize in the ArrayList class.</p> +<h4>matches</h4> + +<p> + Test if the specified string matches the specified regular + expression pattern. + <b>Since Ant 1.7</b></p> +<table border="1" cellpadding="2" cellspacing="0"> + <tr> + <td valign="top"><b>Attribute</b></td> + <td valign="top"><b>Description</b></td> + <td align="center" valign="top"><b>Required</b></td> + </tr> + <tr> + <td valign="top">string</td> + <td valign="top">The string to test.</td> + <td valign="top" align="center">Yes</td> + </tr> + <tr> + <td valign="top">match</td> + <td valign="top">The regular expression pattern used to test.</td> + <td valign="top" align="center">Yes, unless there is a nested + <code><regexp></code> element.</td> + </tr> + <tr> + <td valign="top">casesensitive</td> + <td valign="top">Perform a case sensitive match. Default is + true.</td> + <td valign="top" align="center">No</td> + </tr> + <tr> + <td valign="top">multiline</td> + <td valign="top"> + Perform a multi line match. + Default is false.</td> + <td valign="top" align="center">No</td> + </tr> + <tr> + <td valign="top">singleline</td> + <td valign="top"> + This allows '.' to match new lines. + SingleLine is not to be confused with multiline, SingleLine is a perl + regex term, it corresponds to dotall in java regex. + Default is false.</td> + <td valign="top" align="center">No</td> + </tr> +</table> + <p> + There is also an optional <regexp> element, which can be used to specify + a regular expression instead of the "pattern" attribute. + See <a href="../CoreTypes/regexp.html">Regexp Type</a> for the description + of the nested element regexp and of + the choice of regular expression implementation. + </p> + <p> + An example: + </p> +<blockquote><pre> +<condition propery="legal-password"> + <matches pattern="[1-9]" string="${user-input}"/> +</condition> +<fail message="Your password should at least contain one number" + unless="legal-password"/> +</pre></blockquote> + <p> + The following example sets the property "ok" if + the property "input" is three characters long, starting + with 'a' and ending with 'b'. + </p> +<blockquote><pre> +<condition property="ok"> + <matches string="${input}" pattern="^a.b$"/> +</condition> +</pre></blockquote> + <p> + The following defines a reference regular expression for + matching dates and then uses antunit to check if the + property "today" is in the correct format: + </p> +<blockquote><pre> +<regexp id="date.pattern" pattern="^[0123]\d-[01]\d-[12]\d\d\d$"/> +<au:assertTrue xmlns:au="antlib:org.apache.ant.antunit"> + <matches string="${today}"> + <regexp refid="date.pattern"/> + </matches> +</au:assertTrue> +</pre></blockquote> + <p> + The following example shows the use of the singleline and the casesensitive + flags. + </p> +<blockquote><pre> +<au:assertTrue> + <matches string="AB${line.separator}C" pattern="^ab.*C$" + casesensitive="false" + singleline="true"/> +</au:assertTrue> +<au:assertFalse> + <matches string="AB${line.separator}C" pattern="^ab.*C$" + casesensitive="false" + singleline="false"/> +</au:assertFalse> +</pre></blockquote> </body> </html> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]