git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@808306 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -1365,6 +1365,8 @@ Delete tabs from lines, trim the lines and removes empty lines. | |||||
| <p>Suppresses all tokens that match their ancestor token. It is most | <p>Suppresses all tokens that match their ancestor token. It is most | ||||
| useful if combined with a sort filter.</p> | useful if combined with a sort filter.</p> | ||||
| <p>This filter may be used directly within a filterchain.</p> | |||||
| <h4>Example:</h4> | <h4>Example:</h4> | ||||
| This suppresses duplicate lines. | This suppresses duplicate lines. | ||||
| @@ -26,12 +26,10 @@ package org.apache.tools.ant.filters; | |||||
| * | * | ||||
| * @since Ant 1.8.0 | * @since Ant 1.8.0 | ||||
| */ | */ | ||||
| public class UniqFilter implements TokenFilter.Filter { | |||||
| public class UniqFilter extends TokenFilter.ChainableReaderFilter { | |||||
| private String lastLine = null; | private String lastLine = null; | ||||
| public UniqFilter() { } | |||||
| public String filter(String string) { | public String filter(String string) { | ||||
| return lastLine == null || !lastLine.equals(string) | return lastLine == null || !lastLine.equals(string) | ||||
| ? (lastLine = string) : null; | ? (lastLine = string) : null; | ||||
| @@ -23,6 +23,18 @@ | |||||
| </target> | </target> | ||||
| <target name="testUniqFilter" depends="setUp"> | <target name="testUniqFilter" depends="setUp"> | ||||
| <copy file="input/uniq.txt" | |||||
| tofile="${output}/uniq.txt"> | |||||
| <filterchain> | |||||
| <uniqfilter/> | |||||
| </filterchain> | |||||
| </copy> | |||||
| <au:assertFilesMatch | |||||
| expected="expected/uniq.txt" | |||||
| actual="${output}/uniq.txt"/> | |||||
| </target> | |||||
| <target name="testUniqTokenFilter" depends="setUp"> | |||||
| <copy file="input/uniq.txt" | <copy file="input/uniq.txt" | ||||
| tofile="${output}/uniq.txt"> | tofile="${output}/uniq.txt"> | ||||
| <filterchain> | <filterchain> | ||||