source: release-kits/wirk3/ant-scripts/tasks/antelope/docs/manual/bk03ch05s02.html@ 15023

Last change on this file since 15023 was 15023, checked in by oranfry, 16 years ago

did the bulk of the work on wirk3

File size: 11.3 KB
Line 
1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>More Conditions</title><meta name="generator" content="DocBook XSL Stylesheets V1.68.1"><link rel="start" href="index.html" title="Antelope Users Guide"><link rel="up" href="bk03ch05.html" title="Chapter 5. If Task"><link rel="prev" href="bk03ch05.html" title="Chapter 5. If Task"><link rel="next" href="bk03ch06.html" title="Chapter 6. SwitchTask"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">More Conditions</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="bk03ch05.html">Prev</a> </td><th width="60%" align="center">Chapter 5. If Task</th><td width="20%" align="right"> <a accesskey="n" href="bk03ch06.html">Next</a></td></tr></table><hr></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="conditionals"></a>More Conditions</h2></div></div></div><p>
2These conditions are suitable for use in the &lt;bool&gt; element. Unfortunately, they cannot be used in the &lt;condition&gt; task, although all conditions for the &lt;condition&gt; task can be used with the bool and the bool can be used anywhere that &lt;condition&gt; can be used.
3</p><h3><a name="id2519728"></a>IfPropertyTrue</h3><p>
4Given a property name, tests whether the value for that property equals "true" (or "yes" or "on").
5</p><p>
6</p><div class="table"><a name="id2519740"></a><p class="title"><b>Table 5.2. IfPropertyTrue Attributes</b></p><table summary="IfPropertyTrue Attributes" border="1"><colgroup><col><col><col></colgroup><thead><tr><th>Attribute</th><th>Description</th><th>Required</th></tr></thead><tbody><tr><td>property</td><td>The name of a property to test the value of.</td><td>Yes</td></tr></tbody></table></div><p>
7</p><p>
8</p><pre class="programlisting">
9
10&lt;ispropertytrue property="myprop"/&gt;
11&lt;ispropertytrue property="${someprop}"/&gt;
12
13</pre><p>
14</p><h3><a name="id2519801"></a>IfPropertyFalse</h3><p>
15Given a property name, tests whether the value for that property equals "false" (or "no" or "off").
16</p><p>
17</p><div class="table"><a name="id2519813"></a><p class="title"><b>Table 5.3. IfPropertyFalse Attributes</b></p><table summary="IfPropertyFalse Attributes" border="1"><colgroup><col><col><col></colgroup><thead><tr><th>Attribute</th><th>Description</th><th>Required</th></tr></thead><tbody><tr><td>property</td><td>The name of a property to test the value of.</td><td>Yes</td></tr></tbody></table></div><p>
18</p><p>
19</p><pre class="programlisting">
20
21&lt;ispropertyfalse property="myprop"/&gt;
22&lt;ispropertyfalse property="${someprop}"/&gt;
23
24</pre><p>
25</p><h3><a name="id2519875"></a>StartsWith</h3><p>
26Given a property name, tests whether the value for that property starts with a specified string.
27</p><p>
28</p><div class="table"><a name="id2519887"></a><p class="title"><b>Table 5.4. StartsWith Attributes</b></p><table summary="StartsWith Attributes" border="1"><colgroup><col><col><col></colgroup><thead><tr><th>Attribute</th><th>Description</th><th>Required</th></tr></thead><tbody><tr><td>string</td><td>The string to test.</td><td>Yes</td></tr><tr><td>with</td><td>Check if 'string' starts with this value.</td><td>Yes</td></tr></tbody></table></div><p>
29</p><p>
30</p><pre class="programlisting">
31
32&lt;startswith string="abcdefg" with="abc"/&gt;
33&lt;startswith string="${myprop}" with="foo"/&gt;
34
35</pre><p>
36</p><h3><a name="id2519962"></a>EndsWith</h3><p>
37Given a property name, tests whether the value for that ends with with a specified string.
38</p><p>
39</p><div class="table"><a name="id2519974"></a><p class="title"><b>Table 5.5. EndsWith Attributes</b></p><table summary="EndsWith Attributes" border="1"><colgroup><col><col><col></colgroup><thead><tr><th>Attribute</th><th>Description</th><th>Required</th></tr></thead><tbody><tr><td>string</td><td>The string to test.</td><td>Yes</td></tr><tr><td>with</td><td>Check if 'string' ends with this value.</td><td>Yes</td></tr></tbody></table></div><p>
40</p><p>
41</p><pre class="programlisting">
42
43&lt;endswith string="abcdefg" with="efg"/&gt;
44&lt;endswith string="${myprop}" with="bar"/&gt;
45
46</pre><p>
47</p><h3><a name="id2520049"></a>IsGreaterThan</h3><p>
48Tests whether the first argument is greater than the second argument. Will
49automatically treat the arguments as numbers if both arguments consists of only the characters 0 through 9 and optionally a decimal point. Otherwise, a String
50comparison is used.
51</p><p>
52</p><div class="table"><a name="id2520064"></a><p class="title"><b>Table 5.6. IsGreaterThan Attributes</b></p><table summary="IsGreaterThan Attributes" border="1"><colgroup><col><col><col></colgroup><thead><tr><th>Attribute</th><th>Description</th><th>Required</th></tr></thead><tbody><tr><td>arg1</td><td>The first argument.</td><td>Yes</td></tr><tr><td>arg2</td><td>The second argument.</td><td>Yes</td></tr></tbody></table></div><p>
53</p><p>
54</p><pre class="programlisting">
55
56&lt;!-- evaluates to true --&gt;
57&lt;isgreaterthan arg1="6.02" arg2="4"/&gt;
58
59&lt;!-- evaluates to false --&gt;
60&lt;isgreaterthan arg1="bar" arg2="foo"/&gt;
61
62</pre><p>
63</p><h3><a name="id2520135"></a>IsLessThan</h3><p>
64Tests whether the first argument is less than the second argument. Will
65automatically treat the arguments as numbers if both arguments consists of only the characters 0 through 9 and optionally a decimal point. Otherwise, a String
66comparison is used.
67</p><p>
68</p><div class="table"><a name="id2520155"></a><p class="title"><b>Table 5.7. IsLessThan Attributes</b></p><table summary="IsLessThan Attributes" border="1"><colgroup><col><col><col></colgroup><thead><tr><th>Attribute</th><th>Description</th><th>Required</th></tr></thead><tbody><tr><td>arg1</td><td>The first argument.</td><td>Yes</td></tr><tr><td>arg2</td><td>The second argument.</td><td>Yes</td></tr></tbody></table></div><p>
69</p><p>
70</p><pre class="programlisting">
71
72&lt;!-- evaluates to false --&gt;
73&lt;islessthan arg1="6.02" arg2="4"/&gt;
74
75&lt;!-- evaluates to true --&gt;
76&lt;islessthan arg1="bar" arg2="foo"/&gt;
77
78</pre><p>
79</p><h3><a name="id2520226"></a>DateBefore, TimeBefore </h3><p>
80Tests whether the first date/time is before the second date/time.
81</p><p>
82</p><div class="table"><a name="id2520243"></a><p class="title"><b>Table 5.8. DateBefore, TimeBefore</b></p><table summary="DateBefore, TimeBefore" border="1"><colgroup><col><col><col></colgroup><thead><tr><th>Attribute</th><th>Description</th><th>Required</th></tr></thead><tbody><tr><td>datetime1</td><td>The first date/time.</td><td>Yes</td></tr><tr><td>datetime2</td><td>The second date/time.</td><td>Yes</td></tr><tr><td>format</td><td>The format of the date/time stamps.</td><td>Yes</td></tr><tr><td>lenient</td><td>Whether the datetime parser should use lenient parsing, defaults to true.</td><td>No</td></tr></tbody></table></div><p>
83</p><p>
84</p><pre class="programlisting">
85
86 &lt;target name="test1"&gt;
87 &lt;a:assert&gt;
88 &lt;bool&gt;
89 &lt;not&gt;
90 &lt;datebefore datetime1="2005-09-09 14:58:36" datetime2="2005-07-11 14:58:36" format="yyyy-MM-dd HH:mm:ss"/&gt;
91 &lt;/not&gt;
92 &lt;/bool&gt;
93 &lt;/a:assert&gt;
94 &lt;/target&gt;
95
96 &lt;target name="test2"&gt;
97 &lt;a:assert&gt;
98 &lt;bool&gt;
99 &lt;not&gt;
100 &lt;timebefore datetime1="22:58:36" datetime2="10:58:36" format="HH:mm:ss"/&gt;
101 &lt;/not&gt;
102 &lt;/bool&gt;
103 &lt;/a:assert&gt;
104 &lt;/target&gt;
105
106 &lt;target name="test3"&gt;
107 &lt;a:assert&gt;
108 &lt;bool&gt;
109 &lt;timebefore datetime1="2005" datetime2="2030" format="yyyy"/&gt;
110 &lt;/bool&gt;
111 &lt;/a:assert&gt;
112 &lt;/target&gt;
113
114 &lt;target name="test4"&gt;
115 &lt;a:assert&gt;
116 &lt;bool&gt;
117 &lt;timebefore datetime1="01:00:00" datetime2="03:00:00" format="hh:mm:ss"/&gt;
118 &lt;/bool&gt;
119 &lt;/a:assert&gt;
120 &lt;/target&gt;
121
122</pre><p>
123</p><h3><a name="id2520343"></a>DateDifference, TimeDifference </h3><p>
124Tests that the difference between two dates or times is a certain value.
125</p><p>
126</p><div class="table"><a name="id2520355"></a><p class="title"><b>Table 5.9. DateDifference, TimeDifference</b></p><table summary="DateDifference, TimeDifference" border="1"><colgroup><col><col><col></colgroup><thead><tr><th>Attribute</th><th>Description</th><th>Required</th></tr></thead><tbody><tr><td>datetime1</td><td>The first date/time.</td><td>Yes</td></tr><tr><td>datetime2</td><td>The second date/time.</td><td>Yes</td></tr><tr><td>format</td><td>The format of the date/time stamps.</td><td>Yes</td></tr><tr><td>lenient</td><td>Whether the datetime parser should use lenient parsing, defaults to true.</td><td>No</td></tr><tr><td>value</td><td>The expected difference between the 2 datetimes.</td><td>No, default is 0</td></tr><tr><td>unit</td><td>Sets the unit for the difference between the 2 datetimes. For example,
127if value is 12 and unit is "hours", then this
128condition checks that the difference between the 2 datetimes is 12 hours.
129Valid values are "millisecond", "second", "minute", "hour", "day", "week", "month", "year".</td><td>Yes</td></tr></tbody></table></div><p>
130</p><p>
131</p><pre class="programlisting">
132
133 &lt;target name="test1"&gt;
134 &lt;a:assert message="Difference between dates is not 60 days."&gt;
135 &lt;bool&gt;
136 &lt;datedifference datetime1="2005-09-09 14:58:36" datetime2="2005-07-11 14:58:36" format="yyyy-MM-dd HH:mm:ss" value="60" unit="day"/&gt;
137 &lt;/bool&gt;
138 &lt;/a:assert&gt;
139 &lt;/target&gt;
140
141 &lt;target name="test2"&gt;
142 &lt;a:assert message="Difference between hours is not 12."&gt;
143 &lt;bool&gt;
144 &lt;timedifference datetime1="22:58:36" datetime2="10:58:36" format="HH:mm:ss" value="12" unit="hour"/&gt;
145 &lt;/bool&gt;
146 &lt;/a:assert&gt;
147 &lt;/target&gt;
148
149 &lt;target name="test3"&gt;
150 &lt;a:assert message="Difference between years is not 25."&gt;
151 &lt;bool&gt;
152 &lt;timedifference datetime1="2005" datetime2="2030" format="yyyy" value="25" unit="year"/&gt;
153 &lt;/bool&gt;
154 &lt;/a:assert&gt;
155 &lt;/target&gt;
156
157 &lt;target name="test4"&gt;
158 &lt;a:assert message="Difference between minutes is not 120."&gt;
159 &lt;bool&gt;
160 &lt;timedifference datetime1="01:00:00" datetime2="03:00:00" format="hh:mm:ss" value="120" unit="minute"/&gt;
161 &lt;/bool&gt;
162 &lt;/a:assert&gt;
163 &lt;/target&gt;
164
165 &lt;target name="test5"&gt;
166 &lt;a:assert message="Difference between seconds is not 7200."&gt;
167 &lt;bool&gt;
168 &lt;timedifference datetime1="01:00:00" datetime2="03:00:00" format="hh:mm:ss" value="7200" unit="second"/&gt;
169 &lt;/bool&gt;
170 &lt;/a:assert&gt;
171 &lt;/target&gt;
172
173</pre><p>
174</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="bk03ch05.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="bk03ch05.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="bk03ch06.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 5. If Task </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 6. SwitchTask</td></tr></table></div></body></html>
Note: See TracBrowser for help on using the repository browser.