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
|
---|
13 | pairs
|
---|
14 | or be read in from a file. FilterSets can appear inside tasks that support this
|
---|
15 | feature or at the same level as <CODE><target></CODE> - i.e., as
|
---|
16 | children of
|
---|
17 | <CODE><project></CODE>.</P>
|
---|
18 |
|
---|
19 | <p>FilterSets support the <code>id</code> and <code>refid</code>
|
---|
20 | attributes. You can define a FilterSet with an <code>id</code>
|
---|
21 | attribute and then refer to that definition from another FilterSet
|
---|
22 | with a <code>refid</code> attribute. It is also possible to nest
|
---|
23 | filtersets into filtersets to get a set union of the contained
|
---|
24 | filters.</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
|
---|
30 | replacements in tasks such as <code><copy></code>, etc.</p>
|
---|
31 |
|
---|
32 | <p>
|
---|
33 | <strong>Note: </strong>When a filterset is used in an operation, the files are
|
---|
34 | processed in text mode and the filters applied line by line. This means that
|
---|
35 | the copy operations will typically corrupt binary files. When applying filters
|
---|
36 | you 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>@DATE@</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>@DATE@</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>@DATE@</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>
|
---|
102 | directory from the <code>build</code> directory
|
---|
103 | but wish to replace the token <code>@DATE@</code> with today's date.</p>
|
---|
104 | <BLOCKQUOTE><PRE>
|
---|
105 | <copy file="${build.dir}/version.txt" toFile="${dist.dir}/version.txt">
|
---|
106 | <filterset>
|
---|
107 | <filter token="DATE" value="${TODAY}"/>
|
---|
108 | </filterset>
|
---|
109 | </copy>
|
---|
110 | </PRE></BLOCKQUOTE>
|
---|
111 |
|
---|
112 | <p>You are copying the <code>version.txt</code> file to the <code>dist</code>
|
---|
113 | directory from the build directory
|
---|
114 | but wish to replace the token <code>%DATE*</code> with today's date.</p>
|
---|
115 | <BLOCKQUOTE><PRE>
|
---|
116 | <copy file="${build.dir}/version.txt" toFile="${dist.dir}/version.txt">
|
---|
117 | <filterset begintoken="%" endtoken="*">
|
---|
118 | <filter token="DATE" value="${TODAY}"/>
|
---|
119 | </filterset>
|
---|
120 | </copy>
|
---|
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 | <copy toDir="${dist.dir}/docs">
|
---|
126 | <fileset dir="${build.dir}/docs">
|
---|
127 | <include name="**/*.html">
|
---|
128 | </fileset>
|
---|
129 | <filterset begintoken="%" endtoken="*">
|
---|
130 | <filtersfile file="${user.dir}/dist.properties"/>
|
---|
131 | </filterset>
|
---|
132 | </copy>
|
---|
133 | </PRE></BLOCKQUOTE>
|
---|
134 |
|
---|
135 | <p>Define a FilterSet and reference it later.</p>
|
---|
136 | <BLOCKQUOTE><PRE>
|
---|
137 | <filterset id="myFilterSet" begintoken="%" endtoken="*">
|
---|
138 | <filter token="DATE" value="${TODAY}"/>
|
---|
139 | </filterset>
|
---|
140 |
|
---|
141 | <copy file="${build.dir}/version.txt" toFile="${dist.dir}/version.txt">
|
---|
142 | <filterset refid="myFilterSet"/>
|
---|
143 | </copy>
|
---|
144 | </PRE></BLOCKQUOTE>
|
---|
145 | <HR>
|
---|
146 |
|
---|
147 | <P align=center>Copyright © 2001-2004 The Apache Software Foundation.
|
---|
148 | All rights Reserved.</P></BODY></HTML>
|
---|