|
Hi all
In our prject we needed to add some file processing
(striping off headers and footers of text files). The current copyfile does
similar things. Functionality is spread across Project and Copyfile. I feel
translating or generally processing and copying files should be separated. For
me copying is copying withjout ANY modifications applied.
Translate extends MatchingTask and currently
supports therefor (probably) all MatchingTask properties.
The attached proposal allows the following
definitions in your build.xml:
<translate src=""
dest="/to/dir">
<include
.../>
<exclude
.../>
<strip
header="HEADER-SEPARATOR" footer="FOOTER-SEPARATOR"/>
<convertCRLF
format="DOS"/>
</translate>
Note:
- This is the third implementation of CRLF
conversion. This has been done, as the others can not be combined with other
file translation.
- Adding token filtering is no big deal (note the
current token filtering may converts your eol)
- Add your own file translation as you need
it.
- the strip shown aboev only prints text between
HEADER-SEPARATOR and FOOTER-SEPARATOR or end of file.
How it works:
The translation is done by objects extending
FilterOutputStream. For each file to be translated, the FilterOutputStreams are
chainned together. The example above results in a chain of:
StripFilterOutputStream --->
ConvertCRLFFilterOutputStream ---> FileOutputStream
Next step:
- If considered a good thing, a real patch will be
provided, including the token filtering.
- strip may not be part of standard
distribution
- tom
|
ConvertCRLFFactory.java
Description: Binary data
ConvertCRLFOutputStream.java
Description: Binary data
ProcessLineOutputStream.java
Description: Binary data
StripFactory.java
Description: Binary data
StripOutputStream.java
Description: Binary data
Translate.java
Description: Binary data
TranslatorFactory.java
Description: Binary data
