From 19731e2b2f86f9b7e0d653592c5062d342e5d823 Mon Sep 17 00:00:00 2001 From: Matthew Jason Benson Date: Fri, 8 Apr 2005 19:14:34 +0000 Subject: [PATCH] Lower-case HTML tags git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@278123 13f79535-47bb-0310-9956-ffa450edef68 --- docs/manual/CoreTypes/filterchain.html | 1228 ++++++++++++------------ 1 file changed, 614 insertions(+), 614 deletions(-) diff --git a/docs/manual/CoreTypes/filterchain.html b/docs/manual/CoreTypes/filterchain.html index a31d66472..8a37d712b 100644 --- a/docs/manual/CoreTypes/filterchain.html +++ b/docs/manual/CoreTypes/filterchain.html @@ -1,28 +1,28 @@ - - + + -FilterChains and FilterReaders - +FilterChains and FilterReaders + - + -

FilterChains and FilterReaders

+

FilterChains and FilterReaders

Look at Unix pipes - they offer you so much flexibility - say you wanted to copy just those lines that contained the string blee from the first 10 lines of a file 'foo' -to a file 'bar' - you would do something like

+to a file 'bar' - you would do something like

cat foo|head -n10|grep blee > bar -

+

Ant was not flexible enough. There was no way for the <copy> task to do something similar. If you wanted the <copy> task to get the first 10 lines, you would have -had to create special attributes:

+had to create special attributes:

<copy file="foo" tofile="bar" head="10" contains="blee"/> -

+

The obvious problem thus surfaced: Ant tasks would not be able to accommodate such data transformation attributes as they would be endless. The task would also not know in which order these @@ -31,7 +31,7 @@ contains attribute first and then the head attribute or vice-versa? What Ant tasks needed was a mechanism to allow pluggable filter (data transformer) chains. Ant would provide a few filters for which there have been repeated requests. Users with special filtering needs -would be able to easily write their own and plug them in.

+would be able to easily write their own and plug them in.

The solution was to refactor data transformation oriented tasks to support FilterChains. A FilterChain is a group of @@ -39,9 +39,9 @@ ordered FilterReaders. Users can define their own FilterReaders by just extending the java.io.FilterReader class. Such custom FilterReaders can be easily plugged in as nested elements of <filterchain> by using <filterreader> elements. -

+

Example: -

+
 <copy file="${src.file}" tofile="${dest.file}">
   <filterchain>
     <filterreader classname="your.extension.of.java.io.FilterReader">
@@ -56,21 +56,21 @@ Example:
     </filterreader>
   </filterchain>
 </copy>
-
+
Ant provides some built-in filter readers. These filter readers can also be declared using a syntax similar to the above syntax. -However, they can be declared using some simpler syntax also.

+However, they can be declared using some simpler syntax also.

Example: -

+
 <loadfile srcfile="${src.file}" property="${src.file.head}">
   <filterchain>
     <headfilter lines="15"/>
   </filterchain>
 </loadfile>
-
+
is equivalent to: -
+
 <loadfile srcfile="${src.file}" property="${src.file.head}">
   <filterchain>
     <filterreader classname="org.apache.tools.ant.filters.HeadFilter">
@@ -78,36 +78,36 @@ is equivalent to:
     </filterreader>
   </filterchain>
 </loadfile>
-
+
-The following built-in tasks support nested <filterchain> elements.
-Concat,
-Copy,
-LoadFile,
-LoadProperties,
-Move

+The following built-in tasks support nested <filterchain> elements.
+Concat,
+Copy,
+LoadFile,
+LoadProperties,
+Move

A FilterChain is formed by defining zero or more of the following -nested elements.
-FilterReader
-ClassConstants
-EscapeUnicode
-ExpandProperties
-HeadFilter
-LineContains
-LineContainsRegExp
-PrefixLines
-ReplaceTokens
-StripJavaComments
-StripLineBreaks
-StripLineComments
-TabsToSpaces
-TailFilter
-DeleteCharacters
-ConcatFilter
-TokenFilter
- -

FilterReader

+nested elements.
+FilterReader
+ClassConstants
+EscapeUnicode
+ExpandProperties
+HeadFilter
+LineContains
+LineContainsRegExp
+PrefixLines
+ReplaceTokens
+StripJavaComments
+StripLineBreaks
+StripLineComments
+TabsToSpaces
+TailFilter
+DeleteCharacters
+ConcatFilter
+TokenFilter
+ +

FilterReader

The filterreader element is the generic way to define a filter. User defined filter elements are @@ -121,91 +121,91 @@ extend java.io.FilterReader. If the custom filter reader needs to be parameterized, it must implement org.apache.tools.type.Parameterizable. - - - - - - - - - - - -
AttributeDescriptionRequired
classnameThe class name of the filter reader.Yes
- -

-

Nested Elements:

+ + + + + + + + + + + +
AttributeDescriptionRequired
classnameThe class name of the filter reader.Yes
+ +

+

Nested Elements:

<filterreader> supports <classpath> and <param> as nested elements. Each <param> element may take in the following attributes - name, type and value. -

+

The following FilterReaders are supplied with the default distribution. -

ClassConstants

-

+

ClassConstants

+

This filters basic constants defined in a Java Class, and outputs them in lines composed of the format name=value -

-

Example:

+

+

Example:

This loads the basic constants defined in a Java class as Ant properties. -
+
 <loadproperties srcfile="foo.class">
   <filterchain>
     <filterreader classname="org.apache.tools.ant.filters.ClassConstants"/>
   </filterchain>
 </loadproperties>
-
+
Convenience method: -
+
 <loadproperties srcfile="foo.class">
   <filterchain>
     <classconstants/>
   </filterchain>
 </loadproperties>
-
+
-

EscapeUnicode

-

+

EscapeUnicode

+

This filter converts its input by changing all non US-ASCII characters into their equivalent unicode escape backslash u plus 4 digits.

-

since Ant 1.6

+

since Ant 1.6

-

Example:

+

Example:

This loads the basic constants defined in a Java class as Ant properties. -
+
 <loadproperties srcfile="non_ascii_property.properties">
   <filterchain>
     <filterreader classname="org.apache.tools.ant.filters.EscapeUnicode"/>
   </filterchain>
 </loadproperties>
-
+
Convenience method: -
+
 <loadproperties srcfile="non_ascii_property.properties">
   <filterchain>
     <escapeunicode/>
   </filterchain>
 </loadproperties>
-
+
-

ExpandProperties

-

+

ExpandProperties

+

If the data contains data that represents Ant properties (of the form ${...}), that is substituted with the property's actual value. -

-

Example:

+

+

Example:

This results in the property modifiedmessage holding the value "All these moments will be lost in time, like teardrops in the rain" -
+
 <echo
   message="All these moments will be lost in time, like teardrops in the ${weather}"
   file="loadfile1.tmp"
@@ -216,10 +216,10 @@ This results in the property modifiedmessage holding the value
     <filterreader classname="org.apache.tools.ant.filters.ExpandProperties"/>
   </filterchain>
 </loadfile>
-
+
Convenience method: -
+
 <echo
   message="All these moments will be lost in time, like teardrops in the ${weather}"
   file="loadfile1.tmp"
@@ -230,37 +230,37 @@ Convenience method:
     <expandproperties/>
   </filterchain>
 </loadfile>
-
+
-

HeadFilter

+

HeadFilter

This filter reads the first few lines from the data supplied to it. - - - - - - - - - - - - - - - - -
Parameter NameParameter ValueRequired
linesNumber of lines to be read. - Defaults to "10"
A negative value means that all lines are - passed (useful with skip)
No
skipNumber of lines to be skipped (from the beginning). - Defaults to "0"No
-

-

Example:

+ + + + + + + + + + + + + + + + +
Parameter NameParameter ValueRequired
linesNumber of lines to be read. + Defaults to "10"
A negative value means that all lines are + passed (useful with skip)
No
skipNumber of lines to be skipped (from the beginning). + Defaults to "0"No
+

+

Example:

This stores the first 15 lines of the supplied data in the property ${src.file.head} -
+
 <loadfile srcfile="${src.file}" property="${src.file.head}">
   <filterchain>
     <filterreader classname="org.apache.tools.ant.filters.HeadFilter">
@@ -268,162 +268,162 @@ This stores the first 15 lines of the supplied data in the property ${src.file.h
     </filterreader>
   </filterchain>
 </loadfile>
-
+
Convenience method: -
+
 <loadfile srcfile="${src.file}" property="${src.file.head}">
   <filterchain>
     <headfilter lines="15"/>
   </filterchain>
 </loadfile>
-
+
This stores the first 15 lines, skipping the first 2 lines, of the supplied data in the property ${src.file.head}. (Means: lines 3-17) -
+
 <loadfile srcfile="${src.file}" property="${src.file.head}">
   <filterchain>
     <headfilter lines="15" skip="2"/>
   </filterchain>
 </loadfile>
-
+
-See the testcases for more examples (src\etc\testcases\filters\head-tail.xml in the +See the testcases for more examples (src\etc\testcases\filters\head-tail.xml in the source distribution). -

LineContains

+

LineContains

This filter includes only those lines that contain all the user-specified strings. - - - - - - - - - - - -
Parameter TypeParameter ValueRequired
containsSubstring to be searched for.Yes
-

-

Example:

+ + + + + + + + + + + +
Parameter TypeParameter ValueRequired
containsSubstring to be searched for.Yes
+

+

Example:

This will include only those lines that contain foo and bar. -
+
 <filterreader classname="org.apache.tools.ant.filters.LineContains">
   <param type="contains" value="foo"/>
   <param type="contains" value="bar"/>
 </filterreader>
-
+
Convenience method: -
+
 <linecontains>
   <contains value="foo"/>
   <contains value="bar"/>
 </linecontains>
-
+
-

LineContainsRegExp

+

LineContainsRegExp

Filter which includes only those lines that contain the user-specified regular expression matching strings. See Regexp Type for the description of the nested element regexp and of the choice of regular expression implementation. -

Example:

+

Example:

This will fetch all those lines that contain the pattern foo -
+
 <filterreader classname="org.apache.tools.ant.filters.LineContainsRegExp">
   <param type="regexp" value="foo*"/>
 </filterreader>
-
+
Convenience method: -
+
 <linecontainsregexp>
   <regexp pattern="foo*"/>
 </linecontainsregexp>
-
+
-

PrefixLines

+

PrefixLines

Attaches a prefix to every line. - - - - - - - - - - - -
Parameter NameParameter ValueRequired
prefixPrefix to be attached to lines.Yes
-

-

Example:

+ + + + + + + + + + + +
Parameter NameParameter ValueRequired
prefixPrefix to be attached to lines.Yes
+

+

Example:

This will attach the prefix Foo to all lines. -
+
 <filterreader classname="org.apache.tools.ant.filters.PrefixLines">
   <param name="prefix" value="Foo"/>
 </filterreader>
-
+
Convenience method: -
+
 <prefixlines prefix="Foo"/>
-
+
-

ReplaceTokens

+

ReplaceTokens

This filter reader replaces all strings that are sandwiched between begintoken and endtoken with user defined values. - - - - - - - - - - - - - - - - - - - - - - - - - -
Parameter TypeParameter NameParameter ValueRequired
tokencharbegintokenCharacter marking the - beginning of a token. Defaults to @No
tokencharendtokenCharacter marking the - end of a token. Defaults to @No
tokenUser defined String.User defined search StringYes
-

- -

Example:

+ + + + + + + + + + + + + + + + + + + + + + + + + +
Parameter TypeParameter NameParameter ValueRequired
tokencharbegintokenCharacter marking the + beginning of a token. Defaults to @No
tokencharendtokenCharacter marking the + end of a token. Defaults to @No
tokenUser defined String.User defined search StringYes
+

+ +

Example:

This replaces occurrences of the string @DATE@ in the data with today's date and stores it in the property ${src.file.replaced} -
+
 <tstamp/>
 <loadfile srcfile="${src.file}" property="${src.file.replaced}">
   <filterchain>
@@ -432,10 +432,10 @@ with today's date and stores it in the property ${src.file.replaced}
     </filterreader>
   </filterchain>
 </loadfile>
-
+
Convenience method: -
+
 <tstamp/>
 <loadfile srcfile="${src.file}" property="${src.file.replaced}">
   <filterchain>
@@ -444,75 +444,75 @@ Convenience method:
     </replacetokens>
   </filterchain>
 </loadfile>
-
+
-

StripJavaComments

+

StripJavaComments

This filter reader strips away comments from the data, using Java syntax guidelines. This filter does not take in any parameters. -

-

Example:

+

+

Example:

-
+
 <loadfile srcfile="${java.src.file}" property="${java.src.file.nocomments}">
   <filterchain>
     <filterreader classname="org.apache.tools.ant.filters.StripJavaComments"/>
   </filterchain>
 </loadfile>
-
+
Convenience method: -
+
 <loadfile srcfile="${java.src.file}" property="${java.src.file.nocomments}">
   <filterchain>
     <stripjavacomments/>
   </filterchain>
 </loadfile>
-
+
-

StripLineBreaks

+

StripLineBreaks

This filter reader strips away specific characters from the data supplied to it. - - - - - - - - - - - -
Parameter NameParameter ValueRequired
linebreaksCharacters that are to - be stripped out. Defaults to "\r\n"No
-

-

Examples:

+ + + + + + + + + + + +
Parameter NameParameter ValueRequired
linebreaksCharacters that are to + be stripped out. Defaults to "\r\n"No
+

+

Examples:

This strips the '\r' and '\n' characters. -
+
 <loadfile srcfile="${src.file}" property="${src.file.contents}">
   <filterchain>
     <filterreader classname="org.apache.tools.ant.filters.StripLineBreaks"/>
   </filterchain>
 </loadfile>
-
+
Convenience method: -
+
 <loadfile srcfile="${src.file}" property="${src.file.contents}">
   <filterchain>
     <striplinebreaks/>
   </filterchain>
 </loadfile>
-
+
This treats the '(' and ')' characters as line break characters and strips them. -
+
 <loadfile srcfile="${src.file}" property="${src.file.contents}">
   <filterchain>
     <filterreader classname="org.apache.tools.ant.filters.StripLineBreaks">
@@ -520,31 +520,31 @@ strips them.
     </filterreader>
   </filterchain>
 </loadfile>
-
+
-

StripLineComments

+

StripLineComments

This filter removes all those lines that begin with strings that represent comments as specified by the user. - - - - - - - - - - - -
Parameter TypeParameter ValueRequired
commentStrings that identify a line as a comment - when they appear at the start of the line.Yes
-

-

Examples:

+ + + + + + + + + + + +
Parameter TypeParameter ValueRequired
commentStrings that identify a line as a comment + when they appear at the start of the line.Yes
+

+

Examples:

This removes all lines that begin with #, --, REM, rem and // -
+
 <filterreader classname="org.apache.tools.ant.filters.StripLineComments">
   <param type="comment" value="#"/>
   <param type="comment" value="--"/>
@@ -552,10 +552,10 @@ This removes all lines that begin with #, --, REM, rem and //
   <param type="comment" value="rem "/>
   <param type="comment" value="//"/>
 </filterreader>
-
+
Convenience method: -
+
 <striplinecomments>
   <comment value="#"/>
   <comment value="--"/>
@@ -563,166 +563,166 @@ Convenience method:
   <comment value="rem "/>
   <comment value="//"/>
 </striplinecomments>
-
+
-

TabsToSpaces

+

TabsToSpaces

This filter replaces tabs with spaces - - - - - - - - - - - -
Parameter NameParameter ValueRequired
tablengthDefaults to "8"No
-

-

Examples:

+ + + + + + + + + + + +
Parameter NameParameter ValueRequired
tablengthDefaults to "8"No
+

+

Examples:

This replaces tabs in ${src.file} with spaces. -
+
 <loadfile srcfile="${src.file}" property="${src.file.notab}">
   <filterchain>
     <filterreader classname="org.apache.tools.ant.filters.TabsToSpaces"/>
   </filterchain>
 </loadfile>
-
+
Convenience method: -
+
 <loadfile srcfile="${src.file}" property="${src.file.notab}">
   <filterchain>
     <tabstospaces/>
   </filterchain>
 </loadfile>
-
+
-

TailFilter

+

TailFilter

This filter reads the last few lines from the data supplied to it. - - - - - - - - - - - - - - - - -
Parameter NameParameter ValueRequired
linesNumber of lines to be read. - Defaults to "10"
A negative value means that all lines are - passed (useful with skip)
No
skipNumber of lines to be skipped (from the end). - Defaults to "0" No
-

- -

Background:

+ + + + + + + + + + + + + + + + +
Parameter NameParameter ValueRequired
linesNumber of lines to be read. + Defaults to "10"
A negative value means that all lines are + passed (useful with skip)
No
skipNumber of lines to be skipped (from the end). + Defaults to "0" No
+

+ +

Background:

With HeadFilter and TailFilter you can extract each part of a text file you want. This graphic shows the dependencies: - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Content Filter
Line 1     - - - - + +
 
<filterchain>
+
+
+ 
+ 
+ 
+ 
+ 
+
+
+ 
+ 
+ 
+ 
+ 
-
-
- 
-
-
- 
- 
-
-
- 
-
-
- 
- 
-
-
- 
-
-
- 
-
-
- 
- 
-
-
- 
-
-
- 
- 
-
-
- 
-
-
Content Filter
Line 1     + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - -
 
<filterchain>
     <headfilter lines="2"/>
-</filterchain>
 
<filterchain>
+</filterchain>
 
<filterchain>
     <tailfilter lines="-1" skip="2"/>
-</filterchain>
 
<filterchain>
+</filterchain>
 
<filterchain>
     <headfilter lines="-1" skip="2"/>
-</filterchain>
 
<filterchain>
+</filterchain>
 
<filterchain>
     <headfilter lines="-1" skip="2"/>
     <tailfilter lines="-1" skip="2"/>
-</filterchain>
 
<filterchain>
+</filterchain>
 
<filterchain>
     <tailfilter lines="2"/>
-</filterchain>
-
Line 2
Line 3  
Line 4
Line 5  
Lines ...
Line 95
Line 96  
Line 97
Line 98  
Line 99
- - - -

Examples:

+</filterchain>
+
Line 2
Line 3  
Line 4
Line 5  
Lines ...
Line 95
Line 96  
Line 97
Line 98  
Line 99
+ + + +

Examples:

This stores the last 15 lines of the supplied data in the property ${src.file.tail} -
+
 <loadfile srcfile="${src.file}" property="${src.file.tail}">
   <filterchain>
     <filterreader classname="org.apache.tools.ant.filters.TailFilter">
@@ -730,21 +730,21 @@ This stores the last 15 lines of the supplied data in the property ${src.file.ta
     </filterreader>
   </filterchain>
 </loadfile>
-
+
Convenience method: -
+
 <loadfile srcfile="${src.file}" property="${src.file.tail}">
   <filterchain>
     <tailfilter lines="15"/>
   </filterchain>
 </loadfile>
-
+
This stores the last 5 lines of the first 15 lines of the supplied data in the property ${src.file.mid} -
+
 <loadfile srcfile="${src.file}" property="${src.file.mid}">
   <filterchain>
     <filterreader classname="org.apache.tools.ant.filters.HeadFilter">
@@ -755,114 +755,114 @@ data in the property ${src.file.mid}
     </filterreader>
   </filterchain>
 </loadfile>
-
+
Convenience method: -
+
 <loadfile srcfile="${src.file}" property="${src.file.mid}">
   <filterchain>
     <headfilter lines="15"/>
     <tailfilter lines="5"/>
   </filterchain>
 </loadfile>
-
+
This stores the last 10 lines, skipping the last 2 lines, of the supplied data in the property ${src.file.head}. (Means: if supplied data contains 60 lines, lines 49-58 are extracted) -
+
 <loadfile srcfile="${src.file}" property="${src.file.head}">
   <filterchain>
     <tailfilter lines="10" skip="2"/>
   </filterchain>
 </loadfile>
-
+
-

DeleteCharacters

+

DeleteCharacters

This filter deletes specified characters.

since Ant 1.6

This filter is only available in the convenience form.

- - - - - - - - - + + +
Parameter NameParameter ValueRequired
chars + + + + + + + + + - - -
Parameter NameParameter ValueRequired
chars The characters to delete. This attribute is backslash enabled. - Yes
-

-

Examples:

+
Yes
+

+

Examples:

Delete tabs and returns from the data. -
+
 <deletecharacters chars="\t\r"/>
-
+
-

ConcatFilter

+

ConcatFilter

This filter prepends or appends the content file to the filtered files.

since Ant 1.6

- - - - - - - - - + + +
Parameter NameParameter ValueRequired
prepend + + + + + + + + + - - - - - + + + + + - - -
Parameter NameParameter ValueRequired
prepend The name of the file which content should be prepended to the file. - No
append + No
append The name of the file which content should be appended to the file. - No
-

+

No
+

-

Examples:

+

Examples:

Do nothing: -
+
 <filterchain>
     <concatfilter/>
 </filterchain>
-
+
Adds a license text before each java source: -
+
 <filterchain>
     <concatfilter prepend="apache-license-java.txt"/>
 </filterchain>
-
+
-

TokenFilter

+

TokenFilter

This filter tokenizes the inputstream into strings and passes these strings to filters of strings. Unlike the other filterreaders, this does not support params, only convenience methods are implemented. The tokenizer and the string filters are defined by nested elements. -

since Ant 1.6

-

+

since Ant 1.6

+

Only one tokenizer element may be used, the LineTokenizer is the default if none are specified. A tokenizer splits the input into token strings and trailing delimiter strings. -

+

There may be zero or more string filters. A string filter processes a token and either returns a string or a null. It the string is not null it is passed to the next filter. This @@ -872,30 +872,30 @@ outputs with its associated token delimitier (if one is present). The trailing delimiter may be overridden by the delimOutput attribute. -

+

blackslash interpretation A number of attributes (including delimOutput) interpret backslash escapes. The following are understood: \n, \r, \f, \t and \\. - - - - - - - - - + + +
AttributeDescriptionRequired
delimOutput + + + + + + + + + - - -
AttributeDescriptionRequired
delimOutput This overrides the tokendelimiter returned by the tokenizer if it is not empty. This attribute is backslash enabled. -No
-

+

No
+

The following tokenizers are provided by the default distribution.

@@ -925,58 +925,58 @@ case a tokenfilter is created implicitly. An extra attribute "byline" is added to the filter to specify whether to use a linetokenizer (byline="true") or a filetokenizer (byline="false"). The default is "true". -

+

LineTokenizer

This tokenizer splits the input into lines. The tokenizer delimits lines by "\r", "\n" or "\r\n". This is the default tokenizer. - - - - - - - - - + + +
AttributeDescriptionRequired
includeDelims + + + + + + + + + - - -
AttributeDescriptionRequired
includeDelims Include the line endings in the token. Default is false. - No
-

Examples:

+
No
+

Examples:

Convert input current line endings to unix style line endings. -
+
 <tokenfilter delimoutput="\n"/>
-
+
Remove blank lines. -
+
 <tokenfilter>
     <ignoreblank/>
 </tokenfilter>
 
-
+

FileTokenizer

This tokenizer treats all the input as a token. So be careful not to use this on very large input. -

Examples:

+

Examples:

Replace the first occurrence of package with //package. -
+
 <tokenfilter>
       <filetokenizer/>
       <replaceregex pattern="([\n\r]+[ \t]*|^[ \t]*)package"
                     flags="s"
                     replace="\1//package"/>
 </tokenfilter>
-
+

StringTokenizer

This tokenizer is based on java.util.StringTokenizer. @@ -986,20 +986,20 @@ If the stream starts with delimiter characters, the first token will be the empty string (unless the delimsaretokens attribute is used). - - - - - - - - -
AttributeDescriptionRequired
delimsThe delimiter characters. White space + + + + + + + + + - - + + + -
AttributeDescriptionRequired
delimsThe delimiter characters. White space is used if this is not set. (White space is defined in this case by java.lang.Character.isWhitespace()). - No
No
delimsaretokens If this is true, @@ -1024,35 +1024,35 @@ attribute is used). No
+
-

Examples:

+

Examples:

Surround each non space token with a "[]". -
+
 <tokenfilter>
     <stringtokenizer/>
     <replaceregex pattern="(.+)" replace="[\1]"/>
 </tokenfilter>
 
-
+

ReplaceString

This is a simple filter to replace strings. This filter may be used directly within a filterchain. - - - - - - - - - - - +
AttributeDescriptionRequired
fromThe string that must be replaced.Yes
+ + + + + + + + + + -
AttributeDescriptionRequired
fromThe string that must be replaced.Yes
to The new value for the replaced string. When omitted @@ -1060,45 +1060,45 @@ This filter may be used directly within a filterchain. No
+ -

Examples:

+

Examples:

Replace "sun" with "moon". -
+
 <tokenfilter>
     <replacestring from="sun" to="moon"/>
 </tokenfilter>
-
+

ContainsString

This is a simple filter to filter tokens that contains a specified string. - - - - - - - - - - - -
AttributeDescriptionRequired
containsThe string that the token must contain.Yes
- -

Examples:

+ + + + + + + + + + + +
AttributeDescriptionRequired
containsThe string that the token must contain.Yes
+ +

Examples:

Include only lines that contain "foo"; -
+
 <tokenfilter>
     <containsstring contains="foo"/>
 </tokenfilter>
 
-
+

ReplaceRegex

This string filter replaces regular expressions. @@ -1108,42 +1108,42 @@ This filter may be used directly within a filterchain. concerning the choice of the implementation.

- - - - - - - - - - - - - - - - - - - + + +
AttributeDescriptionRequired
patternThe regular expression pattern to match in - the token.Yes
replaceThe substitution pattern to replace the matched - regular expression. When omitted an empty string is used.No
flagsSee + + + + + + + + + + + + + + + + + + + - - -
AttributeDescriptionRequired
patternThe regular expression pattern to match in + the token.Yes
replaceThe substitution pattern to replace the matched + regular expression. When omitted an empty string is used.No
flagsSee ReplaceRegexp -for an explanation of regex flags.No
-

Examples:

+for an explanation of regex flags.
No
+

Examples:

Replace all occurrences of "hello" with "world", ignoring case. -
+
 <tokenfilter>
     <replaceregex pattern="hello" replace="world" flags="gi"/>
 </tokenfilter>
 
-
+

ContainsRegex

This filters strings that match regular expressions. @@ -1154,55 +1154,55 @@ See Regexp Type concerning the choice of regular expression implementation.

- - - - - - - - - - - - - - + + +
AttributeDescriptionRequired
patternThe regular expression pattern to match in - the token.Yes
replaceThe substitution pattern to replace the matched + + + + + + + + + + + + + + - - - - - + + + + + - - -
AttributeDescriptionRequired
patternThe regular expression pattern to match in + the token.Yes
replaceThe substitution pattern to replace the matched regular expression. When omitted the orignal token is returned. - No
flagsSee + No
flagsSee ReplaceRegexp -for an explanation of regex flags.No
+for an explanation of regex flags.
No
-

Examples:

+

Examples:

Filter lines that contain "hello" or "world", ignoring case. -
+
 <tokenfilter>
     <containsregex pattern="(hello|world)" flags="i"/>
 </tokenfilter>
 
-
+
This example replaces lines like "SUITE(TestSuite, bits);" with "void register_bits();" and removes other lines. -
+
 <tokenfilter>
     <containsregex
         pattern="^ *SUITE\(.*,\s*(.*)\s*\).*"
         replace="void register_\1();"/>
 </tokenfilter>
-
+

Trim

This filter trims whitespace from the start and end of @@ -1214,32 +1214,32 @@ This filter may be used directly within a filterchain.

DeleteCharacters

This filter deletes specified characters from tokens. - - - - - - - - - - - -
AttributeDescriptionRequired
charsThe characters to delete. This attribute - is backslash enabled.Yes
- -

Examples:

+ + + + + + + + + + + +
AttributeDescriptionRequired
charsThe characters to delete. This attribute + is backslash enabled.Yes
+ +

Examples:

Delete tabs from lines, trim the lines and removes empty lines. -
+
 <tokenfilter>
     <deletecharacters chars="\t"/>
     <trim/>
     <ignoreblank/>
 </tokenfilter>
 
-
+

ScriptFilter

This is an optional filter that executes a script in a @@ -1256,37 +1256,37 @@ method replaces the current token.

This filter may be used directly within a filterchain.

- - - - - - - - - - - - - - - - - -
AttributeDescriptionRequired
language The programming language the script is written in. -Must be a supported Apache BSF languageYes
srcThe location of the script as a file, if not inline - No
- -

Examples:

+ + + + + + + + + + + + + + + + + +
AttributeDescriptionRequired
language The programming language the script is written in. +Must be a supported Apache BSF languageYes
srcThe location of the script as a file, if not inline + No
+ +

Examples:

Convert to uppercase: -
+
 <tokenfilter>
     <scriptfilter language="javascript">
         self.setToken(self.getToken().toUpperCase());
     </scriptfilter>
 </tokenfilter>
-
+
Remove lines containing the string "bad" while copying text files: @@ -1303,7 +1303,7 @@ copying text files: -

Custom tokenizers and string filters

+

Custom tokenizers and string filters

Custom string filters and tokenizers may be plugged in by extending the interfaces org.apache.tools.ant.filters.TokenFilter.Filter @@ -1341,7 +1341,7 @@ This may be used as follows: </copy> -
+
-

Copyright © 2002-2005 The Apache Software Foundation. All rights -Reserved.

+

Copyright © 2002-2005 The Apache Software Foundation. All rights +Reserved.