Class FixCrLfFilter
- java.lang.Object
- 
- java.io.Reader
- 
- java.io.FilterReader
- 
- org.apache.tools.ant.filters.BaseFilterReader
- 
- org.apache.tools.ant.filters.BaseParamFilterReader
- 
- org.apache.tools.ant.filters.FixCrLfFilter
 
 
 
 
 
- 
- All Implemented Interfaces:
- java.io.Closeable,- java.lang.AutoCloseable,- java.lang.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
 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> 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classFixCrLfFilter.AddAsisRemoveEnumerated attribute with the values "asis", "add" and "remove".static classFixCrLfFilter.CrLfEnumerated attribute with the values "asis", "cr", "lf" and "crlf".
 - 
Constructor SummaryConstructors Constructor Description FixCrLfFilter()Constructor for "dummy" instances.FixCrLfFilter(java.io.Reader in)Create a new filtered reader.
 - 
Method SummaryModifier and Type Method Description java.io.Readerchain(java.io.Reader rdr)Create a new FixCrLfFilter using the passed in Reader for instantiation.FixCrLfFilter.AddAsisRemovegetEof()Get how DOS EOF (control-z) characters are being handled.FixCrLfFilter.CrLfgetEol()Get how EndOfLine characters are being handled.booleangetFixlast()Get whether a missing EOL be added to the final line of the stream.booleangetJavafiles()Get whether the stream is to be treated as though it contains Java source.FixCrLfFilter.AddAsisRemovegetTab()Return how tab characters are being handled.intgetTablength()Get the tab length to use.intread()Return the next character in the filtered stream.voidsetEof(FixCrLfFilter.AddAsisRemove attr)Specify how DOS EOF (control-z) characters are to be handled.voidsetEol(FixCrLfFilter.CrLf attr)Specify how end of line (EOL) characters are to be handled.voidsetFixlast(boolean fixlast)Specify whether a missing EOL will be added to the final line of input.voidsetJavafiles(boolean javafiles)Indicate whether this stream contains Java source.voidsetTab(FixCrLfFilter.AddAsisRemove attr)Specify how tab characters are to be handled.voidsetTablength(int tabLength)Specify tab length in characters.- 
Methods inherited from class org.apache.tools.ant.filters.BaseParamFilterReadergetParameters, setParameters
 - 
Methods inherited from class org.apache.tools.ant.filters.BaseFilterReadergetInitialized, getProject, read, readFully, readLine, setInitialized, setProject, skip
 
- 
 
- 
- 
- 
Constructor Detail- 
FixCrLfFilterpublic FixCrLfFilter() Constructor for "dummy" instances.- See Also:
- BaseFilterReader()
 
 - 
FixCrLfFilterpublic FixCrLfFilter(java.io.Reader in) throws java.io.IOExceptionCreate a new filtered reader.- Parameters:
- in- A Reader object providing the underlying stream. Must not be- null.
- Throws:
- java.io.IOException- on error.
 
 
- 
 - 
Method Detail- 
chainpublic java.io.Reader chain(java.io.Reader rdr) Create a new FixCrLfFilter using the passed in Reader for instantiation.- Specified by:
- chainin interface- ChainableReader
- Parameters:
- rdr- A Reader object providing the underlying stream. Must not be- null.
- Returns:
- a new filter based on this configuration, but filtering the specified reader.
 
 - 
getEofpublic FixCrLfFilter.AddAsisRemove getEof() Get how DOS EOF (control-z) characters are being handled.- Returns:
- values:
         - add: ensure that there is an eof at the end of the file
- asis: leave eof characters alone
- remove: remove any eof character found at the end
 
 
 - 
getEolpublic FixCrLfFilter.CrLf getEol() Get how EndOfLine characters are being handled.- Returns:
- values:
         - asis: convert line endings to your O/S convention
- cr: convert line endings to CR
- lf: convert line endings to LF
- crlf: convert line endings to CRLF
 
 
 - 
getFixlastpublic boolean getFixlast() Get whether a missing EOL be added to the final line of the stream.- Returns:
- true if a filtered file will always end with an EOL
 
 - 
getJavafilespublic boolean getJavafiles() Get whether the stream is to be treated as though it contains Java source.This attribute is only used in association with the "tab" attribute. Tabs found in Java literals are protected from changes by this filter. - Returns:
- true if whitespace in Java character and string literals is ignored.
 
 - 
getTabpublic FixCrLfFilter.AddAsisRemove getTab() Return how tab characters are being handled.- Returns:
- values:
         - add: convert sequences of spaces which span a tab stop to tabs
- asis: leave tab and space characters alone
- remove: convert tabs to spaces
 
 
 - 
getTablengthpublic int getTablength() Get the tab length to use.- Returns:
- the length of tab in spaces
 
 - 
readpublic int read() throws java.io.IOExceptionReturn the next character in the filtered stream.- Overrides:
- readin class- java.io.FilterReader
- Returns:
- the next character in the resulting stream, or -1 if the end of the resulting stream has been reached.
- Throws:
- java.io.IOException- if the underlying stream throws an IOException during reading.
 
 - 
setEofpublic void setEof(FixCrLfFilter.AddAsisRemove attr) Specify how DOS EOF (control-z) characters are to be handled.- Parameters:
- attr- valid values:- add: ensure that there is an eof at the end of the file
- asis: leave eof characters alone
- remove: remove any eof character found at the end
 
 
 - 
setEolpublic void setEol(FixCrLfFilter.CrLf attr) Specify how end of line (EOL) characters are to be handled.- Parameters:
- attr- valid values:- asis: convert line endings to your O/S convention
- cr: convert line endings to CR
- lf: convert line endings to LF
- crlf: convert line endings to CRLF
 
 
 - 
setFixlastpublic void setFixlast(boolean fixlast) Specify whether a missing EOL will be added to the final line of input.- Parameters:
- fixlast- if true a missing EOL will be appended.
 
 - 
setJavafilespublic void setJavafiles(boolean javafiles) Indicate whether this stream contains Java source. This attribute is only used in association with the "tab" attribute.- Parameters:
- javafiles- set to true to prevent this filter from changing tabs found in Java literals.
 
 - 
setTabpublic void setTab(FixCrLfFilter.AddAsisRemove attr) Specify how tab characters are to be handled.- Parameters:
- attr- valid values:- add: convert sequences of spaces which span a tab stop to tabs
- asis: leave tab and space characters alone
- remove: convert tabs to spaces
 
 
 - 
setTablengthpublic void setTablength(int tabLength) throws java.io.IOExceptionSpecify tab length in characters.- Parameters:
- tabLength- specify the length of tab in spaces. Valid values are between 2 and 80 inclusive. The default for this parameter is 8.
- Throws:
- java.io.IOException- on error.
 
 
- 
 
-