@@ -25,24 +25,24 @@ import org.apache.tools.ant.types.Parameter;
* Attaches a suffix to every line.
*
* Example:
* <pre><appendtolines append ="Foo"/></pre>
* <pre><suffixlines suffix ="Foo"/></pre>
*
* Or:
*
* <pre><filterreader classname="org.apache.tools.ant.filters.AppendTo Lines">
* <param name="append " value="Foo"/>
* <pre><filterreader classname="org.apache.tools.ant.filters.Suffix Lines">
* <param name="suffix " value="Foo"/>
* </filterreader></pre>
*
* @since Ant 1.8.0
*/
public final class AppendTo Lines
public final class Suffix Lines
extends BaseParamFilterReader
implements ChainableReader {
/** Parameter name for the prefix. */
private static final String APPEND_KEY = "append ";
private static final String SUFFIX_KEY = "suffix ";
/** The append ix to be used. */
private String append = null;
/** The suff ix to be used. */
private String suffix = null;
/** Data that must be read from, if not null. */
private String queuedData = null;
@@ -52,7 +52,7 @@ public final class AppendToLines
*
* @see BaseFilterReader#BaseFilterReader()
*/
public AppendTo Lines() {
public Suffix Lines() {
super();
}
@@ -62,13 +62,13 @@ public final class AppendToLines
* @param in A Reader object providing the underlying stream.
* Must not be <code>null</code>.
*/
public AppendTo Lines(final Reader in) {
public Suffix Lines(final Reader in) {
super(in);
}
/**
* Returns the next character in the filtered stream. One line is read
* from the original input, and the append ix added. The resulting
* from the original input, and the suff ix added. The resulting
* line is then used until it ends, at which point the next original line
* is read, etc.
*
@@ -101,7 +101,7 @@ public final class AppendToLines
if (queuedData == null) {
ch = -1;
} else {
if (append != null) {
if (suffix != null) {
String lf = "";
if (queuedData.endsWith("\r\n")) {
lf = "\r\n";
@@ -111,7 +111,7 @@ public final class AppendToLines
queuedData =
queuedData.substring(0,
queuedData.length() - lf.length())
+ append + lf;
+ suffix + lf;
}
return read();
}
@@ -120,27 +120,27 @@ public final class AppendToLines
}
/**
* Sets the append ix to add at the end of each input line.
* Sets the suff ix to add at the end of each input line.
*
* @param append The append ix to add at the end of each input line.
* May be <code>null</code>, in which case no append ix
* @param suffix The suff ix to add at the end of each input line.
* May be <code>null</code>, in which case no suff ix
* is added.
*/
public void setAppend (final String append) {
this.append = append;
public void setSuffix (final String append) {
this.suffix = append;
}
/**
* Returns the append ix which will be added at the end of each input line.
* Returns the suff ix which will be added at the end of each input line.
*
* @return the append ix which will be added at the end of each input line
* @return the suff ix which will be added at the end of each input line
*/
private String getAppend () {
return append ;
private String getSuffix () {
return suffix ;
}
/**
* Creates a new AppendTo Lines filter using the passed in
* Creates a new Suffix Lines filter using the passed in
* Reader for instantiation.
*
* @param rdr A Reader object providing the underlying stream.
@@ -150,21 +150,21 @@ public final class AppendToLines
* the specified reader
*/
public Reader chain(final Reader rdr) {
AppendToLines newFilter = new AppendTo Lines(rdr);
newFilter.setAppend(getAppend ());
SuffixLines newFilter = new Suffix Lines(rdr);
newFilter.setSuffix(getSuffix ());
newFilter.setInitialized(true);
return newFilter;
}
/**
* Initializes the append ix if it is available from the parameters.
* Initializes the suff ix if it is available from the parameters.
*/
private void initialize() {
Parameter[] params = getParameters();
if (params != null) {
for (int i = 0; i < params.length; i++) {
if (APPEND _KEY.equals(params[i].getName())) {
append = params[i].getValue();
if (SUFFIX _KEY.equals(params[i].getName())) {
suffix = params[i].getValue();
break;
}
}