Methods Summary |
---|
private static java.lang.String | calculateEolString(org.apache.tools.ant.filters.FixCrLfFilter$CrLf eol)
// Calculate the EOL string per the current config
if (eol == CrLf.ASIS) {
return System.getProperty("line.separator");
}
if (eol == CrLf.CR || eol == CrLf.MAC) {
return "\r";
}
if (eol == CrLf.CRLF || eol == CrLf.DOS) {
return "\r\n";
}
// assume (eol == CrLf.LF || eol == CrLf.UNIX)
return "\n";
|
public java.io.Reader | chain(java.io.Reader rdr)Create a new FixCrLfFilter using the passed in Reader for instantiation.
tabs = AddAsisRemove.ASIS;
if (Os.isFamily("mac") && !Os.isFamily("unix")) {
ctrlz = AddAsisRemove.REMOVE;
setEol(CrLf.MAC);
} else if (Os.isFamily("dos")) {
ctrlz = AddAsisRemove.ASIS;
setEol(CrLf.DOS);
} else {
ctrlz = AddAsisRemove.REMOVE;
setEol(CrLf.UNIX);
}
try {
FixCrLfFilter newFilter = new FixCrLfFilter(rdr);
newFilter.setJavafiles(getJavafiles());
newFilter.setEol(getEol());
newFilter.setTab(getTab());
newFilter.setTablength(getTablength());
newFilter.setEof(getEof());
newFilter.setFixlast(getFixlast());
newFilter.initInternalFilters();
return newFilter;
} catch (IOException e) {
throw new BuildException(e);
}
|
public org.apache.tools.ant.filters.FixCrLfFilter$AddAsisRemove | getEof()Get how DOS EOF (control-z) characters are being handled.
// Return copy so that the call must call setEof() to change the state
// of fixCRLF
return ctrlz.newInstance();
|
public org.apache.tools.ant.filters.FixCrLfFilter$CrLf | getEol()Get how EndOfLine characters are being handled.
// Return copy so that the call must call setEol() to change the state
// of fixCRLF
return eol.newInstance();
|
public boolean | getFixlast()Get whether a missing EOL be added to the final line of the stream.
return fixlast;
|
public boolean | getJavafiles()Get whether the stream is to be treated as though it contains Java
source.
This attribute is only used in assocation with the "tab"
attribute. Tabs found in Java literals are protected from changes by this
filter.
return javafiles;
|
public org.apache.tools.ant.filters.FixCrLfFilter$AddAsisRemove | getTab()Return how tab characters are being handled.
// Return copy so that the caller must call setTab() to change the state
// of fixCRLF.
return tabs.newInstance();
|
public int | getTablength()Get the tab length to use.
return tabLength;
|
private void | initInternalFilters()Wrap the input stream with the internal filters necessary to perform the
configuration settings.
// If I'm removing an EOF character, do so first so that the other
// filters don't see that character.
in = (ctrlz == AddAsisRemove.REMOVE) ? new RemoveEofFilter(in) : in;
// Change all EOL characters to match the calculated EOL string. If
// configured to do so, append a trailing EOL so that the file ends on
// a EOL.
in = new NormalizeEolFilter(in, calculateEolString(eol), getFixlast());
if (tabs != AddAsisRemove.ASIS) {
// If filtering Java source, prevent changes to whitespace in
// character and string literals.
if (getJavafiles()) {
in = new MaskJavaTabLiteralsFilter(in);
}
// Add/Remove tabs
in = (tabs == AddAsisRemove.ADD) ? (Reader) new AddTabFilter(in, getTablength())
: (Reader) new RemoveTabFilter(in, getTablength());
}
// Add missing EOF character
in = (ctrlz == AddAsisRemove.ADD) ? new AddEofFilter(in) : in;
initialized = true;
|
public synchronized int | read()Return the next character in the filtered stream.
if (!initialized) {
initInternalFilters();
}
return in.read();
|
public void | setEof(org.apache.tools.ant.filters.FixCrLfFilter$AddAsisRemove attr)Specify how DOS EOF (control-z) characters are to be handled.
ctrlz = attr.resolve();
|
public void | setEol(org.apache.tools.ant.filters.FixCrLfFilter$CrLf attr)Specify how end of line (EOL) characters are to be handled.
eol = attr.resolve();
|
public void | setFixlast(boolean fixlast)Specify whether a missing EOL will be added to the final line of input.
this.fixlast = fixlast;
|
public void | setJavafiles(boolean javafiles)Indicate whether this stream contains Java source.
This attribute is only used in assocation with the "tab"
attribute.
this.javafiles = javafiles;
|
public void | setTab(org.apache.tools.ant.filters.FixCrLfFilter$AddAsisRemove attr)Specify how tab characters are to be handled.
tabs = attr.resolve();
|
public void | setTablength(int tabLength)Specify tab length in characters.
if (tabLength < 2 || tabLength > 80) {
throw new IOException("tablength must be between 2 and 80");
}
this.tabLength = tabLength;
|