Class FixCrLfFilter

java.lang.Object
All Implemented Interfaces:
Closeable, AutoCloseable, Readable, ChainableReader, Parameterizable

public final class FixCrLfFilter extends BaseParamFilterReader implements ChainableReader
Converts text to local OS formatting conventions, as well as repair text damaged by misconfigured or misguided editors or file transfer programs.

This filter can take the following arguments:

  • eof
  • eol
  • fixlast
  • javafiles
  • tab
  • tablength
None of which are required.

This version generalises the handling of EOL characters, and allows for CR-only line endings (the standard on Mac systems prior to OS X). Tab handling has also been generalised to accommodate any tabwidth from 2 to 80, inclusive. Importantly, it can leave untouched any literal TAB characters embedded within Java string or character constants.

Caution: run with care on carefully formatted files. This may sound obvious, but if you don't specify asis, presume that your files are going to be modified. If "tabs" is "add" or "remove", whitespace characters may be added or removed as necessary. Similarly, for EOLs, eol="asis" actually means convert to your native O/S EOL convention while eol="crlf" or cr="add" can result in CR characters being removed in one special case accommodated, i.e., CRCRLF is regarded as a single EOL to handle cases where other programs have converted CRLF into CRCRLF.

Example:

 <<fixcrlf tab="add" eol="crlf" eof="asis"/>
 
Or:
 <filterreader classname="org.apache.tools.ant.filters.FixCrLfFilter">
   <param eol="crlf" tab="asis"/>
  </filterreader>