Hi all,

I propose a FilterReader named 'CommentOut' that puts in comment a line or a
block for Java, HTML/XML/XSLT and JSP files. A tag in the code with a
condition will enable or disable the line conversion.

Here's an example how the CommentOut FilterReader works:
    <filterreader classname="org.apache.tools.ant.filters.CommentOut">
      <param name="condition" value="debug"/>
    </filterreader>

If the source code is:
    log("-->method()"); // @IF_LINE@ debug
<!-- @IF_BLOCK@ debug --> <myXMLtag attribute="test"/>

The result is:
//    log("-->method()"); // @IF_LINE@ debug
<!-- @IF_BLOCK@ debug <myXMLtag attribute="test"/>

My motivation was to remove the debugging methods for the release code
compilation because they may slow down the runtime, and to not provide a
part of a code, depending if it is a customer release or a demo release.
A solution was to do a compilation directive. I extended the idea to the
other file types. Also, the FilterReader checks first if the line/block was
already enabled, and is able to disable it. It means that the conversion is
reversible.

Please see the documentation for more examples and for a table with the
different conversions. The code is compiling with the JDK1.1.8. A TestCase
parses a file that contains about 115 conditions.

Your feedback is very much appreciated,
Stephane.

<<attachment: commentout.zip>>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to