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 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
---|
18 |
|
---|
19 | <html>
|
---|
20 | <head>
|
---|
21 | <link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
|
---|
22 | <title>FilterChains and FilterReaders</title>
|
---|
23 | </head>
|
---|
24 |
|
---|
25 | <body>
|
---|
26 |
|
---|
27 | <h2>FilterChains and FilterReaders</h2>
|
---|
28 | Consider the flexibility of Unix pipes. If you wanted,
|
---|
29 | for example, to copy just those lines that contained the
|
---|
30 | string blee from the first 10 lines of a text file 'foo'
|
---|
31 | (<em>you wouldn't want to filter a binary file</em>)
|
---|
32 | to a file 'bar', you would do something like:<p>
|
---|
33 | <code>
|
---|
34 | cat foo|head -n10|grep blee > bar
|
---|
35 | </code><p>
|
---|
36 | Ant was not flexible enough. There was no way for the
|
---|
37 | <code><copy></code> task to do something similar. If you wanted
|
---|
38 | the <code><copy></code> task to get the first 10 lines, you would have
|
---|
39 | had to create special attributes:<p>
|
---|
40 | <code>
|
---|
41 | <copy file="foo" tofile="bar" head="10" contains="blee"/>
|
---|
42 | </code><p>
|
---|
43 | The obvious problem thus surfaced: Ant tasks would not be able
|
---|
44 | to accommodate such data transformation attributes as they would
|
---|
45 | be endless. The task would also not know in which order these
|
---|
46 | attributes were to be interpreted. That is, must the task execute the
|
---|
47 | contains attribute first and then the head attribute or vice-versa?
|
---|
48 | What Ant tasks needed was a mechanism to allow pluggable filter (data
|
---|
49 | transformer) chains. Ant would provide a few filters for which there
|
---|
50 | have been repeated requests. Users with special filtering needs
|
---|
51 | would be able to easily write their own and plug them in.<p>
|
---|
52 |
|
---|
53 | The solution was to refactor data transformation oriented
|
---|
54 | tasks to support FilterChains. A FilterChain is a group of
|
---|
55 | ordered FilterReaders. Users can define their own FilterReaders
|
---|
56 | by just extending the java.io.FilterReader class. Such custom
|
---|
57 | FilterReaders can be easily plugged in as nested elements of
|
---|
58 | <code><filterchain></code> by using <code><filterreader></code> elements.
|
---|
59 | <p>
|
---|
60 | Example:
|
---|
61 | <blockquote><pre>
|
---|
62 | <copy file="${src.file}" tofile="${dest.file}">
|
---|
63 | <filterchain>
|
---|
64 | <filterreader classname="your.extension.of.java.io.FilterReader">
|
---|
65 | <param name="foo" value="bar"/>
|
---|
66 | </filterreader>
|
---|
67 | <filterreader classname="another.extension.of.java.io.FilterReader">
|
---|
68 | <classpath>
|
---|
69 | <pathelement path="${classpath}"/>
|
---|
70 | </classpath>
|
---|
71 | <param name="blah" value="blee"/>
|
---|
72 | <param type="abra" value="cadabra"/>
|
---|
73 | </filterreader>
|
---|
74 | </filterchain>
|
---|
75 | </copy>
|
---|
76 | </pre></blockquote>
|
---|
77 |
|
---|
78 | Ant provides some built-in filter readers. These filter readers
|
---|
79 | can also be declared using a syntax similar to the above syntax.
|
---|
80 | However, they can be declared using some simpler syntax also.<p>
|
---|
81 | Example:
|
---|
82 | <blockquote><pre>
|
---|
83 | <loadfile srcfile="${src.file}" property="src.file.head">
|
---|
84 | <filterchain>
|
---|
85 | <headfilter lines="15"/>
|
---|
86 | </filterchain>
|
---|
87 | </loadfile>
|
---|
88 | </pre></blockquote>
|
---|
89 | is equivalent to:
|
---|
90 | <blockquote><pre>
|
---|
91 | <loadfile srcfile="${src.file}" property="src.file.head">
|
---|
92 | <filterchain>
|
---|
93 | <filterreader classname="org.apache.tools.ant.filters.HeadFilter">
|
---|
94 | <param name="lines" value="15"/>
|
---|
95 | </filterreader>
|
---|
96 | </filterchain>
|
---|
97 | </loadfile>
|
---|
98 | </pre></blockquote>
|
---|
99 |
|
---|
100 | The following built-in tasks support nested <code><filterchain></code> elements.<br>
|
---|
101 | <a href="../CoreTasks/concat.html">Concat</a>,<br>
|
---|
102 | <a href="../CoreTasks/copy.html">Copy</a>,<br>
|
---|
103 | <a href="../CoreTasks/loadfile.html">LoadFile</a>,<br>
|
---|
104 | <a href="../CoreTasks/loadproperties.html">LoadProperties</a>,<br>
|
---|
105 | <a href="../CoreTasks/move.html">Move</a><br><br>
|
---|
106 |
|
---|
107 | A FilterChain is formed by defining zero or more of the following
|
---|
108 | nested elements.<br>
|
---|
109 | <a href="#filterreader">FilterReader</a><br>
|
---|
110 | <a href="#classconstants">ClassConstants</a><br>
|
---|
111 | <a href="#escapeunicode">EscapeUnicode</a><br>
|
---|
112 | <a href="#expandproperties">ExpandProperties</a><br>
|
---|
113 | <a href="#headfilter">HeadFilter</a><br>
|
---|
114 | <a href="#linecontains">LineContains</a><br>
|
---|
115 | <a href="#linecontainsregexp">LineContainsRegExp</a><br>
|
---|
116 | <a href="#prefixlines">PrefixLines</a><br>
|
---|
117 | <a href="#replacetokens">ReplaceTokens</a><br>
|
---|
118 | <a href="#stripjavacomments">StripJavaComments</a><br>
|
---|
119 | <a href="#striplinebreaks">StripLineBreaks</a><br>
|
---|
120 | <a href="#striplinecomments">StripLineComments</a><br>
|
---|
121 | <a href="#tabstospaces">TabsToSpaces</a><br>
|
---|
122 | <a href="#tailfilter">TailFilter</a><br>
|
---|
123 | <a href="#deletecharacters">DeleteCharacters</a><br>
|
---|
124 | <a href="#concatfilter">ConcatFilter</a><br>
|
---|
125 | <a href="#tokenfilter">TokenFilter</a><br>
|
---|
126 | <a href="../CoreTasks/fixcrlf.html">FixCRLF</a><br>
|
---|
127 |
|
---|
128 | <h3><a name="filterreader">FilterReader</a></h3>
|
---|
129 |
|
---|
130 | The filterreader element is the generic way to
|
---|
131 | define a filter. User defined filter elements are
|
---|
132 | defined in the build file using this. Please note that
|
---|
133 | built in filter readers can also be defined using this
|
---|
134 | syntax.
|
---|
135 |
|
---|
136 | A FilterReader element must be supplied with a class name as
|
---|
137 | an attribute value. The class resolved by this name must
|
---|
138 | extend java.io.FilterReader. If the custom filter reader
|
---|
139 | needs to be parameterized, it must implement
|
---|
140 | org.apache.tools.type.Parameterizable.
|
---|
141 |
|
---|
142 | <table cellSpacing=0 cellPadding=2 border=1>
|
---|
143 | <tr>
|
---|
144 | <td vAlign=top><b>Attribute</b></td>
|
---|
145 | <td vAlign=top><b>Description</b></td>
|
---|
146 | <td vAlign=top align="center"><b>Required</b></td>
|
---|
147 | </tr>
|
---|
148 | <tr>
|
---|
149 | <td vAlign=top>classname</td>
|
---|
150 | <td vAlign=top>The class name of the filter reader.</td>
|
---|
151 | <td vAlign=top align="center">Yes</td>
|
---|
152 | </tr>
|
---|
153 | </table>
|
---|
154 |
|
---|
155 | <p>
|
---|
156 | <h4>Nested Elements:</h4>
|
---|
157 | <code><filterreader></code> supports <code><classpath></code> and <code><param></code>
|
---|
158 | as nested elements. Each <code><param></code> element may take in the following
|
---|
159 | attributes - name, type and value.
|
---|
160 | <p>
|
---|
161 | The following FilterReaders are supplied with the default
|
---|
162 | distribution.
|
---|
163 |
|
---|
164 | <h3><a name="classconstants">ClassConstants</a></h3>
|
---|
165 | <p>
|
---|
166 | This filters basic constants defined in a Java Class,
|
---|
167 | and outputs them in lines composed of the format <i>name</i>=<i>value</i>.
|
---|
168 | This filter uses the <em>bcel</em> library to understand the Java Class file.
|
---|
169 | See <a href="../install.html#librarydependencies">Library Dependencies</a>.
|
---|
170 | <p>
|
---|
171 | <p>
|
---|
172 | <em><b>Important:</b></em>
|
---|
173 | This filter is different from most of the other filters.
|
---|
174 | Most of the filters operate on a sequence of characters.
|
---|
175 | This filter operates on the sequence of bytes that makes up
|
---|
176 | a class. However the bytes arrive to the filter as a sequence
|
---|
177 | of characters. This means that one must be careful on the
|
---|
178 | choice of character encoding to use. Most encoding lose information
|
---|
179 | on conversion from an arbitary sequence of bytes to characters
|
---|
180 | and back again to bytes. In particular the usual default
|
---|
181 | character encodings (CP152 and UTF-8) do.
|
---|
182 | For this reason, <em>since Ant 1.7</em>, the character
|
---|
183 | encoding <b>ISO-8859-1</b> is used to convert from characters back to
|
---|
184 | bytes, so one <b>has</b> to use this encoding for reading the java
|
---|
185 | class file.
|
---|
186 | <h4>Example:</h4>
|
---|
187 |
|
---|
188 | This loads the basic constants defined in a Java class as Ant properties.
|
---|
189 |
|
---|
190 | <blockquote><pre>
|
---|
191 | <loadproperties srcfile="foo.class" encoding="ISO-8859-1">
|
---|
192 | <filterchain>
|
---|
193 | <classconstants/>
|
---|
194 | </filterchain>
|
---|
195 | </loadproperties>
|
---|
196 | </pre></blockquote>
|
---|
197 |
|
---|
198 | This loads the constants from a Java class file as Ant properties,
|
---|
199 | prepending the names with a prefix.
|
---|
200 |
|
---|
201 | <blockquote><pre>
|
---|
202 | <loadproperties srcfile="build/classes/org/acme/bar.class"
|
---|
203 | encoding="ISO-8859-1">
|
---|
204 | <filterchain>
|
---|
205 | <classconstants/>
|
---|
206 | <prefixlines prefix="ini."/>
|
---|
207 | </filterchain>
|
---|
208 | </loadproperties>
|
---|
209 | </pre></blockquote>
|
---|
210 | <h3><a name="escapeunicode">EscapeUnicode</a></h3>
|
---|
211 | <p>
|
---|
212 | This filter converts its input by changing all non US-ASCII characters
|
---|
213 | into their equivalent unicode escape backslash u plus 4 digits.</p>
|
---|
214 |
|
---|
215 | <p><em>since Ant 1.6</em></p>
|
---|
216 |
|
---|
217 | <h4>Example:</h4>
|
---|
218 |
|
---|
219 | This loads the basic constants defined in a Java class as Ant properties.
|
---|
220 | <blockquote><pre>
|
---|
221 | <loadproperties srcfile="non_ascii_property.properties">
|
---|
222 | <filterchain>
|
---|
223 | <filterreader classname="org.apache.tools.ant.filters.EscapeUnicode"/>
|
---|
224 | </filterchain>
|
---|
225 | </loadproperties>
|
---|
226 | </pre></blockquote>
|
---|
227 |
|
---|
228 | Convenience method:
|
---|
229 | <blockquote><pre>
|
---|
230 | <loadproperties srcfile="non_ascii_property.properties">
|
---|
231 | <filterchain>
|
---|
232 | <escapeunicode/>
|
---|
233 | </filterchain>
|
---|
234 | </loadproperties>
|
---|
235 | </pre></blockquote>
|
---|
236 |
|
---|
237 | <h3><a name="expandproperties">ExpandProperties</a></h3>
|
---|
238 | <p>
|
---|
239 | If the data contains data that represents Ant
|
---|
240 | properties (of the form ${...}), that is substituted
|
---|
241 | with the property's actual value.
|
---|
242 | <p>
|
---|
243 | <h4>Example:</h4>
|
---|
244 |
|
---|
245 | This results in the property modifiedmessage holding the value
|
---|
246 | "All these moments will be lost in time, like teardrops in the rain"
|
---|
247 | <blockquote><pre>
|
---|
248 | <echo
|
---|
249 | message="All these moments will be lost in time, like teardrops in the ${weather}"
|
---|
250 | file="loadfile1.tmp"
|
---|
251 | />
|
---|
252 | <property name="weather" value="rain"/>
|
---|
253 | <loadfile property="modifiedmessage" srcFile="loadfile1.tmp">
|
---|
254 | <filterchain>
|
---|
255 | <filterreader classname="org.apache.tools.ant.filters.ExpandProperties"/>
|
---|
256 | </filterchain>
|
---|
257 | </loadfile>
|
---|
258 | </pre></blockquote>
|
---|
259 |
|
---|
260 | Convenience method:
|
---|
261 | <blockquote><pre>
|
---|
262 | <echo
|
---|
263 | message="All these moments will be lost in time, like teardrops in the ${weather}"
|
---|
264 | file="loadfile1.tmp"
|
---|
265 | />
|
---|
266 | <property name="weather" value="rain"/>
|
---|
267 | <loadfile property="modifiedmessage" srcFile="loadfile1.tmp">
|
---|
268 | <filterchain>
|
---|
269 | <expandproperties/>
|
---|
270 | </filterchain>
|
---|
271 | </loadfile>
|
---|
272 | </pre></blockquote>
|
---|
273 |
|
---|
274 | <h3><a name="headfilter">HeadFilter</a></h3>
|
---|
275 |
|
---|
276 | This filter reads the first few lines from the data supplied to it.
|
---|
277 |
|
---|
278 | <table cellSpacing=0 cellPadding=2 border=1>
|
---|
279 | <tr>
|
---|
280 | <td vAlign=top><b>Parameter Name</b></td>
|
---|
281 | <td vAlign=top><b>Parameter Value</b></td>
|
---|
282 | <td vAlign=top align="center"><b>Required</b></td>
|
---|
283 | </tr>
|
---|
284 | <tr>
|
---|
285 | <td vAlign=top>lines</td>
|
---|
286 | <td vAlign=top align="center">Number of lines to be read.
|
---|
287 | Defaults to "10" <br> A negative value means that all lines are
|
---|
288 | passed (useful with <i>skip</i>)</td>
|
---|
289 | <td vAlign=top align="center">No</td>
|
---|
290 | </tr>
|
---|
291 | <tr>
|
---|
292 | <td vAlign=top>skip</td>
|
---|
293 | <td vAlign=top align="center">Number of lines to be skipped (from the beginning).
|
---|
294 | Defaults to "0"</td>
|
---|
295 | <td vAlign=top align="center">No</td>
|
---|
296 | </tr>
|
---|
297 | </table>
|
---|
298 | <p>
|
---|
299 | <h4>Example:</h4>
|
---|
300 |
|
---|
301 | This stores the first 15 lines of the supplied data in the property src.file.head
|
---|
302 | <blockquote><pre>
|
---|
303 | <loadfile srcfile="${src.file}" property="src.file.head">
|
---|
304 | <filterchain>
|
---|
305 | <filterreader classname="org.apache.tools.ant.filters.HeadFilter">
|
---|
306 | <param name="lines" value="15"/>
|
---|
307 | </filterreader>
|
---|
308 | </filterchain>
|
---|
309 | </loadfile>
|
---|
310 | </pre></blockquote>
|
---|
311 |
|
---|
312 | Convenience method:
|
---|
313 | <blockquote><pre>
|
---|
314 | <loadfile srcfile="${src.file}" property="src.file.head">
|
---|
315 | <filterchain>
|
---|
316 | <headfilter lines="15"/>
|
---|
317 | </filterchain>
|
---|
318 | </loadfile>
|
---|
319 | </pre></blockquote>
|
---|
320 |
|
---|
321 | This stores the first 15 lines, skipping the first 2 lines, of the supplied data
|
---|
322 | in the property src.file.head. (Means: lines 3-17)
|
---|
323 | <blockquote><pre>
|
---|
324 | <loadfile srcfile="${src.file}" property="src.file.head">
|
---|
325 | <filterchain>
|
---|
326 | <headfilter lines="15" skip="2"/>
|
---|
327 | </filterchain>
|
---|
328 | </loadfile>
|
---|
329 | </pre></blockquote>
|
---|
330 |
|
---|
331 | See the testcases for more examples (<i>src\etc\testcases\filters\head-tail.xml</i> in the
|
---|
332 | source distribution).
|
---|
333 |
|
---|
334 | <h3><a name="linecontains">LineContains</a></h3>
|
---|
335 |
|
---|
336 | This filter includes only those lines that contain all the user-specified
|
---|
337 | strings.
|
---|
338 |
|
---|
339 | <table cellSpacing=0 cellPadding=2 border=1>
|
---|
340 | <tr>
|
---|
341 | <td vAlign=top><b>Parameter Type</b></td>
|
---|
342 | <td vAlign=top><b>Parameter Value</b></td>
|
---|
343 | <td vAlign=top align="center"><b>Required</b></td>
|
---|
344 | </tr>
|
---|
345 | <tr>
|
---|
346 | <td vAlign=top>contains</td>
|
---|
347 | <td vAlign=top align="center">Substring to be searched for.</td>
|
---|
348 | <td vAlign=top align="center">Yes</td>
|
---|
349 | </tr>
|
---|
350 | <tr>
|
---|
351 | <td vAlign=top>negate</td>
|
---|
352 | <td vAlign=top align="center">Whether to select
|
---|
353 | <i>non-</i>matching lines only. <b>Since Ant 1.7</b></td>
|
---|
354 | <td vAlign=top align="center">No</td>
|
---|
355 | </tr>
|
---|
356 | </table>
|
---|
357 | <p>
|
---|
358 | <h4>Example:</h4>
|
---|
359 |
|
---|
360 | This will include only those lines that contain <code>foo</code> and
|
---|
361 | <code>bar</code>.
|
---|
362 | <blockquote><pre>
|
---|
363 | <filterreader classname="org.apache.tools.ant.filters.LineContains">
|
---|
364 | <param type="contains" value="foo"/>
|
---|
365 | <param type="contains" value="bar"/>
|
---|
366 | </filterreader>
|
---|
367 | </pre></blockquote>
|
---|
368 |
|
---|
369 | Convenience method:
|
---|
370 | <blockquote><pre>
|
---|
371 | <linecontains>
|
---|
372 | <contains value="foo"/>
|
---|
373 | <contains value="bar"/>
|
---|
374 | </linecontains>
|
---|
375 | </pre></blockquote>
|
---|
376 |
|
---|
377 | Negation:
|
---|
378 | <blockquote><pre>
|
---|
379 | <filterreader classname="org.apache.tools.ant.filters.LineContains">
|
---|
380 | <param type="negate" value="true"/>
|
---|
381 | <param type="contains" value="foo"/>
|
---|
382 | <param type="contains" value="bar"/>
|
---|
383 | </filterreader>
|
---|
384 | </pre></blockquote>
|
---|
385 | <i>or</i>
|
---|
386 | <blockquote><pre>
|
---|
387 | <linecontains negate="true">
|
---|
388 | <contains value="foo"/>
|
---|
389 | <contains value="bar"/>
|
---|
390 | </linecontains>
|
---|
391 | </pre></blockquote>
|
---|
392 |
|
---|
393 | <h3><a name="linecontainsregexp">LineContainsRegExp</a></h3>
|
---|
394 |
|
---|
395 | Filter which includes only those lines that contain the user-specified
|
---|
396 | regular expression matching strings.
|
---|
397 |
|
---|
398 | <table cellSpacing=0 cellPadding=2 border=1>
|
---|
399 | <tr>
|
---|
400 | <td vAlign=top><b>Parameter Type</b></td>
|
---|
401 | <td vAlign=top><b>Parameter Value</b></td>
|
---|
402 | <td vAlign=top align="center"><b>Required</b></td>
|
---|
403 | </tr>
|
---|
404 | <tr>
|
---|
405 | <td vAlign=top>regexp</td>
|
---|
406 | <td vAlign=top align="center">Regular expression to be searched for.</td>
|
---|
407 | <td vAlign=top align="center">Yes</td>
|
---|
408 | </tr>
|
---|
409 | <tr>
|
---|
410 | <td vAlign=top>negate</td>
|
---|
411 | <td vAlign=top align="center">Whether to select
|
---|
412 | <i>non-</i>matching lines only. <b>Since Ant 1.7</b></td>
|
---|
413 | <td vAlign=top align="center">No</td>
|
---|
414 | </tr>
|
---|
415 | </table>
|
---|
416 |
|
---|
417 | See <a href="regexp.html">Regexp Type</a> for the description of the nested element regexp and of
|
---|
418 | the choice of regular expression implementation.
|
---|
419 | <h4>Example:</h4>
|
---|
420 |
|
---|
421 | This will fetch all those lines that contain the pattern <code>foo</code>
|
---|
422 | <blockquote><pre>
|
---|
423 | <filterreader classname="org.apache.tools.ant.filters.LineContainsRegExp">
|
---|
424 | <param type="regexp" value="foo*"/>
|
---|
425 | </filterreader>
|
---|
426 | </pre></blockquote>
|
---|
427 |
|
---|
428 | Convenience method:
|
---|
429 | <blockquote><pre>
|
---|
430 | <linecontainsregexp>
|
---|
431 | <regexp pattern="foo*"/>
|
---|
432 | </linecontainsregexp>
|
---|
433 | </pre></blockquote>
|
---|
434 |
|
---|
435 | Negation:
|
---|
436 | <blockquote><pre>
|
---|
437 | <filterreader classname="org.apache.tools.ant.filters.LineContainsRegExp">
|
---|
438 | <param type="negate" value="true"/>
|
---|
439 | <param type="regexp" value="foo*"/>
|
---|
440 | </filterreader>
|
---|
441 | </pre></blockquote>
|
---|
442 | <i>or</i>
|
---|
443 | <blockquote><pre>
|
---|
444 | <linecontainsregexp negate="true">
|
---|
445 | <regexp pattern="foo*"/>
|
---|
446 | </linecontainsregexp>
|
---|
447 | </pre></blockquote>
|
---|
448 |
|
---|
449 | <h3><a name="prefixlines">PrefixLines</a></h3>
|
---|
450 |
|
---|
451 | Attaches a prefix to every line.
|
---|
452 |
|
---|
453 | <table cellSpacing=0 cellPadding=2 border=1>
|
---|
454 | <tr>
|
---|
455 | <td vAlign=top><b>Parameter Name</b></td>
|
---|
456 | <td vAlign=top><b>Parameter Value</b></td>
|
---|
457 | <td vAlign=top align="center"><b>Required</b></td>
|
---|
458 | </tr>
|
---|
459 | <tr>
|
---|
460 | <td vAlign=top>prefix</td>
|
---|
461 | <td vAlign=top align="center">Prefix to be attached to lines.</td>
|
---|
462 | <td vAlign=top align="center">Yes</td>
|
---|
463 | </tr>
|
---|
464 | </table>
|
---|
465 | <p>
|
---|
466 | <h4>Example:</h4>
|
---|
467 |
|
---|
468 | This will attach the prefix <code>Foo</code> to all lines.
|
---|
469 | <blockquote><pre>
|
---|
470 | <filterreader classname="org.apache.tools.ant.filters.PrefixLines">
|
---|
471 | <param name="prefix" value="Foo"/>
|
---|
472 | </filterreader>
|
---|
473 | </pre></blockquote>
|
---|
474 |
|
---|
475 | Convenience method:
|
---|
476 | <blockquote><pre>
|
---|
477 | <prefixlines prefix="Foo"/>
|
---|
478 | </pre></blockquote>
|
---|
479 |
|
---|
480 | <h3><a name="replacetokens">ReplaceTokens</a></h3>
|
---|
481 |
|
---|
482 | This filter reader replaces all strings that are
|
---|
483 | sandwiched between begintoken and endtoken with
|
---|
484 | user defined values.
|
---|
485 |
|
---|
486 | <table cellSpacing=0 cellPadding=2 border=1>
|
---|
487 | <tr>
|
---|
488 | <td vAlign=top><b>Parameter Type</b></td>
|
---|
489 | <td vAlign=top><b>Parameter Name</b></td>
|
---|
490 | <td vAlign=top><b>Parameter Value</b></td>
|
---|
491 | <td vAlign=top align="center"><b>Required</b></td>
|
---|
492 | </tr>
|
---|
493 | <tr>
|
---|
494 | <td vAlign=top>tokenchar</td>
|
---|
495 | <td vAlign=top>begintoken</td>
|
---|
496 | <td vAlign=top>Character marking the
|
---|
497 | beginning of a token. Defaults to @</td>
|
---|
498 | <td vAlign=top align="center">No</td>
|
---|
499 | </tr>
|
---|
500 | <tr>
|
---|
501 | <td vAlign=top>tokenchar</td>
|
---|
502 | <td vAlign=top>endtoken</td>
|
---|
503 | <td vAlign=top>Character marking the
|
---|
504 | end of a token. Defaults to @</td>
|
---|
505 | <td vAlign=top align="center">No</td>
|
---|
506 | </tr>
|
---|
507 | <tr>
|
---|
508 | <td vAlign=top>token</td>
|
---|
509 | <td vAlign=top>User defined String.</td>
|
---|
510 | <td vAlign=top>User defined search String.</td>
|
---|
511 | <td vAlign=top align="center">Yes</td>
|
---|
512 | </tr>
|
---|
513 | <tr>
|
---|
514 | <td vAlign=top>propertiesfile</td>
|
---|
515 | <td vAlign=top>Not applicable.</td>
|
---|
516 | <td vAlign=top>Properties file to take tokens from.</td>
|
---|
517 | <td vAlign=top align="center">No</td>
|
---|
518 | </tr>
|
---|
519 | </table>
|
---|
520 | <p>
|
---|
521 |
|
---|
522 | <h4>Example:</h4>
|
---|
523 |
|
---|
524 | This replaces occurrences of the string @DATE@ in the data
|
---|
525 | with today's date and stores it in the property ${src.file.replaced}
|
---|
526 | <blockquote><pre>
|
---|
527 | <tstamp/>
|
---|
528 | <loadfile srcfile="${src.file}" property="${src.file.replaced}">
|
---|
529 | <filterchain>
|
---|
530 | <filterreader classname="org.apache.tools.ant.filters.ReplaceTokens">
|
---|
531 | <param type="token" name="DATE" value="${TODAY}"/>
|
---|
532 | </filterreader>
|
---|
533 | </filterchain>
|
---|
534 | </loadfile>
|
---|
535 | </pre></blockquote>
|
---|
536 |
|
---|
537 | Convenience method:
|
---|
538 | <blockquote><pre>
|
---|
539 | <tstamp/>
|
---|
540 | <loadfile srcfile="${src.file}" property="${src.file.replaced}">
|
---|
541 | <filterchain>
|
---|
542 | <replacetokens>
|
---|
543 | <token key="DATE" value="${TODAY}"/>
|
---|
544 | </replacetokens>
|
---|
545 | </filterchain>
|
---|
546 | </loadfile>
|
---|
547 | </pre></blockquote>
|
---|
548 |
|
---|
549 | This will treat each properties file entry in sample.properties as a token/key pair :
|
---|
550 | <blockquote><pre>
|
---|
551 | <loadfile srcfile="${src.file}" property="${src.file.replaced}">
|
---|
552 | <filterchain>
|
---|
553 | <filterreader classname="org.apache.tools.ant.filters.ReplaceTokens">
|
---|
554 | <param type="propertiesfile" value="sample.properties"/>
|
---|
555 | </filterreader>
|
---|
556 | </filterchain>
|
---|
557 | </loadfile>
|
---|
558 | </filterchain>
|
---|
559 | </pre></blockquote>
|
---|
560 |
|
---|
561 | <h3><a name="stripjavacomments">StripJavaComments</a></h3>
|
---|
562 |
|
---|
563 | This filter reader strips away comments from the data,
|
---|
564 | using Java syntax guidelines. This filter does not
|
---|
565 | take in any parameters.
|
---|
566 | <p>
|
---|
567 | <h4>Example:</h4>
|
---|
568 |
|
---|
569 | <blockquote><pre>
|
---|
570 | <loadfile srcfile="${java.src.file}" property="${java.src.file.nocomments}">
|
---|
571 | <filterchain>
|
---|
572 | <filterreader classname="org.apache.tools.ant.filters.StripJavaComments"/>
|
---|
573 | </filterchain>
|
---|
574 | </loadfile>
|
---|
575 | </pre></blockquote>
|
---|
576 |
|
---|
577 | Convenience method:
|
---|
578 | <blockquote><pre>
|
---|
579 | <loadfile srcfile="${java.src.file}" property="${java.src.file.nocomments}">
|
---|
580 | <filterchain>
|
---|
581 | <stripjavacomments/>
|
---|
582 | </filterchain>
|
---|
583 | </loadfile>
|
---|
584 | </pre></blockquote>
|
---|
585 |
|
---|
586 | <h3><a name="striplinebreaks">StripLineBreaks</a></h3>
|
---|
587 |
|
---|
588 | This filter reader strips away specific characters
|
---|
589 | from the data supplied to it.
|
---|
590 |
|
---|
591 | <table cellSpacing=0 cellPadding=2 border=1>
|
---|
592 | <tr>
|
---|
593 | <td vAlign=top><b>Parameter Name</b></td>
|
---|
594 | <td vAlign=top><b>Parameter Value</b></td>
|
---|
595 | <td vAlign=top align="center"><b>Required</b></td>
|
---|
596 | </tr>
|
---|
597 | <tr>
|
---|
598 | <td vAlign=top>linebreaks</td>
|
---|
599 | <td vAlign=top align="center">Characters that are to
|
---|
600 | be stripped out. Defaults to "\r\n"</td>
|
---|
601 | <td vAlign=top align="center">No</td>
|
---|
602 | </tr>
|
---|
603 | </table>
|
---|
604 | <p>
|
---|
605 | <h4>Examples:</h4>
|
---|
606 |
|
---|
607 | This strips the '\r' and '\n' characters.
|
---|
608 | <blockquote><pre>
|
---|
609 | <loadfile srcfile="${src.file}" property="${src.file.contents}">
|
---|
610 | <filterchain>
|
---|
611 | <filterreader classname="org.apache.tools.ant.filters.StripLineBreaks"/>
|
---|
612 | </filterchain>
|
---|
613 | </loadfile>
|
---|
614 | </pre></blockquote>
|
---|
615 |
|
---|
616 | Convenience method:
|
---|
617 | <blockquote><pre>
|
---|
618 | <loadfile srcfile="${src.file}" property="${src.file.contents}">
|
---|
619 | <filterchain>
|
---|
620 | <striplinebreaks/>
|
---|
621 | </filterchain>
|
---|
622 | </loadfile>
|
---|
623 | </pre></blockquote>
|
---|
624 |
|
---|
625 | This treats the '(' and ')' characters as line break characters and
|
---|
626 | strips them.
|
---|
627 | <blockquote><pre>
|
---|
628 | <loadfile srcfile="${src.file}" property="${src.file.contents}">
|
---|
629 | <filterchain>
|
---|
630 | <filterreader classname="org.apache.tools.ant.filters.StripLineBreaks">
|
---|
631 | <param name="linebreaks" value="()"/>
|
---|
632 | </filterreader>
|
---|
633 | </filterchain>
|
---|
634 | </loadfile>
|
---|
635 | </pre></blockquote>
|
---|
636 |
|
---|
637 | <h3><a name="striplinecomments">StripLineComments</a></h3>
|
---|
638 |
|
---|
639 | This filter removes all those lines that begin with strings
|
---|
640 | that represent comments as specified by the user.
|
---|
641 |
|
---|
642 | <table cellSpacing=0 cellPadding=2 border=1>
|
---|
643 | <tr>
|
---|
644 | <td vAlign=top><b>Parameter Type</b></td>
|
---|
645 | <td vAlign=top><b>Parameter Value</b></td>
|
---|
646 | <td vAlign=top align="center"><b>Required</b></td>
|
---|
647 | </tr>
|
---|
648 | <tr>
|
---|
649 | <td vAlign=top>comment</td>
|
---|
650 | <td vAlign=top align="center">Strings that identify a line as a comment
|
---|
651 | when they appear at the start of the line.</td>
|
---|
652 | <td vAlign=top align="center">Yes</td>
|
---|
653 | </tr>
|
---|
654 | </table>
|
---|
655 | <p>
|
---|
656 | <h4>Examples:</h4>
|
---|
657 |
|
---|
658 | This removes all lines that begin with #, --, REM, rem and //
|
---|
659 | <blockquote><pre>
|
---|
660 | <filterreader classname="org.apache.tools.ant.filters.StripLineComments">
|
---|
661 | <param type="comment" value="#"/>
|
---|
662 | <param type="comment" value="--"/>
|
---|
663 | <param type="comment" value="REM "/>
|
---|
664 | <param type="comment" value="rem "/>
|
---|
665 | <param type="comment" value="//"/>
|
---|
666 | </filterreader>
|
---|
667 | </pre></blockquote>
|
---|
668 |
|
---|
669 | Convenience method:
|
---|
670 | <blockquote><pre>
|
---|
671 | <striplinecomments>
|
---|
672 | <comment value="#"/>
|
---|
673 | <comment value="--"/>
|
---|
674 | <comment value="REM "/>
|
---|
675 | <comment value="rem "/>
|
---|
676 | <comment value="//"/>
|
---|
677 | </striplinecomments>
|
---|
678 | </pre></blockquote>
|
---|
679 |
|
---|
680 | <h3><a name="tabstospaces">TabsToSpaces</a></h3>
|
---|
681 |
|
---|
682 | This filter replaces tabs with spaces
|
---|
683 |
|
---|
684 | <table cellSpacing=0 cellPadding=2 border=1>
|
---|
685 | <tr>
|
---|
686 | <td vAlign=top><b>Parameter Name</b></td>
|
---|
687 | <td vAlign=top><b>Parameter Value</b></td>
|
---|
688 | <td vAlign=top align="center"><b>Required</b></td>
|
---|
689 | </tr>
|
---|
690 | <tr>
|
---|
691 | <td vAlign=top>tablength</td>
|
---|
692 | <td vAlign=top align="center">Defaults to "8"</td>
|
---|
693 | <td vAlign=top align="center">No</td>
|
---|
694 | </tr>
|
---|
695 | </table>
|
---|
696 | <p>
|
---|
697 | <h4>Examples:</h4>
|
---|
698 |
|
---|
699 | This replaces tabs in ${src.file} with spaces.
|
---|
700 | <blockquote><pre>
|
---|
701 | <loadfile srcfile="${src.file}" property="${src.file.notab}">
|
---|
702 | <filterchain>
|
---|
703 | <filterreader classname="org.apache.tools.ant.filters.TabsToSpaces"/>
|
---|
704 | </filterchain>
|
---|
705 | </loadfile>
|
---|
706 | </pre></blockquote>
|
---|
707 |
|
---|
708 | Convenience method:
|
---|
709 | <blockquote><pre>
|
---|
710 | <loadfile srcfile="${src.file}" property="${src.file.notab}">
|
---|
711 | <filterchain>
|
---|
712 | <tabstospaces/>
|
---|
713 | </filterchain>
|
---|
714 | </loadfile>
|
---|
715 | </pre></blockquote>
|
---|
716 |
|
---|
717 | <h3><a name="tailfilter">TailFilter</a></h3>
|
---|
718 |
|
---|
719 | This filter reads the last few lines from the data supplied to it.
|
---|
720 |
|
---|
721 | <table cellSpacing=0 cellPadding=2 border=1>
|
---|
722 | <tr>
|
---|
723 | <td vAlign=top><b>Parameter Name</b></td>
|
---|
724 | <td vAlign=top><b>Parameter Value</b></td>
|
---|
725 | <td vAlign=top align="center"><b>Required</b></td>
|
---|
726 | </tr>
|
---|
727 | <tr>
|
---|
728 | <td vAlign=top>lines</td>
|
---|
729 | <td vAlign=top align="center">Number of lines to be read.
|
---|
730 | Defaults to "10" <br> A negative value means that all lines are
|
---|
731 | passed (useful with <i>skip</i>)</td>
|
---|
732 | <td vAlign=top align="center">No</td>
|
---|
733 | </tr>
|
---|
734 | <tr>
|
---|
735 | <td vAlign=top>skip</td>
|
---|
736 | <td vAlign=top align="center">Number of lines to be skipped (from the end).
|
---|
737 | Defaults to "0" </td>
|
---|
738 | <td vAlign=top align="center">No</td>
|
---|
739 | </tr>
|
---|
740 | </table>
|
---|
741 | <p>
|
---|
742 |
|
---|
743 | <h4>Background:</h4>
|
---|
744 | With HeadFilter and TailFilter you can extract each part of a text file you want.
|
---|
745 | This graphic shows the dependencies:
|
---|
746 |
|
---|
747 | <table cellSpacing=0 cellPadding=2 border=1>
|
---|
748 | <tr>
|
---|
749 | <th> Content </th>
|
---|
750 | <th></th>
|
---|
751 | <th></th>
|
---|
752 | <th></th>
|
---|
753 | <th> Filter </th>
|
---|
754 | </tr>
|
---|
755 | <tr>
|
---|
756 | <td> Line 1 </td>
|
---|
757 | <td rowspan="2" bgcolor="#C0C0C0"> </td>
|
---|
758 | <td rowspan="9" bgcolor="#FF00FF"> </td>
|
---|
759 | <td rowspan="4"> </td>
|
---|
760 | <td rowspan="11">
|
---|
761 | <table>
|
---|
762 | <tr>
|
---|
763 | <td bgcolor="#C0C0C0"> </td>
|
---|
764 | <td><pre><filterchain>
|
---|
765 | <headfilter lines="2"/>
|
---|
766 | </filterchain></pre></td>
|
---|
767 | </tr>
|
---|
768 | <tr>
|
---|
769 | <td bgcolor="#FF00FF"> </td>
|
---|
770 | <td><pre><filterchain>
|
---|
771 | <tailfilter lines="-1" skip="2"/>
|
---|
772 | </filterchain></pre></td>
|
---|
773 | </tr>
|
---|
774 | <tr>
|
---|
775 | <td bgcolor="#008000"> </td>
|
---|
776 | <td><pre><filterchain>
|
---|
777 | <headfilter lines="-1" skip="2"/>
|
---|
778 | </filterchain></pre></td>
|
---|
779 | </tr>
|
---|
780 | <tr>
|
---|
781 | <td bgcolor="#0000FF"> </td>
|
---|
782 | <td><pre><filterchain>
|
---|
783 | <headfilter lines="-1" skip="2"/>
|
---|
784 | <tailfilter lines="-1" skip="2"/>
|
---|
785 | </filterchain></pre></td>
|
---|
786 | </tr>
|
---|
787 | <tr>
|
---|
788 | <td bgcolor="#00FF00"> </td>
|
---|
789 | <td><pre><filterchain>
|
---|
790 | <tailfilter lines="2"/>
|
---|
791 | </filterchain></pre></td>
|
---|
792 | </tr>
|
---|
793 | </table>
|
---|
794 | </td>
|
---|
795 | </tr>
|
---|
796 | <tr>
|
---|
797 | <td> Line 2 </td>
|
---|
798 | </tr>
|
---|
799 | <tr>
|
---|
800 | <td> Line 3 </td>
|
---|
801 | <td rowspan="9" bgcolor="#008000"> </td>
|
---|
802 | </tr>
|
---|
803 | <tr>
|
---|
804 | <td> Line 4 </td>
|
---|
805 | </tr>
|
---|
806 | <tr>
|
---|
807 | <td> Line 5 </td>
|
---|
808 | <td rowspan="3" bgcolor="#0000FF"> </td>
|
---|
809 | </tr>
|
---|
810 | <tr>
|
---|
811 | <td> Lines ... </td>
|
---|
812 | </tr>
|
---|
813 | <tr>
|
---|
814 | <td> Line 95 </td>
|
---|
815 | </tr>
|
---|
816 | <tr>
|
---|
817 | <td> Line 96 </td>
|
---|
818 | <td rowspan="4"> </td>
|
---|
819 | </tr>
|
---|
820 | <tr>
|
---|
821 | <td> Line 97 </td>
|
---|
822 | </tr>
|
---|
823 | <tr>
|
---|
824 | <td> Line 98 </td>
|
---|
825 | <td rowspan="2" bgcolor="#00FF00"> </td>
|
---|
826 | </tr>
|
---|
827 | <tr>
|
---|
828 | <td> Line 99 </td>
|
---|
829 | </tr>
|
---|
830 | </table>
|
---|
831 |
|
---|
832 |
|
---|
833 |
|
---|
834 | <h4>Examples:</h4>
|
---|
835 |
|
---|
836 | This stores the last 15 lines of the supplied data in the property ${src.file.tail}
|
---|
837 | <blockquote><pre>
|
---|
838 | <loadfile srcfile="${src.file}" property="${src.file.tail}">
|
---|
839 | <filterchain>
|
---|
840 | <filterreader classname="org.apache.tools.ant.filters.TailFilter">
|
---|
841 | <param name="lines" value="15"/>
|
---|
842 | </filterreader>
|
---|
843 | </filterchain>
|
---|
844 | </loadfile>
|
---|
845 | </pre></blockquote>
|
---|
846 |
|
---|
847 | Convenience method:
|
---|
848 | <blockquote><pre>
|
---|
849 | <loadfile srcfile="${src.file}" property="${src.file.tail}">
|
---|
850 | <filterchain>
|
---|
851 | <tailfilter lines="15"/>
|
---|
852 | </filterchain>
|
---|
853 | </loadfile>
|
---|
854 | </pre></blockquote>
|
---|
855 |
|
---|
856 |
|
---|
857 | This stores the last 5 lines of the first 15 lines of the supplied
|
---|
858 | data in the property ${src.file.mid}
|
---|
859 | <blockquote><pre>
|
---|
860 | <loadfile srcfile="${src.file}" property="${src.file.mid}">
|
---|
861 | <filterchain>
|
---|
862 | <filterreader classname="org.apache.tools.ant.filters.HeadFilter">
|
---|
863 | <param name="lines" value="15"/>
|
---|
864 | </filterreader>
|
---|
865 | <filterreader classname="org.apache.tools.ant.filters.TailFilter">
|
---|
866 | <param name="lines" value="5"/>
|
---|
867 | </filterreader>
|
---|
868 | </filterchain>
|
---|
869 | </loadfile>
|
---|
870 | </pre></blockquote>
|
---|
871 |
|
---|
872 | Convenience method:
|
---|
873 | <blockquote><pre>
|
---|
874 | <loadfile srcfile="${src.file}" property="${src.file.mid}">
|
---|
875 | <filterchain>
|
---|
876 | <headfilter lines="15"/>
|
---|
877 | <tailfilter lines="5"/>
|
---|
878 | </filterchain>
|
---|
879 | </loadfile>
|
---|
880 | </pre></blockquote>
|
---|
881 |
|
---|
882 |
|
---|
883 | This stores the last 10 lines, skipping the last 2 lines, of the supplied data
|
---|
884 | in the property src.file.head. (Means: if supplied data contains 60 lines,
|
---|
885 | lines 49-58 are extracted)
|
---|
886 | <blockquote><pre>
|
---|
887 | <loadfile srcfile="${src.file}" property="src.file.head">
|
---|
888 | <filterchain>
|
---|
889 | <tailfilter lines="10" skip="2"/>
|
---|
890 | </filterchain>
|
---|
891 | </loadfile>
|
---|
892 | </pre></blockquote>
|
---|
893 |
|
---|
894 | <h3><a name="deletecharacters">DeleteCharacters</a></h3>
|
---|
895 |
|
---|
896 | <p>This filter deletes specified characters.</p>
|
---|
897 | <p><em>since Ant 1.6</em></p>
|
---|
898 | <p>This filter is only available in the convenience form.</p>
|
---|
899 |
|
---|
900 | <table cellSpacing=0 cellPadding=2 border=1>
|
---|
901 | <tr>
|
---|
902 | <td vAlign=top><b>Parameter Name</b></td>
|
---|
903 | <td vAlign=top><b>Parameter Value</b></td>
|
---|
904 | <td vAlign=top align="center"><b>Required</b></td>
|
---|
905 | </tr>
|
---|
906 | <tr>
|
---|
907 | <td vAlign=top>chars</td>
|
---|
908 | <td vAlign=top>
|
---|
909 | The characters to delete. This attribute is
|
---|
910 | <a href="#backslash">backslash enabled</a>.
|
---|
911 | </td>
|
---|
912 | <td vAlign=top align="center">Yes</td>
|
---|
913 | </tr>
|
---|
914 | </table>
|
---|
915 | <p>
|
---|
916 | <h4>Examples:</h4>
|
---|
917 |
|
---|
918 | Delete tabs and returns from the data.
|
---|
919 | <blockquote><pre>
|
---|
920 | <deletecharacters chars="\t\r"/>
|
---|
921 | </pre></blockquote>
|
---|
922 |
|
---|
923 | <h3><a name="concatfilter">ConcatFilter</a></h3>
|
---|
924 | <p>This filter prepends or appends the content file to the filtered files.</p>
|
---|
925 | <p><em>since Ant 1.6</em></p>
|
---|
926 | <table cellSpacing=0 cellPadding=2 border=1>
|
---|
927 | <tr>
|
---|
928 | <td vAlign=top><b>Parameter Name</b></td>
|
---|
929 | <td vAlign=top><b>Parameter Value</b></td>
|
---|
930 | <td vAlign=top align="center"><b>Required</b></td>
|
---|
931 | </tr>
|
---|
932 | <tr>
|
---|
933 | <td vAlign=top>prepend</td>
|
---|
934 | <td vAlign=top>
|
---|
935 | The name of the file which content should be prepended to the file.
|
---|
936 | </td>
|
---|
937 | <td vAlign=top align="center">No</td>
|
---|
938 | </tr>
|
---|
939 | <tr>
|
---|
940 | <td vAlign=top>append</td>
|
---|
941 | <td vAlign=top>
|
---|
942 | The name of the file which content should be appended to the file.
|
---|
943 | </td>
|
---|
944 | <td vAlign=top align="center">No</td>
|
---|
945 | </tr>
|
---|
946 | </table>
|
---|
947 | <p>
|
---|
948 |
|
---|
949 | <h4>Examples:</h4>
|
---|
950 |
|
---|
951 | Do nothing:
|
---|
952 | <blockquote><pre>
|
---|
953 | <filterchain>
|
---|
954 | <concatfilter/>
|
---|
955 | </filterchain>
|
---|
956 | </pre></blockquote>
|
---|
957 |
|
---|
958 | Adds a license text before each java source:
|
---|
959 | <blockquote><pre>
|
---|
960 | <filterchain>
|
---|
961 | <concatfilter prepend="apache-license-java.txt"/>
|
---|
962 | </filterchain>
|
---|
963 | </pre></blockquote>
|
---|
964 |
|
---|
965 |
|
---|
966 |
|
---|
967 | <h3><a name="tokenfilter">TokenFilter</a></h3>
|
---|
968 | This filter tokenizes the inputstream into strings and passes these
|
---|
969 | strings to filters of strings. Unlike the other filterreaders, this does
|
---|
970 | not support params, only convenience methods are implemented.
|
---|
971 | The tokenizer and the string filters are defined by nested elements.
|
---|
972 | <p><em>since Ant 1.6</em></p>
|
---|
973 | <p>
|
---|
974 | Only one tokenizer element may be used, the LineTokenizer is the
|
---|
975 | default if none are specified. A tokenizer
|
---|
976 | splits the input into token strings and trailing delimiter strings.
|
---|
977 | <p>
|
---|
978 | There may be zero or more string filters. A string filter processes
|
---|
979 | a token and either returns a string or a null.
|
---|
980 | It the string is not null it is passed to the next filter. This
|
---|
981 | proceeds until all the filters are called.
|
---|
982 | If a string is returned after all the filters, the string is
|
---|
983 | outputs with its associated token delimitier
|
---|
984 | (if one is present).
|
---|
985 | The trailing delimiter may be overridden by the <i>delimOutput</i>
|
---|
986 | attribute.
|
---|
987 | <p>
|
---|
988 | <a name="backslash"><em>blackslash interpretation</em></a>
|
---|
989 | A number of attributes (including <i>delimOutput</i>) interpret
|
---|
990 | backslash escapes. The following are understood: \n, \r, \f, \t
|
---|
991 | and \\.
|
---|
992 |
|
---|
993 |
|
---|
994 | <table cellSpacing=0 cellPadding=2 border=1>
|
---|
995 | <tr>
|
---|
996 | <td vAlign=top><b>Attribute</b></td>
|
---|
997 | <td vAlign=top><b>Description</b></td>
|
---|
998 | <td vAlign=top align="center"><b>Required</b></td>
|
---|
999 | </tr>
|
---|
1000 | <tr>
|
---|
1001 | <td vAlign=top>delimOutput</td>
|
---|
1002 | <td vAlign=top>
|
---|
1003 | This overrides the tokendelimiter
|
---|
1004 | returned by the tokenizer if it is not empty. This
|
---|
1005 | attribute is backslash enabled.
|
---|
1006 | </td>
|
---|
1007 | <td vAlign=top align="center">No</td>
|
---|
1008 | </tr>
|
---|
1009 | </table>
|
---|
1010 | <p>
|
---|
1011 |
|
---|
1012 | The following tokenizers are provided by the default distribution.
|
---|
1013 | <p>
|
---|
1014 | <a href="#linetokenizer">LineTokenizer</a><br>
|
---|
1015 | <a href="#filetokenizer">FileTokenizer</a><br>
|
---|
1016 | <a href="#stringtokenizer">StringTokenizer</a><br>
|
---|
1017 | </p>
|
---|
1018 |
|
---|
1019 | The following string filters are provided by the default distribution.
|
---|
1020 | <p>
|
---|
1021 | <a href="#replacestring">ReplaceString</a><br>
|
---|
1022 | <a href="#containsstring">ContainsString</a><br>
|
---|
1023 | <a href="#replaceregex">ReplaceRegex</a><br>
|
---|
1024 | <a href="#containsregex">ContainsRegex</a><br>
|
---|
1025 | <a href="#trim">Trim</a><br>
|
---|
1026 | <a href="#ignoreblank">IgnoreBlank</a><br>
|
---|
1027 | <a href="#filterdeletecharacters">DeleteCharacters</a><br>
|
---|
1028 | </p>
|
---|
1029 |
|
---|
1030 | The following string filters are provided by the optional distribution.
|
---|
1031 | <p>
|
---|
1032 | <a href="#scriptfilter">ScriptFilter</a><br>
|
---|
1033 | </p>
|
---|
1034 |
|
---|
1035 | Some of the filters may be used directly within a filter chain. In this
|
---|
1036 | case a tokenfilter is created implicitly. An extra attribute "byline"
|
---|
1037 | is added to the filter to specify whether to use a linetokenizer
|
---|
1038 | (byline="true") or a filetokenizer (byline="false"). The default
|
---|
1039 | is "true".
|
---|
1040 | <p>
|
---|
1041 |
|
---|
1042 | <p><b><em><a name="linetokenizer">LineTokenizer</a></em></b></p>
|
---|
1043 | This tokenizer splits the input into lines.
|
---|
1044 | The tokenizer delimits lines
|
---|
1045 | by "\r", "\n" or "\r\n".
|
---|
1046 | This is the default tokenizer.
|
---|
1047 | <table cellSpacing=0 cellPadding=2 border=1>
|
---|
1048 | <tr>
|
---|
1049 | <td vAlign=top><b>Attribute</b></td>
|
---|
1050 | <td vAlign=top><b>Description</b></td>
|
---|
1051 | <td vAlign=top align="center"><b>Required</b></td>
|
---|
1052 | </tr>
|
---|
1053 | <tr>
|
---|
1054 | <td vAlign=top>includeDelims</td>
|
---|
1055 | <td vAlign=top>
|
---|
1056 | Include the line endings in the token.
|
---|
1057 | Default is false.
|
---|
1058 | </td>
|
---|
1059 | <td vAlign=top align="center">No</td>
|
---|
1060 | </tr>
|
---|
1061 | </table>
|
---|
1062 | <h4>Examples:</h4>
|
---|
1063 |
|
---|
1064 | Convert input current line endings to unix style line endings.
|
---|
1065 | <blockquote><pre>
|
---|
1066 | <tokenfilter delimoutput="\n"/>
|
---|
1067 | </pre></blockquote>
|
---|
1068 |
|
---|
1069 |
|
---|
1070 | Remove blank lines.
|
---|
1071 | <blockquote><pre>
|
---|
1072 | <tokenfilter>
|
---|
1073 | <ignoreblank/>
|
---|
1074 | </tokenfilter>
|
---|
1075 |
|
---|
1076 | </pre></blockquote>
|
---|
1077 |
|
---|
1078 | <p><b><em><a name="filetokenizer">FileTokenizer</a></em></b></p>
|
---|
1079 | This tokenizer treats <b>all</b> the input as a token. So be
|
---|
1080 | careful not to use this on very large input.
|
---|
1081 | <h4>Examples:</h4>
|
---|
1082 |
|
---|
1083 | Replace the first occurrence of package with //package.
|
---|
1084 | <blockquote><pre>
|
---|
1085 | <tokenfilter>
|
---|
1086 | <filetokenizer/>
|
---|
1087 | <replaceregex pattern="([\n\r]+[ \t]*|^[ \t]*)package"
|
---|
1088 | flags="s"
|
---|
1089 | replace="\1//package"/>
|
---|
1090 | </tokenfilter>
|
---|
1091 | </pre></blockquote>
|
---|
1092 |
|
---|
1093 | <p><b><em><a name="stringtokenizer">StringTokenizer</a></em></b></p>
|
---|
1094 | This tokenizer is based on java.util.StringTokenizer.
|
---|
1095 | It splits up the input into strings separated by white space, or
|
---|
1096 | by a specified list of delimiting characters.
|
---|
1097 | If the stream starts with delimiter characters, the first
|
---|
1098 | token will be the empty string (unless the <i>delimsaretokens</i>
|
---|
1099 | attribute is used).
|
---|
1100 |
|
---|
1101 | <table cellSpacing=0 cellPadding=2 border=1>
|
---|
1102 | <tr>
|
---|
1103 | <td vAlign=top><b>Attribute</b></td>
|
---|
1104 | <td vAlign=top><b>Description</b></td>
|
---|
1105 | <td vAlign=top align="center"><b>Required</b></td>
|
---|
1106 | </tr>
|
---|
1107 | <tr>
|
---|
1108 | <td vAlign=top>delims</td>
|
---|
1109 | <td vAlign=top>The delimiter characters. White space
|
---|
1110 | is used if this is not set. (White space is defined
|
---|
1111 | in this case by java.lang.Character.isWhitespace()).
|
---|
1112 | </td>
|
---|
1113 | <td vAlign=top align="center">No</td>
|
---|
1114 | </tr>
|
---|
1115 | <tr>
|
---|
1116 | <td valign="top">delimsaretokens</td>
|
---|
1117 | <td valign="top">If this is true,
|
---|
1118 | each delimiter character is returned as a token.
|
---|
1119 | Default is false.
|
---|
1120 | </td>
|
---|
1121 | <td valign="top" align="center">No</td>
|
---|
1122 | </tr>
|
---|
1123 | <tr>
|
---|
1124 | <td valign="top">suppressdelims</td>
|
---|
1125 | <td valign="top">
|
---|
1126 | If this is true, delimiters are not returned.
|
---|
1127 | Default is false.
|
---|
1128 | </td>
|
---|
1129 | <td valign="top" align="center">No</td>
|
---|
1130 | </tr>
|
---|
1131 | <tr>
|
---|
1132 | <td vAlign=top>includeDelims</td>
|
---|
1133 | <td vAlign=top>
|
---|
1134 | Include the delimiters in the token.
|
---|
1135 | Default is false.
|
---|
1136 | </td>
|
---|
1137 | <td vAlign=top align="center">No</td>
|
---|
1138 | </tr>
|
---|
1139 | </table>
|
---|
1140 |
|
---|
1141 | <h4>Examples:</h4>
|
---|
1142 |
|
---|
1143 | Surround each non space token with a "[]".
|
---|
1144 |
|
---|
1145 | <blockquote><pre>
|
---|
1146 | <tokenfilter>
|
---|
1147 | <stringtokenizer/>
|
---|
1148 | <replaceregex pattern="(.+)" replace="[\1]"/>
|
---|
1149 | </tokenfilter>
|
---|
1150 |
|
---|
1151 | </pre></blockquote>
|
---|
1152 |
|
---|
1153 | <p><b><em><a name="replacestring">ReplaceString</a></em></b></p>
|
---|
1154 | This is a simple filter to replace strings.
|
---|
1155 | This filter may be used directly within a filterchain.
|
---|
1156 |
|
---|
1157 | <table cellSpacing=0 cellPadding=2 border=1>
|
---|
1158 | <tr>
|
---|
1159 | <td vAlign=top><b>Attribute</b></td>
|
---|
1160 | <td vAlign=top><b>Description</b></td>
|
---|
1161 | <td vAlign=top align="center"><b>Required</b></td>
|
---|
1162 | </tr>
|
---|
1163 | <tr>
|
---|
1164 | <td vAlign=top>from</td>
|
---|
1165 | <td vAlign=top>The string that must be replaced.</td>
|
---|
1166 | <td vAlign=top align="center">Yes</td>
|
---|
1167 | </tr>
|
---|
1168 | <tr>
|
---|
1169 | <td valign="top">to</td>
|
---|
1170 | <td valign="top">The new value for the replaced string. When omitted
|
---|
1171 | an empty string is used.
|
---|
1172 | </td>
|
---|
1173 | <td valign="top" align="center">No</td>
|
---|
1174 | </tr>
|
---|
1175 | </table>
|
---|
1176 |
|
---|
1177 | <h4>Examples:</h4>
|
---|
1178 |
|
---|
1179 | Replace "sun" with "moon".
|
---|
1180 |
|
---|
1181 | <blockquote><pre>
|
---|
1182 | <tokenfilter>
|
---|
1183 | <replacestring from="sun" to="moon"/>
|
---|
1184 | </tokenfilter>
|
---|
1185 | </pre></blockquote>
|
---|
1186 |
|
---|
1187 | <p><b><em><a name="containsstring">ContainsString</a></em></b></p>
|
---|
1188 | This is a simple filter to filter tokens that contains
|
---|
1189 | a specified string.
|
---|
1190 |
|
---|
1191 | <table cellSpacing=0 cellPadding=2 border=1>
|
---|
1192 | <tr>
|
---|
1193 | <td vAlign=top><b>Attribute</b></td>
|
---|
1194 | <td vAlign=top><b>Description</b></td>
|
---|
1195 | <td vAlign=top align="center"><b>Required</b></td>
|
---|
1196 | </tr>
|
---|
1197 | <tr>
|
---|
1198 | <td vAlign=top>contains</td>
|
---|
1199 | <td vAlign=top>The string that the token must contain.</td>
|
---|
1200 | <td vAlign=top align="center">Yes</td>
|
---|
1201 | </tr>
|
---|
1202 | </table>
|
---|
1203 |
|
---|
1204 | <h4>Examples:</h4>
|
---|
1205 |
|
---|
1206 | Include only lines that contain "foo";
|
---|
1207 |
|
---|
1208 | <blockquote><pre>
|
---|
1209 | <tokenfilter>
|
---|
1210 | <containsstring contains="foo"/>
|
---|
1211 | </tokenfilter>
|
---|
1212 |
|
---|
1213 | </pre></blockquote>
|
---|
1214 |
|
---|
1215 | <p><b><em><a name="replaceregex">ReplaceRegex</a></em></b></p>
|
---|
1216 | This string filter replaces regular expressions.
|
---|
1217 | This filter may be used directly within a filterchain.
|
---|
1218 | <p>
|
---|
1219 | See <a href="regexp.html#implementation">Regexp Type</a>
|
---|
1220 | concerning the choice of the implementation.
|
---|
1221 | </p>
|
---|
1222 |
|
---|
1223 | <table cellSpacing=0 cellPadding=2 border=1>
|
---|
1224 | <tr>
|
---|
1225 | <td vAlign=top><b>Attribute</b></td>
|
---|
1226 | <td vAlign=top><b>Description</b></td>
|
---|
1227 | <td vAlign=top align="center"><b>Required</b></td>
|
---|
1228 | </tr>
|
---|
1229 | <tr>
|
---|
1230 | <td vAlign=top>pattern</td>
|
---|
1231 | <td vAlign=top>The regular expression pattern to match in
|
---|
1232 | the token.</td>
|
---|
1233 | <td vAlign=top align="center">Yes</td>
|
---|
1234 | </tr>
|
---|
1235 | <tr>
|
---|
1236 | <td vAlign=top>replace</td>
|
---|
1237 | <td vAlign=top>The substitution pattern to replace the matched
|
---|
1238 | regular expression. When omitted an empty string is used.</td>
|
---|
1239 | <td vAlign=top align="center">No</td>
|
---|
1240 | </tr>
|
---|
1241 | <tr>
|
---|
1242 | <td vAlign=top>flags</td>
|
---|
1243 | <td vAlign=top>See
|
---|
1244 | <a href="../OptionalTasks/replaceregexp.html">ReplaceRegexp</a>
|
---|
1245 | for an explanation of regex flags.</td>
|
---|
1246 | <td vAlign=top align="center">No</td>
|
---|
1247 | </tr>
|
---|
1248 | </table>
|
---|
1249 | <h4>Examples:</h4>
|
---|
1250 |
|
---|
1251 | Replace all occurrences of "hello" with "world", ignoring case.
|
---|
1252 |
|
---|
1253 | <blockquote><pre>
|
---|
1254 | <tokenfilter>
|
---|
1255 | <replaceregex pattern="hello" replace="world" flags="gi"/>
|
---|
1256 | </tokenfilter>
|
---|
1257 |
|
---|
1258 | </pre></blockquote>
|
---|
1259 |
|
---|
1260 | <p><b><em><a name="containsregex">ContainsRegex</a></em></b></p>
|
---|
1261 | This filters strings that match regular expressions.
|
---|
1262 | The filter may optionally replace the matched regular expression.
|
---|
1263 | This filter may be used directly within a filterchain.
|
---|
1264 | <p>
|
---|
1265 | See
|
---|
1266 | <a href="regexp.html#implementation">Regexp Type</a>
|
---|
1267 | concerning the choice of regular expression implementation.
|
---|
1268 | </p>
|
---|
1269 | <table cellSpacing=0 cellPadding=2 border=1>
|
---|
1270 | <tr>
|
---|
1271 | <td vAlign=top><b>Attribute</b></td>
|
---|
1272 | <td vAlign=top><b>Description</b></td>
|
---|
1273 | <td vAlign=top align="center"><b>Required</b></td>
|
---|
1274 | </tr>
|
---|
1275 | <tr>
|
---|
1276 | <td vAlign=top>pattern</td>
|
---|
1277 | <td vAlign=top>The regular expression pattern to match in
|
---|
1278 | the token.</td>
|
---|
1279 | <td vAlign=top align="center">Yes</td>
|
---|
1280 | </tr>
|
---|
1281 | <tr>
|
---|
1282 | <td vAlign=top>replace</td>
|
---|
1283 | <td vAlign=top>The substitution pattern to replace the matched
|
---|
1284 | regular expression. When omitted the orignal token is returned.
|
---|
1285 | </td>
|
---|
1286 | <td vAlign=top align="center">No</td>
|
---|
1287 | </tr>
|
---|
1288 | <tr>
|
---|
1289 | <td vAlign=top>flags</td>
|
---|
1290 | <td vAlign=top>See
|
---|
1291 | <a href="../OptionalTasks/replaceregexp.html">ReplaceRegexp</a>
|
---|
1292 | for an explanation of regex flags.</td>
|
---|
1293 | <td vAlign=top align="center">No</td>
|
---|
1294 | </tr>
|
---|
1295 | </table>
|
---|
1296 |
|
---|
1297 | <h4>Examples:</h4>
|
---|
1298 |
|
---|
1299 | Filter lines that contain "hello" or "world", ignoring case.
|
---|
1300 |
|
---|
1301 | <blockquote><pre>
|
---|
1302 | <tokenfilter>
|
---|
1303 | <containsregex pattern="(hello|world)" flags="i"/>
|
---|
1304 | </tokenfilter>
|
---|
1305 |
|
---|
1306 | </pre></blockquote>
|
---|
1307 |
|
---|
1308 | This example replaces lines like "SUITE(TestSuite, bits);" with
|
---|
1309 | "void register_bits();" and removes other lines.
|
---|
1310 |
|
---|
1311 | <blockquote><pre>
|
---|
1312 | <tokenfilter>
|
---|
1313 | <containsregex
|
---|
1314 | pattern="^ *SUITE\(.*,\s*(.*)\s*\).*"
|
---|
1315 | replace="void register_\1();"/>
|
---|
1316 | </tokenfilter>
|
---|
1317 | </pre></blockquote>
|
---|
1318 |
|
---|
1319 | <p><b><em><a name="trim">Trim</a></em></b></p>
|
---|
1320 | This filter trims whitespace from the start and end of
|
---|
1321 | tokens.
|
---|
1322 | This filter may be used directly within a filterchain.
|
---|
1323 | <p><b><em><a name="ignoreblank">IgnoreBlank</a></em></b></p>
|
---|
1324 | This filter removes empty tokens.
|
---|
1325 | This filter may be used directly within a filterchain.
|
---|
1326 | <p><b><em><a name="filterdeletecharacters">DeleteCharacters</a></em></b></p>
|
---|
1327 | This filter deletes specified characters from tokens.
|
---|
1328 |
|
---|
1329 | <table cellSpacing=0 cellPadding=2 border=1>
|
---|
1330 | <tr>
|
---|
1331 | <td vAlign=top><b>Attribute</b></td>
|
---|
1332 | <td vAlign=top><b>Description</b></td>
|
---|
1333 | <td vAlign=top align="center"><b>Required</b></td>
|
---|
1334 | </tr>
|
---|
1335 | <tr>
|
---|
1336 | <td vAlign=top>chars</td>
|
---|
1337 | <td vAlign=top>The characters to delete. This attribute
|
---|
1338 | is backslash enabled.</td>
|
---|
1339 | <td vAlign=top align="center">Yes</td>
|
---|
1340 | </tr>
|
---|
1341 | </table>
|
---|
1342 |
|
---|
1343 | <h4>Examples:</h4>
|
---|
1344 |
|
---|
1345 | Delete tabs from lines, trim the lines and removes empty lines.
|
---|
1346 |
|
---|
1347 | <blockquote><pre>
|
---|
1348 | <tokenfilter>
|
---|
1349 | <deletecharacters chars="\t"/>
|
---|
1350 | <trim/>
|
---|
1351 | <ignoreblank/>
|
---|
1352 | </tokenfilter>
|
---|
1353 |
|
---|
1354 | </pre></blockquote>
|
---|
1355 |
|
---|
1356 | <p><b><em><a name="scriptfilter">ScriptFilter</a></em></b></p>
|
---|
1357 | This is an optional filter that executes a script in a
|
---|
1358 | <a href="http://jakarta.apache.org/bsf" target="_top">Apache BSF</a>
|
---|
1359 | or
|
---|
1360 | <a href="https://scripting.dev.java.net">JSR 223</a>
|
---|
1361 | supported language.</p>
|
---|
1362 | See the <a href="../OptionalTasks/script.html">Script</a> task for
|
---|
1363 | an explanation of scripts and dependencies.
|
---|
1364 | </p>
|
---|
1365 | <p>
|
---|
1366 | The script is provided with an object <i>self</i> that has
|
---|
1367 | getToken() and setToken(String) methods.
|
---|
1368 | The getToken() method returns the current token. The setToken(String)
|
---|
1369 | method replaces the current token.
|
---|
1370 | </p>
|
---|
1371 |
|
---|
1372 | This filter may be used directly within a filterchain.<p>
|
---|
1373 | <table cellSpacing=0 cellPadding=2 border=1>
|
---|
1374 | <tr>
|
---|
1375 | <td vAlign=top><b>Attribute</b></td>
|
---|
1376 | <td vAlign=top><b>Description</b></td>
|
---|
1377 | <td vAlign=top align="center"><b>Required</b></td>
|
---|
1378 | </tr>
|
---|
1379 | <tr>
|
---|
1380 | <td vAlign=top>language</td>
|
---|
1381 | <td vAlign=top> The programming language the script is written in.
|
---|
1382 | Must be a supported Apache BSF or JSR 223 language</td>
|
---|
1383 | <td vAlign=top align="center">Yes</td>
|
---|
1384 | </tr>
|
---|
1385 | <tr>
|
---|
1386 | <td valign="top">manager</td>
|
---|
1387 | <td valign="top">
|
---|
1388 | The script engine manager to use.
|
---|
1389 | See the <a href="../OptionalTasks/script.html">script</a> task
|
---|
1390 | for using this attribute.
|
---|
1391 | </td>
|
---|
1392 | <td valign="top" align="center">No - default is "auto"</td>
|
---|
1393 | </tr>
|
---|
1394 | <tr>
|
---|
1395 | <td vAlign=top>src</td>
|
---|
1396 | <td vAlign=top>The location of the script as a file, if not inline
|
---|
1397 | </td>
|
---|
1398 | <td vAlign=top align="center">No</td>
|
---|
1399 | </tr>
|
---|
1400 | <tr>
|
---|
1401 | <td valign="top">setbeans</td>
|
---|
1402 | <td valign="top">whether to have all properties, references and targets as
|
---|
1403 | global variables in the script.</td>
|
---|
1404 | <td valign="top" align="center">No, default is "true".</td>
|
---|
1405 | </tr>
|
---|
1406 | <tr>
|
---|
1407 | <td valign="top">classpath</td>
|
---|
1408 | <td valign="top">
|
---|
1409 | The classpath to pass into the script.
|
---|
1410 | </td>
|
---|
1411 | <td align="center" valign="top">No</td>
|
---|
1412 | </tr>
|
---|
1413 | <tr>
|
---|
1414 | <td valign="top">classpathref</td>
|
---|
1415 | <td valign="top">The classpath to use, given as a
|
---|
1416 | <a href="../using.html#references">reference</a> to a path defined elsewhere.
|
---|
1417 | <td align="center" valign="top">No</td>
|
---|
1418 | </tr>
|
---|
1419 | </table>
|
---|
1420 | <p>
|
---|
1421 | This filter can take a nested <classpath> element.
|
---|
1422 | See the <a href="../OptionalTasks/script.html">script</a> task
|
---|
1423 | on how to use this element.
|
---|
1424 | </p>
|
---|
1425 | <h4>Examples:</h4>
|
---|
1426 |
|
---|
1427 | Convert to uppercase:
|
---|
1428 | <blockquote><pre>
|
---|
1429 | <tokenfilter>
|
---|
1430 | <scriptfilter language="javascript">
|
---|
1431 | self.setToken(self.getToken().toUpperCase());
|
---|
1432 | </scriptfilter>
|
---|
1433 | </tokenfilter>
|
---|
1434 | </pre></blockquote>
|
---|
1435 |
|
---|
1436 | Remove lines containing the string "bad" while
|
---|
1437 | copying text files:
|
---|
1438 | <blockquote>
|
---|
1439 | <pre>
|
---|
1440 | <copy todir="dist">
|
---|
1441 | <fileset dir="src" includes="**/*.txt"/>
|
---|
1442 | <filterchain>
|
---|
1443 | <scriptfilter language="beanshell">
|
---|
1444 | if (self.getToken().indexOf("bad") != -1) {
|
---|
1445 | self.setToken(null);
|
---|
1446 | }
|
---|
1447 | </scriptfilter>
|
---|
1448 | </filterchain>
|
---|
1449 | </copy>
|
---|
1450 | </pre>
|
---|
1451 | </blockquote>
|
---|
1452 |
|
---|
1453 | <h4>Custom tokenizers and string filters</h4>
|
---|
1454 |
|
---|
1455 | Custom string filters and tokenizers may be plugged in by
|
---|
1456 | extending the interfaces org.apache.tools.ant.filters.TokenFilter.Filter
|
---|
1457 | and org.apache.tools.ant.util.Tokenizer respectly.
|
---|
1458 |
|
---|
1459 | They are defined the build file using <code><typedef/></code>. For
|
---|
1460 | example a string filter that capitalizes words may be declared as:
|
---|
1461 | <blockquote><pre>
|
---|
1462 | package my.customant;
|
---|
1463 | import org.apache.tools.ant.filters.TokenFilter;
|
---|
1464 |
|
---|
1465 | public class Capitalize
|
---|
1466 | implements TokenFilter.Filter
|
---|
1467 | {
|
---|
1468 | public String filter(String token) {
|
---|
1469 | if (token.length() == 0)
|
---|
1470 | return token;
|
---|
1471 | return token.substring(0, 1).toUpperCase() +
|
---|
1472 | token.substring(1);
|
---|
1473 | }
|
---|
1474 | }
|
---|
1475 | </pre></blockquote>
|
---|
1476 |
|
---|
1477 | This may be used as follows:
|
---|
1478 | <blockquote><pre>
|
---|
1479 | <typedef type="capitalize" classname="my.customant.Capitalize"
|
---|
1480 | classpath="my.customant.path"/>
|
---|
1481 | <copy file="input" tofile="output">
|
---|
1482 | <filterchain>
|
---|
1483 | <tokenfilter>
|
---|
1484 | <stringtokenizer/>
|
---|
1485 | <capitalize/>
|
---|
1486 | </tokenfilter>
|
---|
1487 | </filterchain>
|
---|
1488 | </copy>
|
---|
1489 | </pre></blockquote>
|
---|
1490 |
|
---|
1491 | </body></html>
|
---|