|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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
public final class FixCrLfFilter
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:
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 Summary | |
---|---|
static class |
FixCrLfFilter.AddAsisRemove
Enumerated attribute with the values "asis", "add" and "remove". |
static class |
FixCrLfFilter.CrLf
Enumerated attribute with the values "asis", "cr", "lf" and "crlf". |
Field Summary |
---|
Fields inherited from class java.io.FilterReader |
---|
in |
Fields inherited from class java.io.Reader |
---|
lock |
Constructor Summary | |
---|---|
FixCrLfFilter()
Constructor for "dummy" instances. |
|
FixCrLfFilter(java.io.Reader in)
Create a new filtered reader. |
Method Summary | |
---|---|
java.io.Reader |
chain(java.io.Reader rdr)
Create a new FixCrLfFilter using the passed in Reader for instantiation. |
FixCrLfFilter.AddAsisRemove |
getEof()
Get how DOS EOF (control-z) characters are being handled. |
FixCrLfFilter.CrLf |
getEol()
Get how EndOfLine characters are being handled. |
boolean |
getFixlast()
Get whether a missing EOL be added to the final line of the stream. |
boolean |
getJavafiles()
Get whether the stream is to be treated as though it contains Java source. |
FixCrLfFilter.AddAsisRemove |
getTab()
Return how tab characters are being handled. |
int |
getTablength()
Get the tab length to use. |
int |
read()
Return the next character in the filtered stream. |
void |
setEof(FixCrLfFilter.AddAsisRemove attr)
Specify how DOS EOF (control-z) characters are to be handled. |
void |
setEol(FixCrLfFilter.CrLf attr)
Specify how end of line (EOL) characters are to be handled. |
void |
setFixlast(boolean fixlast)
Specify whether a missing EOL will be added to the final line of input. |
void |
setJavafiles(boolean javafiles)
Indicate whether this stream contains Java source. |
void |
setTab(FixCrLfFilter.AddAsisRemove attr)
Specify how tab characters are to be handled. |
void |
setTablength(int tabLength)
Specify tab length in characters. |
Methods inherited from class org.apache.tools.ant.filters.BaseParamFilterReader |
---|
getParameters, setParameters |
Methods inherited from class org.apache.tools.ant.filters.BaseFilterReader |
---|
getInitialized, getProject, read, readFully, readLine, setInitialized, setProject, skip |
Methods inherited from class java.io.FilterReader |
---|
close, mark, markSupported, ready, reset |
Methods inherited from class java.io.Reader |
---|
read, read |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FixCrLfFilter()
BaseFilterReader.BaseFilterReader()
public FixCrLfFilter(java.io.Reader in) throws java.io.IOException
in
- A Reader object providing the underlying stream. Must not be
null
.
java.io.IOException
- on error.Method Detail |
---|
public java.io.Reader chain(java.io.Reader rdr)
chain
in interface ChainableReader
rdr
- A Reader object providing the underlying stream. Must not be
null
.
public FixCrLfFilter.AddAsisRemove getEof()
public FixCrLfFilter.CrLf getEol()
public boolean getFixlast()
public boolean getJavafiles()
This attribute is only used in assocation with the "tab" attribute. Tabs found in Java literals are protected from changes by this filter.
public FixCrLfFilter.AddAsisRemove getTab()
public int getTablength()
public int read() throws java.io.IOException
read
in class java.io.FilterReader
java.io.IOException
- if the underlying stream throws an IOException during
reading.public void setEof(FixCrLfFilter.AddAsisRemove attr)
attr
- valid values:
public void setEol(FixCrLfFilter.CrLf attr)
attr
- valid values:
public void setFixlast(boolean fixlast)
fixlast
- if true a missing EOL will be appended.public void setJavafiles(boolean javafiles)
javafiles
- set to true to prevent this filter from changing tabs found in
Java literals.public void setTab(FixCrLfFilter.AddAsisRemove attr)
attr
- valid values:
public void setTablength(int tabLength) throws java.io.IOException
tabLength
- specify the length of tab in spaces. Valid values are between
2 and 80 inclusive. The default for this parameter is 8.
java.io.IOException
- on error.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |