source: release-kits/lirk3/bin/ant-installer/web/manual/manual/CoreTypes/resources.html@ 14982

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

initial import of LiRK3

File size: 30.6 KB
Line 
1<!--
2 Licensed to the Apache Software Foundation (ASF) under one or more
3 contributor license agreements. See the NOTICE file distributed with
4 this work for additional information regarding copyright ownership.
5 The ASF licenses this file to You under the Apache License, Version 2.0
6 (the "License"); you may not use this file except in compliance with
7 the License. You may obtain a copy of the License at
8
9 http://www.apache.org/licenses/LICENSE-2.0
10
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16-->
17<html>
18
19<head>
20<meta http-equiv="Content-Language" content="en-us">
21<link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
22<title>Resources and Resource Collections</title>
23</head>
24
25<body>
26
27<h2><a name="resource">Resources</a></h2>
28<p>
29A file-like entity can be abstracted to the concept of a <i>resource</i>.
30In addition to providing access to file-like attributes, a resource
31implementation should, when possible, provide the means to read content
32from and/or write content to the underlying entity. Although the resource
33concept was introduced in <i>Ant 1.5.2</i>, resources are available for
34explicit use beginning in <b>Ant 1.7</b>.
35</p>
36
37<h3>The built-in resource types are:</h3>
38
39<ul>
40 <li><a href="#basic">resource</a> - a basic resource.</li>
41 <li><a href="#bzip2resource">bzip2resource</a> - a BZip2 compressed resource.</li>
42 <li><a href="#file">file</a> - a file.</li>
43 <li><a href="#gzipresource">gzipresource</a> - a GZip compressed resource.</li>
44 <li><a href="#javaresource">javaresource</a> - a resource loadable
45 via a Java classloader.</li>
46 <li><a href="#propertyresource">propertyresource</a> - an Ant property.</li>
47 <li><a href="#string">string</a> - a text string.</li>
48 <li><a href="#tarentry">tarentry</a> - an entry in a tar file.</li>
49 <li><a href="#url">url</a> - a URL.</li>
50 <li><a href="#zipentry">zipentry</a> - an entry in a zip file.</li>
51</ul>
52
53<h4><a name="basic">resource</a></h4>
54
55<p>A basic resource. Other resource types derive from this basic
56type; as such all its attributes are available, though in most cases
57irrelevant attributes will be ignored. This and all resource
58implementations are also usable as single-element
59<a href="#collection">Resource Collections</a>.
60</p>
61
62<table border="1" cellpadding="2" cellspacing="0">
63 <tr>
64 <td valign="top"><b>Attribute</b></td>
65 <td valign="top"><b>Description</b></td>
66 <td align="center" valign="top"><b>Required</b></td>
67 </tr>
68 <tr>
69 <td valign="top">name</td>
70 <td valign="top">The name of this resource</td>
71 <td align="center" valign="top">No</td>
72 </tr>
73 <tr>
74 <td valign="top">exists</td>
75 <td valign="top">Whether this resource exists</td>
76 <td align="center" valign="top">No, default <i>true</i></td>
77 </tr>
78 <tr>
79 <td valign="top">lastmodified</td>
80 <td valign="top">The last modification time of this resource</td>
81 <td align="center" valign="top">No</td>
82 </tr>
83 <tr>
84 <td valign="top">directory</td>
85 <td valign="top">Whether this resource is directory-like</td>
86 <td align="center" valign="top">No, default <i>false</i></td>
87 </tr>
88 <tr>
89 <td valign="top">size</td>
90 <td valign="top">The size of this resource</td>
91 <td align="center" valign="top">No</td>
92 </tr>
93</table>
94
95<h4><a name="file">file</a></h4>
96
97<p>Represents a file accessible via local filesystem conventions.</p>
98
99<table border="1" cellpadding="2" cellspacing="0">
100 <tr>
101 <td valign="top"><b>Attribute</b></td>
102 <td valign="top"><b>Description</b></td>
103 <td align="center" valign="top"><b>Required</b></td>
104 </tr>
105 <tr>
106 <td valign="top">file</td>
107 <td valign="top">The file represented by this resource</td>
108 <td align="center" valign="top">Yes</td>
109 </tr>
110 <tr>
111 <td valign="top">basedir</td>
112 <td valign="top">The base directory of this resource. When this
113 attribute is set, attempts to access the name of the resource
114 will yield a path relative to this location.</td>
115 <td align="center" valign="top">No</td>
116 </tr>
117</table>
118
119<h4><a name="javaresource">javaresource</a></h4>
120
121<p>Represents a resource loadable via a Java classloader.</p>
122
123<table border="1" cellpadding="2" cellspacing="0">
124 <tr>
125 <td valign="top"><b>Attribute</b></td>
126 <td valign="top"><b>Description</b></td>
127 <td align="center" valign="top"><b>Required</b></td>
128 </tr>
129 <tr>
130 <td valign="top">name</td>
131 <td valign="top">The name of the resource.</td>
132 <td align="center" valign="top">Yes</td>
133 </tr>
134 <tr>
135 <td valign="top">classpath</td>
136 <td valign="top">the classpath to use when looking up a resource.</td>
137 <td align="center" valign="top">No</td>
138 </tr>
139 <tr>
140 <td valign="top">classpathref</td>
141 <td valign="top">the classpath to use when looking up a resource,
142 given as <a href="../using.html#references">reference</a>
143 to a <code>&lt;path&gt;</code> defined elsewhere..</td>
144 <td align="center" valign="top">No</td>
145 </tr>
146 <tr>
147 <td valign="top">loaderRef</td>
148 <td valign="top">the name of the loader that is
149 used to load the resource, constructed from the specified classpath.</td>
150 <td align="center" valign="top">No</td>
151 </tr>
152</table>
153
154<p>The classpath can also be specified as nested classpath element,
155where <b>&lt;classpath&gt;</b> is a <a
156href="../using.html#path">path-like</a> structure.</p>
157
158<h4><a name="zipentry">zipentry</a></h4>
159
160<p>Represents an entry in a ZIP archive. The archive can be specified
161using the archive attribute or a nested single-element resource
162collection. <code>zipentry</code> only supports file system resources
163as nested elements.</p>
164
165<table border="1" cellpadding="2" cellspacing="0">
166 <tr>
167 <td valign="top"><b>Attribute</b></td>
168 <td valign="top"><b>Description</b></td>
169 <td align="center" valign="top"><b>Required</b></td>
170 </tr>
171 <tr>
172 <td valign="top">zipfile or its alias name archive</td>
173 <td valign="top">The zip file containing this resource</td>
174 <td align="center" valign="top">Yes, unless a nested resource
175 collection has been specified.</td>
176 </tr>
177 <tr>
178 <td valign="top">name</td>
179 <td valign="top">The name of the archived resource</td>
180 <td align="center" valign="top">Yes</td>
181 </tr>
182 <tr>
183 <td valign="top">encoding</td>
184 <td valign="top">The encoding of the zipfile</td>
185 <td align="center" valign="top">No;
186 platform default used if unspecified</td>
187 </tr>
188</table>
189
190<h4><a name="tarentry">tarentry</a></h4>
191
192<p>Represents an entry in a TAR archive. The archive can be specified
193using the archive attribute or a nested single-element resource
194collection.</p>
195
196<table border="1" cellpadding="2" cellspacing="0">
197 <tr>
198 <td valign="top"><b>Attribute</b></td>
199 <td valign="top"><b>Description</b></td>
200 <td align="center" valign="top"><b>Required</b></td>
201 </tr>
202 <tr>
203 <td valign="top">archive</td>
204 <td valign="top">The tar archive containing this resource</td>
205 <td align="center" valign="top">Yes, unless a nested resource
206 collection has been specified.</td>
207 </tr>
208 <tr>
209 <td valign="top">name</td>
210 <td valign="top">The name of the archived resource</td>
211 <td align="center" valign="top">Yes</td>
212 </tr>
213</table>
214
215<h4><a name="gzipresource">gzipresource</a></h4>
216
217<p>This is not a stand-alone resource, but a wrapper around another
218resource providing compression of the resource's contents on the fly.
219A single element resource collection must be specified as a nested
220element.</p>
221
222<h4><a name="bzip2resource">bzip2resource</a></h4>
223
224<p>This is not a stand-alone resource, but a wrapper around another
225resource providing compression of the resource's contents on the fly.
226A single element resource collection must be specified as a nested
227element.</p>
228
229<h4><a name="url">url</a></h4>
230
231<p>Represents a URL.</p>
232
233<table border="1" cellpadding="2" cellspacing="0">
234 <tr>
235 <td valign="top"><b>Attribute</b></td>
236 <td valign="top"><b>Description</b></td>
237 <td align="center" valign="top"><b>Required</b></td>
238 </tr>
239 <tr>
240 <td valign="top">url</td>
241 <td valign="top">The url to expose</td>
242 <td rowspan="3" align="center" valign="middle">Exactly one of these</td>
243 </tr>
244 <tr>
245 <td valign="top">file</td>
246 <td valign="top">The file to expose as a file: url</td>
247 </tr>
248</table>
249
250<h4><a name="string">string</a></h4>
251
252<p>Represents a Java String. As such a string is readable but not writable.</p>
253
254<table border="1" cellpadding="2" cellspacing="0">
255 <tr>
256 <td valign="top"><b>Attribute</b></td>
257 <td valign="top"><b>Description</b></td>
258 <td align="center" valign="top"><b>Required</b></td>
259 </tr>
260 <tr>
261 <td valign="top">value</td>
262 <td valign="top">The value of this resource</td>
263 <td align="center" valign="top">Yes</td>
264 </tr>
265</table>
266
267<h4><a name="propertyresource">propertyresource</a></h4>
268
269<p>Represents an Ant property.</p>
270
271<table border="1" cellpadding="2" cellspacing="0">
272 <tr>
273 <td valign="top"><b>Attribute</b></td>
274 <td valign="top"><b>Description</b></td>
275 <td align="center" valign="top"><b>Required</b></td>
276 </tr>
277 <tr>
278 <td valign="top">name</td>
279 <td valign="top">The property name</td>
280 <td align="center" valign="top">Yes</td>
281 </tr>
282</table>
283
284<hr>
285<h2><a name="collection">Resource Collections</a></h2>
286<p>
287A Resource Collection is an abstraction of an entity that groups
288together a number of <a href="#resource">resources</a>. Several of
289Ant's "legacy" datatypes have been modified to behave as Resource Collections:
290<ul>
291 <li><a href="fileset.html">fileset</a>,
292 <a href="dirset.html">dirset</a>,
293 <a href="filelist.html">filelist</a>, and
294 <a href="../using.html#path">path</a>
295 (and derivative types) expose <a href="#file">file</a> resources
296 </li>
297 <li><a href="zipfileset.html">tarfileset</a>
298 can expose <a href="#file">file</a> or <a href="#tarentry">tarentry</a>
299 resources depending on configuration
300 </li>
301 <li><a href="zipfileset.html">zipfileset</a>
302 can expose <a href="#file">file</a> or <a href="#zipentry">zipentry</a>
303 resources depending on configuration
304 </li>
305 <li><a href="propertyset.html">propertyset</a>
306 exposes <a href="#property">property</a> resources
307 </li>
308</ul>
309</p>
310<h3>The additional built-in resource collections are:</h3>
311<ul>
312 <li><a href="#resources">resources</a> - generic resource collection</li>
313 <li><a href="#files">files</a> - collection of files similar to
314 <a href="fileset.html">fileset</a></li>
315 <li><a href="#restrict">restrict</a> - restrict a resource collection
316 to include only resources meeting specified criteria</li>
317 <li><a href="#sort">sort</a> - sorted resource collection</li>
318 <li><a href="#first">first</a> - first <i>n</i> resources from a
319 nested collection</li>
320 <li><a href="#tokens">tokens</a> - <a href="#string">string</a> tokens
321 gathered from a nested collection</li>
322 <li><a href="#union">union</a> - set union of nested resource collections</li>
323 <li><a href="#intersect">intersect</a> - set intersection
324 of nested resource collections</li>
325 <li><a href="#difference">difference</a> - set difference
326 of nested resource collections</li>
327</ul>
328<h4><a name="resources">resources</a></h4>
329<p>A generic resource collection, designed for use with
330 <a href="../using.html#references">references</a>.
331 For example, if a third-party Ant task generates a Resource Collection
332 of an unknown type, it can still be accessed via a
333 <code>&lt;resources&gt;</code> collection. The secondary use of this
334 collection type is as a container of other resource collections,
335 preserving the order of nested collections as well as
336 duplicate resources (contrast with <a href="#union">union</a>).
337</p>
338
339<h4><a name="files">files</a></h4>
340<p>A group of files. These files are matched by <b>absolute</b> patterns
341 taken from a number of <a href="patternset.html">PatternSets</a>.
342 These can be specified as nested <code>&lt;patternset&gt;</code>
343 elements. In addition, <code>&lt;files&gt;</code> holds an implicit
344 PatternSet and supports the nested <code>&lt;include&gt;</code>,
345 <code>&lt;includesfile&gt;</code>, <code>&lt;exclude&gt;</code>
346 and <code>&lt;excludesfile&gt;</code> elements of PatternSet directly,
347 as well as PatternSet's attributes.
348</p>
349<p><a href="selectors.html">File Selectors</a> are available as nested
350 elements. A file must be selected by all selectors in order to be included;
351 <code>&lt;files&gt;</code> is thus equivalent to an
352 <code>&lt;and&gt;</code> file selector container.
353</p>
354<p><b>More simply put</b>, this type is equivalent to a
355 <a href="fileset.html">fileset</a> with no base directory.
356 <b>Please note</b> that without a base directory,
357 filesystem scanning is based entirely on include and exclude patterns.
358 A <a href="selectors.html#filenameselect">filename</a> (or any)
359 selector can <i>only</i> influence the scanning process <i>after</i>
360 the file has been included based on pattern-based selection.
361</p>
362
363<table border="1" cellpadding="2" cellspacing="0">
364 <tr>
365 <td valign="top"><b>Attribute</b></td>
366 <td valign="top"><b>Description</b></td>
367 <td align="center" valign="top"><b>Required</b></td>
368 </tr>
369 <tr>
370 <td valign="top">includes</td>
371 <td valign="top">comma- or space-separated list of patterns
372 of files that must be included</td>
373 <td rowspan="2" valign="middle" align="center">At least one of these</td>
374 </tr>
375 <tr>
376 <td valign="top">includesfile</td>
377 <td valign="top">the name of a file; each line of this file is
378 taken to be an include pattern.</td>
379 </tr>
380 <tr>
381 <td valign="top">excludes</td>
382 <td valign="top">comma- or space-separated list of patterns
383 of files that must be excluded</td>
384 <td rowspan="2" valign="top" align="center">No, default none
385 (except default excludes when true)</td>
386 </tr>
387 <tr>
388 <td valign="top">excludesfile</td>
389 <td valign="top">the name of a file; each line of this file is
390 taken to be an exclude pattern.</td>
391 </tr>
392 <tr>
393 <td valign="top">defaultexcludes</td>
394 <td valign="top">Whether
395 <a href="../dirtasks.html#defaultexcludes">default excludes</a>
396 should be used</td>
397 <td valign="top" align="center">No, default <i>true</i></td>
398 </tr>
399 <tr>
400 <td valign="top">casesensitive</td>
401 <td valign="top">Whether patterns are case-sensitive</td>
402 <td valign="top" align="center">No, default <i>true</i></td>
403 </tr>
404 <tr>
405 <td valign="top">followsymlinks</td>
406 <td valign="top">Whether to follow symbolic links
407 (see note <a href="#symlink">below</a>)</td>
408 <td valign="top" align="center">No, default <i>true</i></td>
409 </tr>
410</table>
411
412<p><a name="symlink"><b>Note</b></a>: All files/directories for which
413the canonical path is different from its path are considered symbolic
414links. On Unix systems this usually means the file really is a
415symbolic link but it may lead to false results on other
416platforms.
417</p>
418
419<h4><a name="restrict">restrict</a></h4>
420<p>Restricts another nested resource collection using resource selectors:
421<blockquote>
422 <table border="1" cellpadding="2" cellspacing="0">
423 <tr>
424 <td valign="top"><b>Attribute</b></td>
425 <td valign="top"><b>Description</b></td>
426 <td align="center" valign="top"><b>Required</b></td>
427 </tr>
428 <tr>
429 <td valign="top">cache</td>
430 <td valign="top">Whether to cache results; disabling
431 may seriously impact performance</td>
432 <td valign="top" align="center">No, default <i>true</i></td>
433 </tr>
434 </table>
435 <h4>Parameters specified as nested elements</h4>
436 <p>A single resource collection is required.</p>
437 <p>Nested resource selectors are used to "narrow down" the included
438 resources. These are patterned after <a href="selectors.html">file
439 selectors</a> but are, unsurprisingly, targeted to resources.
440 Several built-in resource selectors are available in the internal
441 <a href="antlib.html">antlib</a>
442 <code>org.apache.tools.ant.types.resources.selectors</code>:
443 </p>
444
445 <ul>
446 <li><a href="#rsel.name">name</a> - select resources by name.</li>
447 <li><a href="#rsel.exists">exists</a> - select existing resources.</li>
448 <li><a href="#rsel.date">date</a> - select resources by date.</li>
449 <li><a href="#rsel.type">type</a> - select resources by type.</li>
450 <li><a href="#rsel.size">size</a> - select resources by size.</li>
451 <li><a href="#rsel.instanceof">instanceof</a>
452 - select resources by class or Ant datatype.</li>
453 <li><a href="#rsel.and">and</a> - "and" nested resource selectors.</li>
454 <li><a href="#rsel.or">or</a> - "or" nested resource selectors.</li>
455 <li><a href="#rsel.not">not</a> - "not" a nested resource selector.</li>
456 <li><a href="#rsel.none">none</a>
457 - select resources selected by no nested resource selectors.</li>
458 <li><a href="#rsel.majority">majority</a> - select resources selected
459 by a majority of nested resource selectors.</li>
460 <li><a href="selectors.html#modified">modified</a> - select resources which
461 content has changed.</li>
462 <li><a href="selectors.html#containsselect">contains</a> - select resources
463 containing a particular text string.</li>
464 <li><a href="selectors.html#regexpselect">containsregexp</a> - select
465 resources whose contents match a particular regular expression.</li>
466 <li><a href="#rsel.compare">compare</a> - select resources
467 based on comparison to other resources.</li>
468 </ul>
469
470 <h4><a name="rsel.name">name</a></h4>
471 <p>Selects resources by name.</p>
472 <table border="1" cellpadding="2" cellspacing="0">
473 <tr>
474 <td valign="top"><b>Attribute</b></td>
475 <td valign="top"><b>Description</b></td>
476 <td align="center" valign="top"><b>Required</b></td>
477 </tr>
478 <tr>
479 <td valign="top">name</td>
480 <td valign="top">The name pattern to test</td>
481 <td align="center" valign="top">Yes</td>
482 </tr>
483 <tr>
484 <td valign="top">casesensitive</td>
485 <td valign="top">Whether name comparisons are case-sensitive</td>
486 <td align="center" valign="top">No, default <i>true</i></td>
487 </tr>
488 </table>
489
490 <h4><a name="rsel.exists">exists</a></h4>
491 <p>Selects existing resources.</p>
492
493 <h4><a name="rsel.date">date</a></h4>
494 <p>Selects resources by date.</p>
495 <table border="1" cellpadding="2" cellspacing="0">
496 <tr>
497 <td valign="top"><b>Attribute</b></td>
498 <td valign="top"><b>Description</b></td>
499 <td align="center" valign="top"><b>Required</b></td>
500 </tr>
501 <tr>
502 <td valign="top">millis</td>
503 <td valign="top">The comparison date/time in ms since January 1, 1970</td>
504 <td rowspan="2" align="center" valign="middle">One of these</td>
505 </tr>
506 <tr>
507 <td valign="top">datetime</td>
508 <td valign="top">The formatted comparison date/time</td>
509 </tr>
510 <tr>
511 <td valign="top">pattern</td>
512 <td valign="top">SimpleDateFormat-compatible pattern
513 for use with the <code>datetime</code> attribute</td>
514 <td align="center" valign="top">
515 No, default is "MM/DD/YYYY HH:MM AM_or_PM"</td>
516 </tr>
517 <tr>
518 <td valign="top">granularity</td>
519 <td valign="top">The number of milliseconds leeway to use when
520 comparing file modification times. This is needed because not
521 every file system supports tracking the last modified time to
522 the millisecond level.</td>
523 <td align="center" valign="top">No; default varies by platform:
524 FAT filesystems = 2 sec; Unix = 1 sec; NTFS = 1 ms.</td>
525 </tr>
526 <tr>
527 <td valign="top">when</td>
528 <td valign="top">One of "before", "after", "equal"</td>
529 <td align="center" valign="top">No, default "equal"</td>
530 </tr>
531 </table>
532
533 <h4><a name="rsel.type">type</a></h4>
534 <p>Selects resources by type (file or directory).</p>
535 <table border="1" cellpadding="2" cellspacing="0">
536 <tr>
537 <td valign="top"><b>Attribute</b></td>
538 <td valign="top"><b>Description</b></td>
539 <td align="center" valign="top"><b>Required</b></td>
540 </tr>
541 <tr>
542 <td valign="top">type</td>
543 <td valign="top">One of "file", "dir"</td>
544 <td align="center" valign="top">Yes</td>
545 </tr>
546 </table>
547
548 <h4><a name="rsel.size">size</a></h4>
549 <p>Selects resources by size.</p>
550 <table border="1" cellpadding="2" cellspacing="0">
551 <tr>
552 <td valign="top"><b>Attribute</b></td>
553 <td valign="top"><b>Description</b></td>
554 <td align="center" valign="top"><b>Required</b></td>
555 </tr>
556 <tr>
557 <td valign="top">size</td>
558 <td valign="top">The size to compare</td>
559 <td align="center" valign="top">Yes</td>
560 </tr>
561 <tr>
562 <td valign="top">when</td>
563 <td valign="top">One of "equal", "eq", "greater", "gt", "less", "lt",
564 "ge" (greater or equal), "ne" (not equal), "le" (less or equal)</td>
565 <td align="center" valign="top">No, default "equal"</td>
566 </tr>
567 </table>
568
569 <h4><a name="rsel.instanceof">instanceof</a></h4>
570 <p>Selects resources by type.</p>
571 <table border="1" cellpadding="2" cellspacing="0">
572 <tr>
573 <td valign="top"><b>Attribute</b></td>
574 <td valign="top"><b>Description</b></td>
575 <td align="center" valign="top"><b>Required</b></td>
576 </tr>
577 <tr>
578 <td valign="top">class</td>
579 <td valign="top">The class of which the resource must be an instance</td>
580 <td rowspan="2" align="center" valign="middle">One of these</td>
581 </tr>
582 <tr>
583 <td valign="top">type</td>
584 <td valign="top">The Ant type that must
585 be assignable from the resource</td>
586 </tr>
587 <tr>
588 <td valign="top">uri</td>
589 <td valign="top">The uri in which <i>type</i> must be defined</td>
590 <td valign="top">No</td>
591 </tr>
592 </table>
593
594 <h4><a name="rsel.and">and</a></h4>
595 <p>Selects a resource if it is selected by all nested resource selectors.</p>
596
597 <h4><a name="rsel.or">or</a></h4>
598 <p>Selects a resource if it is selected
599 by at least one nested resource selector.</p>
600
601 <h4><a name="rsel.not">not</a></h4>
602 <p>Negates the selection result of the single
603 nested resource selector allowed.</p>
604
605 <h4><a name="rsel.none">none</a></h4>
606 <p>Selects a resource if it is selected
607 by no nested resource selectors.</p>
608
609 <h4><a name="rsel.majority">majority</a></h4>
610 <p>Selects a resource if it is selected
611 by the majority of nested resource selectors.</p>
612 <table border="1" cellpadding="2" cellspacing="0">
613 <tr>
614 <td valign="top"><b>Attribute</b></td>
615 <td valign="top"><b>Description</b></td>
616 <td align="center" valign="top"><b>Required</b></td>
617 </tr>
618 <tr>
619 <td valign="top">allowtie</td>
620 <td valign="top">Whether a tie (when there is an even number
621 of nested resource selectors) is considered a majority</td>
622 <td valign="top">No, default <i>true</i></td>
623 </tr>
624 </table>
625
626 <h4><a name="rsel.compare">compare</a></h4>
627 <p>Selects a resource based on its comparison to one or more "control"
628 resources using nested <a href="#rcmp">resource comparators</a>.</p>
629 <table border="1" cellpadding="2" cellspacing="0">
630 <tr>
631 <td valign="top"><b>Attribute</b></td>
632 <td valign="top"><b>Description</b></td>
633 <td align="center" valign="top"><b>Required</b></td>
634 </tr>
635 <tr>
636 <td valign="top">when</td>
637 <td valign="top">Comparison ("equal"/"eq", "greater"/"gt", "less"/"lt",
638 "le" (less or equal), "ge" (greater or equal), "ne" (not equal).</td>
639 <td valign="top">No, default "equal"</td>
640 </tr>
641 <tr>
642 <td valign="top">against</td>
643 <td valign="top">Quantifier ("all"/"each"/"every", "any"/"some",
644 (exactly) "one", "most"/"majority", "none".</td>
645 <td valign="top">No, default "all"</td>
646 </tr>
647 </table>
648 <h4>Parameters specified as nested elements</h4>
649 <p>The resources against which comparisons will be made must be specified
650 using the nested &lt;control&gt; element, which denotes a
651 <a href="#resources">resources</a> collection.</p>
652 <h3>Examples</h3>
653 <p>The following selects files a, b, c, and d:</p>
654 <pre>
655&lt;restrict&gt;
656 &lt;fileset dir="src" includes="a,b,c,d,e,f,g" /&gt;
657 &lt;rsel:compare when="le" against="all"&gt;
658 &lt;control&gt;
659 &lt;resource name="d" /&gt;
660 &lt;/control&gt;
661 &lt;rcmp:name /&gt;
662 &lt;/rsel:compare&gt;
663&lt;/restrict&gt;</pre>
664</blockquote>
665
666<h4><a name="sort">sort</a></h4>
667
668<p>Sorts another nested resource collection according to the resources'
669 natural order, or by one or more nested <a href="#rcmp">resource
670 comparators</a>:</p>
671<blockquote>
672 <table border="1" cellpadding="2" cellspacing="0">
673 <tr>
674 <td valign="top"><b>Attribute</b></td>
675 <td valign="top"><b>Description</b></td>
676 <td align="center" valign="top"><b>Required</b></td>
677 </tr>
678 <tr>
679 <td valign="top">cache</td>
680 <td valign="top">Whether to cache results; disabling
681 may seriously impact performance</td>
682 <td valign="top" align="center">No, default <i>true</i></td>
683 </tr>
684 </table>
685 <h4>Parameters specified as nested elements</h4>
686 <p>A single resource collection is required.</p>
687 <p>The sort can be controlled and customized by specifying one or more
688 resource comparators. Resources can be sorted according to multiple
689 criteria; the first specified is the "outermost", while the last
690 specified is the "innermost". Several built-in resource comparators
691 are available in the internal <a href="antlib.html">antlib</a>
692 <code>org.apache.tools.ant.types.resources.comparators</code>:
693 </p>
694 <h4><a name="rcmp">Resource Comparators:</a></h4>
695 <ul>
696 <li><a href="#rcmp.name">name</a> - sort resources by name</li>
697 <li><a href="#rcmp.exists">exists</a> - sort resources by existence</li>
698 <li><a href="#rcmp.date">date</a> - sort resources by date</li>
699 <li><a href="#rcmp.type">type</a> - sort resources by type</li>
700 <li><a href="#rcmp.size">size</a> - sort resources by size</li>
701 <li><a href="#rcmp.content">content</a> - sort resources by content</li>
702 <li><a href="#rcmp.reverse">reverse</a> - reverse the natural sort order,
703 or that of a single nested resource comparator</li>
704 </ul>
705
706 <h4><a name="rcmp.name">name</a></h4>
707 <p>Sort resources by name.</p>
708
709 <h4><a name="rcmp.exists">exists</a></h4>
710 <p>Sort resources by existence.
711 Not existing is considered "less than" existing.</p>
712
713 <h4><a name="rcmp.date">date</a></h4>
714 <p>Sort resources by date.</p>
715
716 <h4><a name="rcmp.type">type</a></h4>
717 <p>Sort resources by type (file or directory).
718 Because directories contain files, they are considered "greater".</p>
719
720 <h4><a name="rcmp.size">size</a></h4>
721 <p>Sort resources by size.</p>
722
723 <h4><a name="rcmp.content">content</a></h4>
724 <p>Sort resources by content.</p>
725 <table border="1" cellpadding="2" cellspacing="0">
726 <tr>
727 <td valign="top"><b>Attribute</b></td>
728 <td valign="top"><b>Description</b></td>
729 <td align="center" valign="top"><b>Required</b></td>
730 </tr>
731 <tr>
732 <td valign="top">binary</td>
733 <td valign="top">Whether content should be compared in binary mode.
734 If <i>false<i>, content will be compared without regard to
735 platform-specific line-ending conventions.</td>
736 <td valign="top">No, default <i>true</i></td>
737 </tr>
738 </table>
739
740 <h4><a name="rcmp.reverse">reverse</a></h4>
741 <p>Reverse the natural sort order, or that of a single nested comparator.</p>
742
743</blockquote>
744
745<h4><a name="first">first</a></h4>
746<p>Includes the first <i>count</i> resources from a nested resource collection.
747This can be used in conjunction with the <a href="#sort">sort</a> collection,
748for example, to select the first few oldest, largest, etc. resources from a
749larger collection.</p>
750<blockquote>
751 <table border="1" cellpadding="2" cellspacing="0">
752 <tr>
753 <td valign="top"><b>Attribute</b></td>
754 <td valign="top"><b>Description</b></td>
755 <td align="center" valign="top"><b>Required</b></td>
756 </tr>
757 <tr>
758 <td valign="top">count</td>
759 <td valign="top">The number of resources to include</td>
760 <td valign="top" align="center">No, default 1</td>
761 </tr>
762 <tr>
763 <td valign="top">cache</td>
764 <td valign="top">Whether to cache results; disabling
765 may seriously impact performance</td>
766 <td valign="top" align="center">No, default <i>true</i></td>
767 </tr>
768 </table>
769 <h4>Parameters specified as nested elements</h4>
770 <p>A single resource collection is required.</p>
771</blockquote>
772
773<h4><a name="tokens">tokens</a></h4>
774<p>Includes the <a href="#string">string</a> tokens gathered from a nested
775 resource collection. Uses the same tokenizers supported by the
776<a href="filterchain.html#tokenfilter">TokenFilter</a>. Hint: imaginative
777 use of this resource collection can implement equivalents for such Unix
778 functions as <code>sort</code>, <code>grep -c</code>, <code>wc</code> and
779 <code>wc -l</code>.</p>
780<blockquote>
781 <table border="1" cellpadding="2" cellspacing="0">
782 <tr>
783 <td valign="top"><b>Attribute</b></td>
784 <td valign="top"><b>Description</b></td>
785 <td align="center" valign="top"><b>Required</b></td>
786 </tr>
787 <tr>
788 <td valign="top">encoding</td>
789 <td valign="top">The encoding of the nested resources</td>
790 <td valign="top" align="center">No, default is platform default</td>
791 </tr>
792 <tr>
793 <td valign="top">cache</td>
794 <td valign="top">Whether to cache results; disabling
795 may seriously impact performance</td>
796 <td valign="top" align="center">No, default <i>true</i></td>
797 </tr>
798 </table>
799 <h4>Parameters specified as nested elements</h4>
800 <p>A single resource collection is required.</p>
801</blockquote>
802
803<h4><a name="setlogic">Set operations</a></h4>
804<blockquote>
805 <p>The following resource collections implement set operations:</p>
806 <ul>
807 <li><a href="#union">union</a></li>
808 <li><a href="#intersect">intersect</a></li>
809 <li><a href="#difference">difference</a></li>
810 </ul>
811
812 <h4><a name="union">union</a></h4>
813 <p>Union of nested resource collections.</p>
814
815 <h4><a name="intersect">intersect</a></h4>
816 <p>Intersection of nested resource collections.</p>
817
818 <h4><a name="difference">difference</a></h4>
819 <p>Difference of nested resource collections.</p>
820
821 <p>The following attributes apply to all set-operation resource collections:
822 </p>
823 <table border="1" cellpadding="2" cellspacing="0">
824 <tr>
825 <td valign="top"><b>Attribute</b></td>
826 <td valign="top"><b>Description</b></td>
827 <td align="center" valign="top"><b>Required</b></td>
828 </tr>
829 <tr>
830 <td valign="top">cache</td>
831 <td valign="top">Whether to cache results; disabling
832 may seriously impact performance</td>
833 <td valign="top" align="center">No, default <i>true</i></td>
834 </tr>
835 </table>
836</blockquote>
837
838
839
840</body>
841</html>
Note: See TracBrowser for help on using the repository browser.