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

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

initial import of LiRK3

File size: 5.0 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2
3<HTML>
4<HEAD>
5 <TITLE>FilterSet Type</TITLE>
6 <link rel="stylesheet" type="text/css" href="../stylesheets/antmanual.css">
7</HEAD>
8
9<BODY>
10<H2><A name="filterset">FilterSet</A></H2>
11
12<P>FilterSets are groups of filters. Filters can be defined as token-value
13pairs
14or be read in from a file. FilterSets can appear inside tasks that support this
15feature or at the same level as <CODE>&lt;target&gt;</CODE> - i.e., as
16children of
17<CODE>&lt;project&gt;</CODE>.</P>
18
19<p>FilterSets support the <code>id</code> and <code>refid</code>
20attributes. You can define a FilterSet with an <code>id</code>
21attribute and then refer to that definition from another FilterSet
22with a <code>refid</code> attribute. It is also possible to nest
23filtersets into filtersets to get a set union of the contained
24filters.</p>
25
26<p>In addition, FilterSets can specify
27<code>begintoken</code> and/or
28<code>endtoken</code> attributes to define what to match.</p>
29<p>Filtersets are used for doing
30replacements in tasks such as <code>&lt;copy&gt;</code>, etc.</p>
31
32<p>
33<strong>Note: </strong>When a filterset is used in an operation, the files are
34processed in text mode and the filters applied line by line. This means that
35the copy operations will typically corrupt binary files. When applying filters
36you should ensure that the set of files being filtered are all text files.
37</p>
38
39<H2>Filterset</H2>
40
41<TABLE cellSpacing=0 cellPadding=2 border=1>
42 <TR>
43 <TD vAlign=top><B>Attribute</B></TD>
44 <TD vAlign=top><B>Description</B></TD>
45 <TD vAlign=top><B>Default</B></TD>
46 <TD vAlign=top align="center"><B>Required</B></TD>
47 </TR>
48 <TR>
49 <TD vAlign=top>begintoken</TD>
50 <TD vAlign=top>The string marking the beginning of a token (eg.,
51 <code>&#64;DATE&#64;</code>).</TD>
52 <TD vAlign=top>@</TD>
53 <TD vAlign=top align="center">No</TD>
54 </TR>
55 <TR>
56 <TD vAlign=top>endtoken</TD>
57 <TD vAlign=top>The string marking the end of a token (eg.,
58 <code>&#64;DATE&#64;</code>).</TD>
59 <TD vAlign=top>@</TD>
60 <TD vAlign=top align="center">No</TD>
61 </TR>
62</TABLE>
63
64<H2>Filter</H2>
65<TABLE cellSpacing=0 cellPadding=2 border=1>
66 <TR>
67 <TD vAlign=top><B>Attribute</B></TD>
68 <TD vAlign=top><B>Description</B></TD>
69 <TD vAlign=top align="center"><B>Required</B></TD>
70 </TR>
71 <TR>
72 <TD vAlign=top>token</TD>
73 <TD vAlign=top>The token to replace (eg., <code>&#64;DATE&#64;</code>)</TD>
74 <TD vAlign=top align="center">Yes</TD>
75 </TR>
76 <TR>
77 <TD vAlign=top>value</TD>
78 <TD vAlign=top>The value to replace it with
79 (eg., <code>Thursday, April 26, 2001</code>).</TD>
80 <TD vAlign=top align="center">Yes</TD>
81 </TR>
82</TABLE>
83
84<H2>Filtersfile</H2>
85<TABLE cellSpacing=0 cellPadding=2 border=1>
86 <TR>
87 <TD vAlign=top><B>Attribute</B></TD>
88 <TD vAlign=top><B>Description</B></TD>
89 <TD vAlign=top align="center"><B>Required</B></TD>
90 </TR>
91 <TR>
92 <TD vAlign=top>file</TD>
93 <TD vAlign=top>A properties file of
94 name-value pairs from which to load the tokens.</TD>
95 <TD vAlign=top align="center">Yes</TD>
96 </TR>
97</TABLE>
98
99<H4>Examples</H4>
100
101<p>You are copying the <code>version.txt</code> file to the <code>dist</code>
102directory from the <code>build</code> directory
103but wish to replace the token <code>&#64;DATE&#64;</code> with today's date.</p>
104<BLOCKQUOTE><PRE>
105&lt;copy file=&quot;${build.dir}/version.txt&quot; toFile=&quot;${dist.dir}/version.txt&quot;&gt;
106 &lt;filterset&gt;
107 &lt;filter token=&quot;DATE&quot; value=&quot;${TODAY}&quot;/&gt;
108 &lt;/filterset&gt;
109&lt;/copy&gt;
110</PRE></BLOCKQUOTE>
111
112<p>You are copying the <code>version.txt</code> file to the <code>dist</code>
113directory from the build directory
114but wish to replace the token <code>%DATE*</code> with today's date.</p>
115<BLOCKQUOTE><PRE>
116&lt;copy file=&quot;${build.dir}/version.txt&quot; toFile=&quot;${dist.dir}/version.txt&quot;&gt;
117 &lt;filterset begintoken=&quot;%&quot; endtoken=&quot;*&quot;&gt;
118 &lt;filter token=&quot;DATE&quot; value=&quot;${TODAY}&quot;/&gt;
119 &lt;/filterset&gt;
120&lt;/copy&gt;
121</PRE></BLOCKQUOTE>
122
123<p>Copy all the docs but change all dates and appropriate notices as stored in a file.</p>
124<BLOCKQUOTE><PRE>
125&lt;copy toDir=&quot;${dist.dir}/docs&quot;&gt;
126 &lt;fileset dir=&quot;${build.dir}/docs&quot;&gt;
127 &lt;include name=&quot;**/*.html&quot;&gt;
128 &lt;/fileset&gt;
129 &lt;filterset begintoken=&quot;%&quot; endtoken=&quot;*&quot;&gt;
130 &lt;filtersfile file=&quot;${user.dir}/dist.properties&quot;/&gt;
131 &lt;/filterset&gt;
132&lt;/copy&gt;
133</PRE></BLOCKQUOTE>
134
135<p>Define a FilterSet and reference it later.</p>
136<BLOCKQUOTE><PRE>
137&lt;filterset id=&quot;myFilterSet&quot; begintoken=&quot;%&quot; endtoken=&quot;*&quot;&gt;
138 &lt;filter token=&quot;DATE&quot; value=&quot;${TODAY}&quot;/&gt;
139&lt;/filterset&gt;
140
141&lt;copy file=&quot;${build.dir}/version.txt&quot; toFile=&quot;${dist.dir}/version.txt&quot;&gt;
142 &lt;filterset refid=&quot;myFilterSet&quot;/&gt;
143&lt;/copy&gt;
144</PRE></BLOCKQUOTE>
145<HR>
146
147<P align=center>Copyright &copy; 2001-2004 The Apache Software Foundation.
148All rights Reserved.</P></BODY></HTML>
Note: See TracBrowser for help on using the repository browser.