Browse Source

appendtolines -> suffixlines

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@897758 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 15 years ago
parent
commit
73a3dfbc27
5 changed files with 44 additions and 42 deletions
  1. +2
    -0
      WHATSNEW
  2. +9
    -9
      docs/manual/CoreTypes/filterchain.html
  3. +27
    -27
      src/main/org/apache/tools/ant/filters/SuffixLines.java
  4. +5
    -5
      src/main/org/apache/tools/ant/types/FilterChain.java
  5. +1
    -1
      src/tests/antunit/filters/suffix-test.xml

+ 2
- 0
WHATSNEW View File

@@ -4,6 +4,8 @@ Changes from Ant 1.8.0RC1 TO current SVN version
Changes that could break older environments:
-------------------------------------------

* the appendtolines filter has been renamed to suffixlines.

Fixed bugs:
-----------



+ 9
- 9
docs/manual/CoreTypes/filterchain.html View File

@@ -107,7 +107,6 @@ The following built-in tasks support nested <code>&lt;filterchain&gt;</code> ele
A FilterChain is formed by defining zero or more of the following
nested elements.<br>
<a href="#filterreader">FilterReader</a><br>
<a href="#appendtolines">AppendToLines</a><br>
<a href="#classconstants">ClassConstants</a><br>
<a href="#escapeunicode">EscapeUnicode</a><br>
<a href="#expandproperties">ExpandProperties</a><br>
@@ -119,6 +118,7 @@ nested elements.<br>
<a href="#stripjavacomments">StripJavaComments</a><br>
<a href="#striplinebreaks">StripLineBreaks</a><br>
<a href="#striplinecomments">StripLineComments</a><br>
<a href="#suffixlines">SuffixLines</a><br>
<a href="#tabstospaces">TabsToSpaces</a><br>
<a href="#tailfilter">TailFilter</a><br>
<a href="#deletecharacters">DeleteCharacters</a><br>
@@ -479,9 +479,9 @@ Convenience method:
&lt;prefixlines prefix=&quot;Foo&quot;/&gt;
</pre></blockquote>

<h3><a name="appendtolines">AppendToLines</a></h3>
<h3><a name="suffixlines">SuffixLines</a></h3>

Attaches an appendix to every line.
Attaches a suffix to every line.

<p><em>since Ant 1.8.0</em></p>

@@ -492,24 +492,24 @@ Attaches an appendix to every line.
<td vAlign=top align="center"><b>Required</b></td>
</tr>
<tr>
<td vAlign=top>append</td>
<td vAlign=top align="center">Appendix to be attached to lines.</td>
<td vAlign=top>suffix</td>
<td vAlign=top align="center">Suffix to be attached to lines.</td>
<td vAlign=top align="center">Yes</td>
</tr>
</table>
<p>
<h4>Example:</h4>

This will attach the appendix <code>Foo</code> to all lines.
This will attach the suffix <code>Foo</code> to all lines.
<blockquote><pre>
&lt;filterreader classname=&quot;org.apache.tools.ant.filters.AppendToLines&quot;&gt;
&lt;param name=&quot;append&quot; value=&quot;Foo&quot;/&gt;
&lt;filterreader classname=&quot;org.apache.tools.ant.filters.SuffixLines&quot;&gt;
&lt;param name=&quot;suffix&quot; value=&quot;Foo&quot;/&gt;
&lt;/filterreader&gt;
</pre></blockquote>

Convenience method:
<blockquote><pre>
&lt;appendtolines append=&quot;Foo&quot;/&gt;
&lt;suffixlines suffix=&quot;Foo&quot;/&gt;
</pre></blockquote>

<h3><a name="replacetokens">ReplaceTokens</a></h3>


src/main/org/apache/tools/ant/filters/AppendToLines.java → src/main/org/apache/tools/ant/filters/SuffixLines.java View File

@@ -25,24 +25,24 @@ import org.apache.tools.ant.types.Parameter;
* Attaches a suffix to every line.
*
* Example:
* <pre>&lt;appendtolines append=&quot;Foo&quot;/&gt;</pre>
* <pre>&lt;suffixlines suffix=&quot;Foo&quot;/&gt;</pre>
*
* Or:
*
* <pre>&lt;filterreader classname=&quot;org.apache.tools.ant.filters.AppendToLines&quot;&gt;
* &lt;param name=&quot;append&quot; value=&quot;Foo&quot;/&gt;
* <pre>&lt;filterreader classname=&quot;org.apache.tools.ant.filters.SuffixLines&quot;&gt;
* &lt;param name=&quot;suffix&quot; value=&quot;Foo&quot;/&gt;
* &lt;/filterreader&gt;</pre>
*
* @since Ant 1.8.0
*/
public final class AppendToLines
public final class SuffixLines
extends BaseParamFilterReader
implements ChainableReader {
/** Parameter name for the prefix. */
private static final String APPEND_KEY = "append";
private static final String SUFFIX_KEY = "suffix";

/** The appendix to be used. */
private String append = null;
/** The suffix 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 AppendToLines() {
public SuffixLines() {
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 AppendToLines(final Reader in) {
public SuffixLines(final Reader in) {
super(in);
}

/**
* Returns the next character in the filtered stream. One line is read
* from the original input, and the appendix added. The resulting
* from the original input, and the suffix 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 appendix to add at the end of each input line.
* Sets the suffix to add at the end of each input line.
*
* @param append The appendix to add at the end of each input line.
* May be <code>null</code>, in which case no appendix
* @param suffix The suffix to add at the end of each input line.
* May be <code>null</code>, in which case no suffix
* is added.
*/
public void setAppend(final String append) {
this.append = append;
public void setSuffix(final String append) {
this.suffix = append;
}

/**
* Returns the appendix which will be added at the end of each input line.
* Returns the suffix which will be added at the end of each input line.
*
* @return the appendix which will be added at the end of each input line
* @return the suffix which will be added at the end of each input line
*/
private String getAppend() {
return append;
private String getSuffix() {
return suffix;
}

/**
* Creates a new AppendToLines filter using the passed in
* Creates a new SuffixLines 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 AppendToLines(rdr);
newFilter.setAppend(getAppend());
SuffixLines newFilter = new SuffixLines(rdr);
newFilter.setSuffix(getSuffix());
newFilter.setInitialized(true);
return newFilter;
}

/**
* Initializes the appendix if it is available from the parameters.
* Initializes the suffix 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;
}
}

+ 5
- 5
src/main/org/apache/tools/ant/types/FilterChain.java View File

@@ -23,7 +23,6 @@ import java.util.Vector;

import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.filters.AppendToLines;
import org.apache.tools.ant.filters.ChainableReader;
import org.apache.tools.ant.filters.ClassConstants;
import org.apache.tools.ant.filters.EscapeUnicode;
@@ -36,6 +35,7 @@ import org.apache.tools.ant.filters.ReplaceTokens;
import org.apache.tools.ant.filters.StripJavaComments;
import org.apache.tools.ant.filters.StripLineBreaks;
import org.apache.tools.ant.filters.StripLineComments;
import org.apache.tools.ant.filters.SuffixLines;
import org.apache.tools.ant.filters.TabsToSpaces;
import org.apache.tools.ant.filters.TailFilter;
import org.apache.tools.ant.filters.TokenFilter;
@@ -156,17 +156,17 @@ public class FilterChain extends DataType
}

/**
* Add a AppendToLines filter.
* Add a SuffixLines filter.
*
* @param prefixLines a <code>AppendToLines</code> value
* @param suffixLines a <code>SuffixLines</code> value
* @since Ant 1.8.0
*/
public void addAppendToLines(final AppendToLines appendToLines) {
public void addSuffixLines(final SuffixLines suffixLines) {
if (isReference()) {
throw noChildrenAllowed();
}
setChecked(false);
filterReaders.addElement(appendToLines);
filterReaders.addElement(suffixLines);
}

/**


src/tests/antunit/filters/append-test.xml → src/tests/antunit/filters/suffix-test.xml View File

@@ -33,7 +33,7 @@ cFoo</echo>
<copy todir="${output}">
<fileset dir="${input}"/>
<filterchain>
<appendtolines append="Foo"/>
<suffixlines suffix="Foo"/>
</filterchain>
</copy>
<au:assertFilesMatch expected="${input}/b.txt"

Loading…
Cancel
Save