Home| Design| License| Regex| Download| Credits| Contact
Text-Zap Info
› Overview» Text-Zap Ant Task› Expand Text-Zap› API Docs
Components
› Filters› Savers› Groupers› Sequencers
Navigate
› Description› Parameters› Nested Elements› Examples

Description

The Text-Zap ant task is the backbone of Text-Zap. It runs the files through the filters.

The tasks accepts an unlimited number of Filesets and Filters. By default the task will overwrite any files that exist in the destination directory, even if they are newer than the original source file. This option can be changed with the overwrite parameter.

In order to run Text-Zap the Text-Zap Task must be defined within your build file. Here is an example of what the definition should look like.

<typedef resource="com/jmw/tzap/typedef.xml" classpath="${classpath to tzap.jar}"/>

^topParameters

 
AttributeDescriptionRequired
inFileA single file for filteringYes, unless nested Filesets are included
outFileA single out put file Yes, unless a destdir is specified, only works if a single infile is specified
destDirThe directory where the filtered files should be placedYes, unless outFile is specified
encodingThe encoding to be used when reading and writing the filesNo, defaults to the system default
overwriteFlag indicating if the files in the destination will be overwritten.No, defaults to true

^topNested Elements

Filesets
Filesets specify the files to be filtered. An unlimited number of fileset elements can be added to the Text-Zap task. When using filesets, a destDir must be specified.
Filters
Filter elements are used to specify the filters that the the files should run throguh. An unlimited number of filters can be added to the Text-Zap task. Each filter must have the proper parameters supplied. At least one filter is required for the Text-Zap task.
Mappers
You can define filename transformations by using a nested mapper element. The default mapper used is the identity mapper.
Savers
You can determine which files will be saved by adding a saver element to the tzap task.

^topExamples

Run a filter on a single file to a single file
<tzap inFile="./myfile.txt" outFile="./filtered.txt">
    <replace regex="aa*" replacement="bb"/>
</tzap>
Run a filter on a single file to a directory, but do not overwrite if the file already exists
<tzap inFile="./myfile.txt" destDir="/outdir" overwrite="false">
    <replace regex="aa*" replacement="bb"/>
</tzap>
Run a filter on a fileset and map the new files to a new extension
<tzap destDir="./outdir">
    <fileset dir="./sourcedir" includes="**/*.txt"/>
    <replace .... />
    <mapper type="glob" from="*.txt" to="*.text"/>
</tzap>

Note: Examples for each of the filters are provided in their respective descriptions. Check the filters page for more details.

SourceForge.net Logo