You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Matt Benson <gu...@yahoo.com> on 2009/08/26 19:30:29 UTC
Re: svn commit: r808018 - in /ant/core/trunk: ./ docs/manual/CoreTypes/ src/main/org/apache/tools/ant/ src/main/org/apache/tools/ant/filters/ src/tests/antunit/filters/ src/tests/antunit/filters/expected/ src/tests/antunit/filters/input/
Do we want to stick to English spellings ("unique") or are we okay with "uniq"--presumably correct in French?
-Matt
--- On Wed, 8/26/09, bodewig@apache.org <bo...@apache.org> wrote:
> From: bodewig@apache.org <bo...@apache.org>
> Subject: svn commit: r808018 - in /ant/core/trunk: ./ docs/manual/CoreTypes/ src/main/org/apache/tools/ant/ src/main/org/apache/tools/ant/filters/ src/tests/antunit/filters/ src/tests/antunit/filters/expected/ src/tests/antunit/filters/input/
> To: notifications@ant.apache.org
> Date: Wednesday, August 26, 2009, 9:14 AM
> Author: bodewig
> Date: Wed Aug 26 14:14:12 2009
> New Revision: 808018
>
> URL: http://svn.apache.org/viewvc?rev=808018&view=rev
> Log:
> Now that we have sort, throw in uniq as well
>
> Added:
>
> ant/core/trunk/src/main/org/apache/tools/ant/filters/UniqFilter.java (with
> props)
>
> ant/core/trunk/src/tests/antunit/filters/expected/sortuniq.txt (with
> props)
>
> ant/core/trunk/src/tests/antunit/filters/expected/uniq.txt (with
> props)
>
> ant/core/trunk/src/tests/antunit/filters/input/uniq.txt (with
> props)
>
> ant/core/trunk/src/tests/antunit/filters/uniq-test.xml (with
> props)
> Modified:
> ant/core/trunk/WHATSNEW
>
> ant/core/trunk/docs/manual/CoreTypes/filterchain.html
>
> ant/core/trunk/src/main/org/apache/tools/ant/antlib.xml
>
> Modified: ant/core/trunk/WHATSNEW
> URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=808018&r1=808017&r2=808018&view=diff
> ==============================================================================
> --- ant/core/trunk/WHATSNEW (original)
> +++ ant/core/trunk/WHATSNEW Wed Aug 26 14:14:12 2009
> @@ -927,6 +927,9 @@
> added.
> Bugzilla Report 40504.
>
> + * A new filterreader <uniqfilter> that suppresses
> lines that match
> + their ancestor line has been added.
> +
> Changes from Ant 1.7.0 TO Ant 1.7.1
> =============================================
>
>
> Modified:
> ant/core/trunk/docs/manual/CoreTypes/filterchain.html
> URL: http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/CoreTypes/filterchain.html?rev=808018&r1=808017&r2=808018&view=diff
> ==============================================================================
> --- ant/core/trunk/docs/manual/CoreTypes/filterchain.html
> (original)
> +++ ant/core/trunk/docs/manual/CoreTypes/filterchain.html
> Wed Aug 26 14:14:12 2009
> @@ -125,6 +125,7 @@
> <a
> href="#tokenfilter">TokenFilter</a><br>
> <a
> href="../CoreTasks/fixcrlf.html">FixCRLF</a><br>
> <a
> href="#sortfilter">SortFilter</a><br>
> +<a
> href="#sortfilter">UniqFilter</a><br>
>
> <h3><a
> name="filterreader">FilterReader</a></h3>
>
> @@ -1494,97 +1495,21 @@
> </copy>
> </pre></blockquote>
>
> -<h3><a
> name="sortfilter">SortFilter</a></h3>
> +<h3><a
> name="uniqfilter">UniqFilter</a></h3>
>
> -<p>This filter sorts lines lexicographically but you
> can specifiy a
> - custom comparator as well.</p>
> +<p>Suppresses all lines that match their ancestor
> line. It is most
> + useful if combined with a sort filter.</p>
>
> -<table cellSpacing=0 cellPadding=2 border=1>
> - <tr>
> - <td vAlign=top><b>Parameter
> Type</b></td>
> - <td vAlign=top><b>Parameter
> Value</b></td>
> - <td vAlign=top
> align="center"><b>Required</b></td>
> - </tr>
> - <tr>
> - <td vAlign=top>reverse</td>
> - <td vAlign=top align="center">Whether
> to reverse the sort order
> - (boolean). Will be ignored if a
> custom comparator has been
> - specified.</td>
> - <td vAlign=top
> align="center">No</td>
> - </tr>
> - <tr>
> - <td vAlign=top>comparator</td>
> - <td vAlign=top
> align="center">Classname of a class
> - implementing
> <code>java.util.Comparator</code> an instance
> of
> - which will be used when comparing
> lines.</td>
> - <td vAlign=top
> align="center">No</td>
> - </tr>
> -</table>
> -<p>
> <h4>Example:</h4>
>
> -This will sort the lines.
> +This suppresses duplicate lines.
> <blockquote><pre>
> -<filterreader
> classname="org.apache.tools.ant.filters.SortFilter"/>
> +<filterreader
> classname="org.apache.tools.ant.filters.UniqFilter"/>
> </pre></blockquote>
>
> Convenience method:
> <blockquote><pre>
> -<sortfilter/>
> -</pre></blockquote>
> -
> -This will reverse the sort order.
> -
> -<blockquote><pre>
> -<filterreader
> classname="org.apache.tools.ant.filters.SortFilter">
> - <param name="reverse"
> value="true"/>
> -</filterreader>
> -</pre></blockquote>
> -
> -Convenience method:
> -<blockquote><pre>
> -<sortfilter reverse="true"/>
> -</pre></blockquote>
> -
> -You can use your own comparator, the easiest way is by
> using typedef
> -and the convenience method which allows to specify the
> comparator as a
> -nested element:
> -<blockquote><pre>
> -public final class EvenFirstCmp implements Comparator {
> -
> - public int compare(Object o1, Object o2) {
> - String s1 = ((String)
> o1).substring(5).trim();
> - String s2 = ((String)
> o2).substring(5).trim();
> - int n1 =
> Integer.parseInt(s1);
> - int n2 =
> Integer.parseInt(s2);
> - if (n1 % 2 == 0) {
> - if (n2 % 2 == 0)
> {
> -
> return n1 - n2;
> - } else {
> -
> return -1;
> - }
> - } else {
> - if (n2 % 2 == 0)
> {
> -
> return 1;
> - } else {
> -
> return n1 - n2;
> - }
> - }
> - }
> -}
> -</pre></blockquote>
> -
> -and used as
> -
> -<blockquote><pre>
> -<typedef
> classname="org.apache.tools.ant.filters.EvenFirstCmp"
> -
> name="evenfirst"/>
> -...
> - <filterchain>
> - <sortfilter>
> - <evenfirst/>
> - </sortfilter>
> - </filterchain>
> +<uniqfilter/>
> </pre></blockquote>
>
> </body></html>
>
> Modified:
> ant/core/trunk/src/main/org/apache/tools/ant/antlib.xml
> URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/antlib.xml?rev=808018&r1=808017&r2=808018&view=diff
> ==============================================================================
> --- ant/core/trunk/src/main/org/apache/tools/ant/antlib.xml
> (original)
> +++ ant/core/trunk/src/main/org/apache/tools/ant/antlib.xml
> Wed Aug 26 14:14:12 2009
> @@ -138,5 +138,7 @@
> <!-- filters -->
> <componentdef name="sortfilter"
> onerror="ignore"
>
> classname="org.apache.tools.ant.filters.SortFilter"/>
> + <componentdef name="uniqfilter"
> onerror="ignore"
> +
> classname="org.apache.tools.ant.filters.UniqFilter"/>
> </antlib>
>
>
> Added:
> ant/core/trunk/src/main/org/apache/tools/ant/filters/UniqFilter.java
> URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/filters/UniqFilter.java?rev=808018&view=auto
> ==============================================================================
> ---
> ant/core/trunk/src/main/org/apache/tools/ant/filters/UniqFilter.java
> (added)
> +++
> ant/core/trunk/src/main/org/apache/tools/ant/filters/UniqFilter.java
> Wed Aug 26 14:14:12 2009
> @@ -0,0 +1,69 @@
> +/*
> + * Licensed to the Apache Software Foundation (ASF)
> under one or more
> + * contributor license agreements. See the
> NOTICE file distributed with
> + * this work for additional information regarding
> copyright ownership.
> + * The ASF licenses this file to You under the
> Apache License, Version 2.0
> + * (the "License"); you may not use this file except
> in compliance with
> + * the License. You may obtain a copy of the
> License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in
> writing, software
> + * distributed under the License is distributed on
> an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
> either express or implied.
> + * See the License for the specific language
> governing permissions and
> + * limitations under the License.
> + *
> + */
> +package org.apache.tools.ant.filters;
> +
> +import java.io.IOException;
> +import java.io.Reader;
> +
> +/**
> + * Like the Unix uniq(1) command, only returns lines that
> are
> + * different from their ancestor line.
> + *
> + * <p>This filter is probably most useful if used
> together with a sortfilter.</p>
> + *
> + * @since Ant 1.8.0
> + */
> +public class UniqFilter extends BaseFilterReader
> implements ChainableReader {
> +
> + private String lastLine = null;
> + private String currentLine = null;
> +
> + public UniqFilter() { }
> +
> + public UniqFilter(Reader rdr) {
> + super(rdr);
> + }
> +
> + public int read() throws IOException {
> + int ch = -1;
> + if (currentLine != null) {
> + ch =
> currentLine.charAt(0);
> + if
> (currentLine.length() == 1) {
> +
> currentLine = null;
> + } else {
> +
> currentLine = currentLine.substring(1);
> + }
> + } else {
> + do {
> +
> currentLine = readLine();
> + } while
> (lastLine != null && currentLine != null
> +
> &&
> lastLine.equals(currentLine));
> + lastLine =
> currentLine;
> + if (currentLine
> != null) {
> +
> return read();
> + }
> + }
> + return ch;
> + }
> +
> + public Reader chain(final Reader rdr) {
> + UniqFilter newFilter = new
> UniqFilter(rdr);
> +
> newFilter.setInitialized(true);
> + return newFilter;
> + }
> +}
>
> Propchange:
> ant/core/trunk/src/main/org/apache/tools/ant/filters/UniqFilter.java
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
> Added:
> ant/core/trunk/src/tests/antunit/filters/expected/sortuniq.txt
> URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/filters/expected/sortuniq.txt?rev=808018&view=auto
> ==============================================================================
> ---
> ant/core/trunk/src/tests/antunit/filters/expected/sortuniq.txt
> (added)
> +++
> ant/core/trunk/src/tests/antunit/filters/expected/sortuniq.txt
> Wed Aug 26 14:14:12 2009
> @@ -0,0 +1,4 @@
> +A
> +AA
> +B
> +C
>
> Propchange:
> ant/core/trunk/src/tests/antunit/filters/expected/sortuniq.txt
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
> Added:
> ant/core/trunk/src/tests/antunit/filters/expected/uniq.txt
> URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/filters/expected/uniq.txt?rev=808018&view=auto
> ==============================================================================
> ---
> ant/core/trunk/src/tests/antunit/filters/expected/uniq.txt
> (added)
> +++
> ant/core/trunk/src/tests/antunit/filters/expected/uniq.txt
> Wed Aug 26 14:14:12 2009
> @@ -0,0 +1,5 @@
> +A
> +AA
> +B
> +C
> +B
>
> Propchange:
> ant/core/trunk/src/tests/antunit/filters/expected/uniq.txt
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
> Added:
> ant/core/trunk/src/tests/antunit/filters/input/uniq.txt
> URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/filters/input/uniq.txt?rev=808018&view=auto
> ==============================================================================
> --- ant/core/trunk/src/tests/antunit/filters/input/uniq.txt
> (added)
> +++ ant/core/trunk/src/tests/antunit/filters/input/uniq.txt
> Wed Aug 26 14:14:12 2009
> @@ -0,0 +1,6 @@
> +A
> +AA
> +AA
> +B
> +C
> +B
>
> Propchange:
> ant/core/trunk/src/tests/antunit/filters/input/uniq.txt
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
> Added:
> ant/core/trunk/src/tests/antunit/filters/uniq-test.xml
> URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/filters/uniq-test.xml?rev=808018&view=auto
> ==============================================================================
> --- ant/core/trunk/src/tests/antunit/filters/uniq-test.xml
> (added)
> +++ ant/core/trunk/src/tests/antunit/filters/uniq-test.xml
> Wed Aug 26 14:14:12 2009
> @@ -0,0 +1,49 @@
> +<?xml version="1.0"?>
> +<!--
> + Licensed to the Apache Software
> Foundation (ASF) under one or more
> + contributor license agreements.
> See the NOTICE file distributed with
> + this work for additional information
> regarding copyright ownership.
> + The ASF licenses this file to You under
> the Apache License, Version 2.0
> + (the "License"); you may not use this
> file except in compliance with
> + the License. You may obtain a copy
> of the License at
> +
> + http://www.apache.org/licenses/LICENSE-2.0
> +
> + Unless required by applicable law or
> agreed to in writing, software
> + distributed under the License is
> distributed on an "AS IS" BASIS,
> + WITHOUT WARRANTIES OR CONDITIONS OF ANY
> KIND, either express or implied.
> + See the License for the specific
> language governing permissions and
> + limitations under the License.
> + -->
> +<project default="antunit"
> xmlns:au="antlib:org.apache.ant.antunit">
> + <import file="../antunit-base.xml" />
> +
> + <target name="setUp">
> + <mkdir dir="${output}"/>
> + </target>
> +
> + <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="testSortUniq" depends="setUp">
> + <copy file="input/uniq.txt"
> +
> tofile="${output}/uniq.txt">
> + <filterchain>
> + <sortfilter/>
> + <uniqfilter/>
> + </filterchain>
> + </copy>
> + <au:assertFilesMatch
> +
> expected="expected/sortuniq.txt"
> +
> actual="${output}/uniq.txt"/>
> + </target>
> +</project>
>
> Propchange:
> ant/core/trunk/src/tests/antunit/filters/uniq-test.xml
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
Re: svn commit: r808018 - in /ant/core/trunk: ./ docs/manual/CoreTypes/ src/main/org/apache/tools/ant/ src/main/org/apache/tools/ant/filters/ src/tests/antunit/filters/ src/tests/antunit/filters/expected/ src/tests/antunit/filters/input/
Posted by Stefan Bodewig <bo...@apache.org>.
On 2009-08-26, Matt Benson <gu...@yahoo.com> wrote:
> Do we want to stick to English spellings ("unique") or are we okay
> with "uniq"--presumably correct in French?
I don't speak french (unfortunately).
It really is a reference to uniq(1) on Unix like systems, I have no
problem with changing the name.
Stefan
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
Re: svn commit: r808018 - in /ant/core/trunk: ./ docs/manual/CoreTypes/
src/main/org/apache/tools/ant/ src/main/org/apache/tools/ant/filters/
src/tests/antunit/filters/ src/tests/antunit/filters/expected/
src/tests/antunit/filters/input/
Posted by Dominique Devienne <dd...@gmail.com>.
On Wed, Aug 26, 2009 at 1:35 PM, Matt Benson<gu...@yahoo.com> wrote:
> Is "uniq" correct anywhere?
In *nix lingo only ;) --DD
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
Re: svn commit: r808018 - in /ant/core/trunk: ./ docs/manual/CoreTypes/ src/main/org/apache/tools/ant/ src/main/org/apache/tools/ant/filters/ src/tests/antunit/filters/ src/tests/antunit/filters/expected/ src/tests/antunit/filters/input/
Posted by Matt Benson <gu...@yahoo.com>.
--- On Wed, 8/26/09, Jesse Glick <je...@sun.com> wrote:
> From: Jesse Glick <je...@sun.com>
> Subject: Re: svn commit: r808018 - in /ant/core/trunk: ./ docs/manual/CoreTypes/ src/main/org/apache/tools/ant/ src/main/org/apache/tools/ant/filters/ src/tests/antunit/filters/ src/tests/antunit/filters/expected/ src/tests/antunit/filters/input/
> To: dev@ant.apache.org
> Date: Wednesday, August 26, 2009, 1:44 PM
> Matt Benson wrote:
> > Is "uniq" correct anywhere?
>
> I think the analogy was to /usr/bin/uniq.
>
Thanks Jesse/DD--I wasn't aware of 'uniq', only sort -u ;)
-Matt
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
Re: svn commit: r808018 - in /ant/core/trunk: ./ docs/manual/CoreTypes/
src/main/org/apache/tools/ant/ src/main/org/apache/tools/ant/filters/ src/tests/antunit/filters/
src/tests/antunit/filters/expected/ src/tests/antunit/filters/input/
Posted by Jesse Glick <je...@sun.com>.
Matt Benson wrote:
> Is "uniq" correct anywhere?
I think the analogy was to /usr/bin/uniq.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
Re: svn commit: r808018 - in /ant/core/trunk: ./ docs/manual/CoreTypes/ src/main/org/apache/tools/ant/ src/main/org/apache/tools/ant/filters/ src/tests/antunit/filters/ src/tests/antunit/filters/expected/ src/tests/antunit/filters/input/
Posted by Matt Benson <gu...@yahoo.com>.
:) Guess I should have known that "-que" was common in French, given our own DD... was working from the fact that "unique" was given as being of Fr. etymology at webster.com . Is "uniq" correct anywhere?
-Matt
--- On Wed, 8/26/09, Gilles Scokart <gs...@gmail.com> wrote:
> From: Gilles Scokart <gs...@gmail.com>
> Subject: Re: svn commit: r808018 - in /ant/core/trunk: ./ docs/manual/CoreTypes/ src/main/org/apache/tools/ant/ src/main/org/apache/tools/ant/filters/ src/tests/antunit/filters/ src/tests/antunit/filters/expected/ src/tests/antunit/filters/input/
> To: "Ant Developers List" <de...@ant.apache.org>
> Date: Wednesday, August 26, 2009, 1:09 PM
> The French translation of unique is
> ... "unique".
>
>
> Gilles Scokart
>
>
> 2009/8/26 Matt Benson <gu...@yahoo.com>
>
> > Do we want to stick to English spellings ("unique") or
> are we okay with
> > "uniq"--presumably correct in French?
> >
> > -Matt
> >
> > --- On Wed, 8/26/09, bodewig@apache.org
> <bo...@apache.org>
> wrote:
> >
> > > From: bodewig@apache.org
> <bo...@apache.org>
> > > Subject: svn commit: r808018 - in
> /ant/core/trunk: ./
> > docs/manual/CoreTypes/ src/main/org/apache/tools/ant/
> > src/main/org/apache/tools/ant/filters/
> src/tests/antunit/filters/
> > src/tests/antunit/filters/expected/
> src/tests/antunit/filters/input/
> > > To: notifications@ant.apache.org
> > > Date: Wednesday, August 26, 2009, 9:14 AM
> > > Author: bodewig
> > > Date: Wed Aug 26 14:14:12 2009
> > > New Revision: 808018
> > >
> > > URL: http://svn.apache.org/viewvc?rev=808018&view=rev
> > > Log:
> > > Now that we have sort, throw in uniq as well
> > >
> > > Added:
> > >
> > >
> >
> ant/core/trunk/src/main/org/apache/tools/ant/filters/UniqFilter.java (with
> > > props)
> > >
> > >
> ant/core/trunk/src/tests/antunit/filters/expected/sortuniq.txt (with
> > > props)
> > >
> > >
> ant/core/trunk/src/tests/antunit/filters/expected/uniq.txt (with
> > > props)
> > >
> > >
> ant/core/trunk/src/tests/antunit/filters/input/uniq.txt (with
> > > props)
> > >
> > >
> ant/core/trunk/src/tests/antunit/filters/uniq-test.xml (with
> > > props)
> > > Modified:
> > > ant/core/trunk/WHATSNEW
> > >
> > >
> ant/core/trunk/docs/manual/CoreTypes/filterchain.html
> > >
> > >
> ant/core/trunk/src/main/org/apache/tools/ant/antlib.xml
> > >
> > > Modified: ant/core/trunk/WHATSNEW
> > > URL:
> > http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=808018&r1=808017&r2=808018&view=diff
> > >
> >
> ==============================================================================
> > > --- ant/core/trunk/WHATSNEW (original)
> > > +++ ant/core/trunk/WHATSNEW Wed Aug 26 14:14:12
> 2009
> > > @@ -927,6 +927,9 @@
> > > added.
> > > Bugzilla Report 40504.
> > >
> > > + * A new filterreader <uniqfilter> that
> suppresses
> > > lines that match
> > > + their ancestor line has been
> added.
> > > +
> > > Changes from Ant 1.7.0 TO Ant 1.7.1
> > >
> =============================================
> > >
> > >
> > > Modified:
> > >
> ant/core/trunk/docs/manual/CoreTypes/filterchain.html
> > > URL:
> > http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/CoreTypes/filterchain.html?rev=808018&r1=808017&r2=808018&view=diff
> > >
> >
> ==============================================================================
> > > ---
> ant/core/trunk/docs/manual/CoreTypes/filterchain.html
> > > (original)
> > > +++
> ant/core/trunk/docs/manual/CoreTypes/filterchain.html
> > > Wed Aug 26 14:14:12 2009
> > > @@ -125,6 +125,7 @@
> > > <a
> > >
> href="#tokenfilter">TokenFilter</a><br>
> > > <a
> > >
> href="../CoreTasks/fixcrlf.html">FixCRLF</a><br>
> > > <a
> > >
> href="#sortfilter">SortFilter</a><br>
> > > +<a
> > >
> href="#sortfilter">UniqFilter</a><br>
> > >
> > > <h3><a
> > >
> name="filterreader">FilterReader</a></h3>
> > >
> > > @@ -1494,97 +1495,21 @@
> > > </copy>
> > > </pre></blockquote>
> > >
> > > -<h3><a
> > >
> name="sortfilter">SortFilter</a></h3>
> > > +<h3><a
> > >
> name="uniqfilter">UniqFilter</a></h3>
> > >
> > > -<p>This filter sorts lines
> lexicographically but you
> > > can specifiy a
> > > - custom comparator as well.</p>
> > > +<p>Suppresses all lines that match their
> ancestor
> > > line. It is most
> > > + useful if combined with a sort
> filter.</p>
> > >
> > > -<table cellSpacing=0 cellPadding=2
> border=1>
> > > - <tr>
> > > - <td
> vAlign=top><b>Parameter
> > > Type</b></td>
> > > - <td
> vAlign=top><b>Parameter
> > > Value</b></td>
> > > - <td vAlign=top
> > >
> align="center"><b>Required</b></td>
> > > - </tr>
> > > - <tr>
> > > - <td
> vAlign=top>reverse</td>
> > > - <td vAlign=top
> align="center">Whether
> > > to reverse the sort order
> > > - (boolean). Will be
> ignored if a
> > > custom comparator has been
> > > - specified.</td>
> > > - <td vAlign=top
> > > align="center">No</td>
> > > - </tr>
> > > - <tr>
> > > - <td
> vAlign=top>comparator</td>
> > > - <td vAlign=top
> > > align="center">Classname of a class
> > > - implementing
> > > <code>java.util.Comparator</code> an
> instance
> > > of
> > > - which will be used when
> comparing
> > > lines.</td>
> > > - <td vAlign=top
> > > align="center">No</td>
> > > - </tr>
> > > -</table>
> > > -<p>
> > > <h4>Example:</h4>
> > >
> > > -This will sort the lines.
> > > +This suppresses duplicate lines.
> > > <blockquote><pre>
> > > -<filterreader
> > >
> classname="org.apache.tools.ant.filters.SortFilter"/>
> > > +<filterreader
> > >
> classname="org.apache.tools.ant.filters.UniqFilter"/>
> > > </pre></blockquote>
> > >
> > > Convenience method:
> > > <blockquote><pre>
> > > -<sortfilter/>
> > > -</pre></blockquote>
> > > -
> > > -This will reverse the sort order.
> > > -
> > > -<blockquote><pre>
> > > -<filterreader
> > >
> classname="org.apache.tools.ant.filters.SortFilter">
> > > - <param name="reverse"
> > > value="true"/>
> > > -</filterreader>
> > > -</pre></blockquote>
> > > -
> > > -Convenience method:
> > > -<blockquote><pre>
> > > -<sortfilter reverse="true"/>
> > > -</pre></blockquote>
> > > -
> > > -You can use your own comparator, the easiest way
> is by
> > > using typedef
> > > -and the convenience method which allows to
> specify the
> > > comparator as a
> > > -nested element:
> > > -<blockquote><pre>
> > > -public final class EvenFirstCmp implements
> Comparator {
> > > -
> > > - public int compare(Object o1,
> Object o2) {
> > > - String s1 =
> ((String)
> > > o1).substring(5).trim();
> > > - String s2 =
> ((String)
> > > o2).substring(5).trim();
> > > - int n1 =
> > > Integer.parseInt(s1);
> > > - int n2 =
> > > Integer.parseInt(s2);
> > > - if (n1 % 2 == 0) {
> > > - if (n2
> % 2 == 0)
> > > {
> > > -
> > > return n1 - n2;
> > > - } else
> {
> > > -
> > > return -1;
> > > - }
> > > - } else {
> > > - if (n2
> % 2 == 0)
> > > {
> > > -
> > > return 1;
> > > - } else
> {
> > > -
> > > return n1 - n2;
> > > - }
> > > - }
> > > - }
> > > -}
> > > -</pre></blockquote>
> > > -
> > > -and used as
> > > -
> > > -<blockquote><pre>
> > > -<typedef
> > >
> classname="org.apache.tools.ant.filters.EvenFirstCmp"
> > > -
> > > name="evenfirst"/>
> > > -...
> > > - <filterchain>
> > > - <sortfilter>
> > > - <evenfirst/>
> > > - </sortfilter>
> > > - </filterchain>
> > > +<uniqfilter/>
> > > </pre></blockquote>
> > >
> > > </body></html>
> > >
> > > Modified:
> > >
> ant/core/trunk/src/main/org/apache/tools/ant/antlib.xml
> > > URL:
> > http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/antlib.xml?rev=808018&r1=808017&r2=808018&view=diff
> > >
> >
> ==============================================================================
> > > ---
> ant/core/trunk/src/main/org/apache/tools/ant/antlib.xml
> > > (original)
> > > +++
> ant/core/trunk/src/main/org/apache/tools/ant/antlib.xml
> > > Wed Aug 26 14:14:12 2009
> > > @@ -138,5 +138,7 @@
> > > <!-- filters -->
> > > <componentdef name="sortfilter"
> > > onerror="ignore"
> > >
> > >
> classname="org.apache.tools.ant.filters.SortFilter"/>
> > > + <componentdef name="uniqfilter"
> > > onerror="ignore"
> > > +
> > >
> classname="org.apache.tools.ant.filters.UniqFilter"/>
> > > </antlib>
> > >
> > >
> > > Added:
> > >
> ant/core/trunk/src/main/org/apache/tools/ant/filters/UniqFilter.java
> > > URL:
> > http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/filters/UniqFilter.java?rev=808018&view=auto
> > >
> >
> ==============================================================================
> > > ---
> > >
> ant/core/trunk/src/main/org/apache/tools/ant/filters/UniqFilter.java
> > > (added)
> > > +++
> > >
> ant/core/trunk/src/main/org/apache/tools/ant/filters/UniqFilter.java
> > > Wed Aug 26 14:14:12 2009
> > > @@ -0,0 +1,69 @@
> > > +/*
> > > + * Licensed to the Apache Software
> Foundation (ASF)
> > > under one or more
> > > + * contributor license agreements.
> See the
> > > NOTICE file distributed with
> > > + * this work for additional information
> regarding
> > > copyright ownership.
> > > + * The ASF licenses this file to You under
> the
> > > Apache License, Version 2.0
> > > + * (the "License"); you may not use this
> file except
> > > in compliance with
> > > + * the License. You may obtain a
> copy of the
> > > License at
> > > + *
> > > + * http://www.apache.org/licenses/LICENSE-2.0
> > > + *
> > > + * Unless required by applicable law or
> agreed to in
> > > writing, software
> > > + * distributed under the License is
> distributed on
> > > an "AS IS" BASIS,
> > > + * WITHOUT WARRANTIES OR CONDITIONS OF ANY
> KIND,
> > > either express or implied.
> > > + * See the License for the specific
> language
> > > governing permissions and
> > > + * limitations under the License.
> > > + *
> > > + */
> > > +package org.apache.tools.ant.filters;
> > > +
> > > +import java.io.IOException;
> > > +import java.io.Reader;
> > > +
> > > +/**
> > > + * Like the Unix uniq(1) command, only returns
> lines that
> > > are
> > > + * different from their ancestor line.
> > > + *
> > > + * <p>This filter is probably most useful
> if used
> > > together with a sortfilter.</p>
> > > + *
> > > + * @since Ant 1.8.0
> > > + */
> > > +public class UniqFilter extends
> BaseFilterReader
> > > implements ChainableReader {
> > > +
> > > + private String lastLine = null;
> > > + private String currentLine =
> null;
> > > +
> > > + public UniqFilter() { }
> > > +
> > > + public UniqFilter(Reader rdr) {
> > > + super(rdr);
> > > + }
> > > +
> > > + public int read() throws
> IOException {
> > > + int ch = -1;
> > > + if (currentLine !=
> null) {
> > > + ch =
> > > currentLine.charAt(0);
> > > + if
> > > (currentLine.length() == 1) {
> > > +
> > > currentLine = null;
> > > + } else
> {
> > > +
> > > currentLine = currentLine.substring(1);
> > > + }
> > > + } else {
> > > + do {
> > > +
> > > currentLine = readLine();
> > > + }
> while
> > > (lastLine != null && currentLine != null
> > > +
> > > &&
> > > lastLine.equals(currentLine));
> > > +
> lastLine =
> > > currentLine;
> > > + if
> (currentLine
> > > != null) {
> > > +
> > > return read();
> > > + }
> > > + }
> > > + return ch;
> > > + }
> > > +
> > > + public Reader chain(final Reader
> rdr) {
> > > + UniqFilter newFilter
> = new
> > > UniqFilter(rdr);
> > > +
> > > newFilter.setInitialized(true);
> > > + return newFilter;
> > > + }
> > > +}
> > >
> > > Propchange:
> > >
> ant/core/trunk/src/main/org/apache/tools/ant/filters/UniqFilter.java
> > >
> >
> ------------------------------------------------------------------------------
> > > svn:eol-style = native
> > >
> > > Added:
> > >
> ant/core/trunk/src/tests/antunit/filters/expected/sortuniq.txt
> > > URL:
> > http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/filters/expected/sortuniq.txt?rev=808018&view=auto
> > >
> >
> ==============================================================================
> > > ---
> > >
> ant/core/trunk/src/tests/antunit/filters/expected/sortuniq.txt
> > > (added)
> > > +++
> > >
> ant/core/trunk/src/tests/antunit/filters/expected/sortuniq.txt
> > > Wed Aug 26 14:14:12 2009
> > > @@ -0,0 +1,4 @@
> > > +A
> > > +AA
> > > +B
> > > +C
> > >
> > > Propchange:
> > >
> ant/core/trunk/src/tests/antunit/filters/expected/sortuniq.txt
> > >
> >
> ------------------------------------------------------------------------------
> > > svn:eol-style = native
> > >
> > > Added:
> > >
> ant/core/trunk/src/tests/antunit/filters/expected/uniq.txt
> > > URL:
> > http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/filters/expected/uniq.txt?rev=808018&view=auto
> > >
> >
> ==============================================================================
> > > ---
> > >
> ant/core/trunk/src/tests/antunit/filters/expected/uniq.txt
> > > (added)
> > > +++
> > >
> ant/core/trunk/src/tests/antunit/filters/expected/uniq.txt
> > > Wed Aug 26 14:14:12 2009
> > > @@ -0,0 +1,5 @@
> > > +A
> > > +AA
> > > +B
> > > +C
> > > +B
> > >
> > > Propchange:
> > >
> ant/core/trunk/src/tests/antunit/filters/expected/uniq.txt
> > >
> >
> ------------------------------------------------------------------------------
> > > svn:eol-style = native
> > >
> > > Added:
> > >
> ant/core/trunk/src/tests/antunit/filters/input/uniq.txt
> > > URL:
> > http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/filters/input/uniq.txt?rev=808018&view=auto
> > >
> >
> ==============================================================================
> > > ---
> ant/core/trunk/src/tests/antunit/filters/input/uniq.txt
> > > (added)
> > > +++
> ant/core/trunk/src/tests/antunit/filters/input/uniq.txt
> > > Wed Aug 26 14:14:12 2009
> > > @@ -0,0 +1,6 @@
> > > +A
> > > +AA
> > > +AA
> > > +B
> > > +C
> > > +B
> > >
> > > Propchange:
> > >
> ant/core/trunk/src/tests/antunit/filters/input/uniq.txt
> > >
> >
> ------------------------------------------------------------------------------
> > > svn:eol-style = native
> > >
> > > Added:
> > >
> ant/core/trunk/src/tests/antunit/filters/uniq-test.xml
> > > URL:
> > http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/filters/uniq-test.xml?rev=808018&view=auto
> > >
> >
> ==============================================================================
> > > ---
> ant/core/trunk/src/tests/antunit/filters/uniq-test.xml
> > > (added)
> > > +++
> ant/core/trunk/src/tests/antunit/filters/uniq-test.xml
> > > Wed Aug 26 14:14:12 2009
> > > @@ -0,0 +1,49 @@
> > > +<?xml version="1.0"?>
> > > +<!--
> > > + Licensed to the Apache
> Software
> > > Foundation (ASF) under one or more
> > > + contributor license
> agreements.
> > > See the NOTICE file distributed with
> > > + this work for additional
> information
> > > regarding copyright ownership.
> > > + The ASF licenses this file to
> You under
> > > the Apache License, Version 2.0
> > > + (the "License"); you may not
> use this
> > > file except in compliance with
> > > + the License. You may
> obtain a copy
> > > of the License at
> > > +
> > > + http://www.apache.org/licenses/LICENSE-2.0
> > > +
> > > + Unless required by applicable
> law or
> > > agreed to in writing, software
> > > + distributed under the License
> is
> > > distributed on an "AS IS" BASIS,
> > > + WITHOUT WARRANTIES OR
> CONDITIONS OF ANY
> > > KIND, either express or implied.
> > > + See the License for the
> specific
> > > language governing permissions and
> > > + limitations under the
> License.
> > > + -->
> > > +<project default="antunit"
> > > xmlns:au="antlib:org.apache.ant.antunit">
> > > + <import file="../antunit-base.xml"
> />
> > > +
> > > + <target name="setUp">
> > > + <mkdir dir="${output}"/>
> > > + </target>
> > > +
> > > + <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="testSortUniq"
> depends="setUp">
> > > + <copy file="input/uniq.txt"
> > > +
> > > tofile="${output}/uniq.txt">
> > > + <filterchain>
> > > + <sortfilter/>
> > > + <uniqfilter/>
> > > + </filterchain>
> > > + </copy>
> > > + <au:assertFilesMatch
> > > +
> > > expected="expected/sortuniq.txt"
> > > +
> > > actual="${output}/uniq.txt"/>
> > > + </target>
> > > +</project>
> > >
> > > Propchange:
> > >
> ant/core/trunk/src/tests/antunit/filters/uniq-test.xml
> > >
> >
> ------------------------------------------------------------------------------
> > > svn:eol-style = native
> > >
> > >
> > >
> >
> >
> >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> > For additional commands, e-mail: dev-help@ant.apache.org
> >
> >
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org
Re: svn commit: r808018 - in /ant/core/trunk: ./ docs/manual/CoreTypes/
src/main/org/apache/tools/ant/ src/main/org/apache/tools/ant/filters/
src/tests/antunit/filters/ src/tests/antunit/filters/expected/
src/tests/antunit/filters/input/
Posted by Gilles Scokart <gs...@gmail.com>.
The French translation of unique is ... "unique".
Gilles Scokart
2009/8/26 Matt Benson <gu...@yahoo.com>
> Do we want to stick to English spellings ("unique") or are we okay with
> "uniq"--presumably correct in French?
>
> -Matt
>
> --- On Wed, 8/26/09, bodewig@apache.org <bo...@apache.org> wrote:
>
> > From: bodewig@apache.org <bo...@apache.org>
> > Subject: svn commit: r808018 - in /ant/core/trunk: ./
> docs/manual/CoreTypes/ src/main/org/apache/tools/ant/
> src/main/org/apache/tools/ant/filters/ src/tests/antunit/filters/
> src/tests/antunit/filters/expected/ src/tests/antunit/filters/input/
> > To: notifications@ant.apache.org
> > Date: Wednesday, August 26, 2009, 9:14 AM
> > Author: bodewig
> > Date: Wed Aug 26 14:14:12 2009
> > New Revision: 808018
> >
> > URL: http://svn.apache.org/viewvc?rev=808018&view=rev
> > Log:
> > Now that we have sort, throw in uniq as well
> >
> > Added:
> >
> >
> ant/core/trunk/src/main/org/apache/tools/ant/filters/UniqFilter.java (with
> > props)
> >
> > ant/core/trunk/src/tests/antunit/filters/expected/sortuniq.txt (with
> > props)
> >
> > ant/core/trunk/src/tests/antunit/filters/expected/uniq.txt (with
> > props)
> >
> > ant/core/trunk/src/tests/antunit/filters/input/uniq.txt (with
> > props)
> >
> > ant/core/trunk/src/tests/antunit/filters/uniq-test.xml (with
> > props)
> > Modified:
> > ant/core/trunk/WHATSNEW
> >
> > ant/core/trunk/docs/manual/CoreTypes/filterchain.html
> >
> > ant/core/trunk/src/main/org/apache/tools/ant/antlib.xml
> >
> > Modified: ant/core/trunk/WHATSNEW
> > URL:
> http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=808018&r1=808017&r2=808018&view=diff
> >
> ==============================================================================
> > --- ant/core/trunk/WHATSNEW (original)
> > +++ ant/core/trunk/WHATSNEW Wed Aug 26 14:14:12 2009
> > @@ -927,6 +927,9 @@
> > added.
> > Bugzilla Report 40504.
> >
> > + * A new filterreader <uniqfilter> that suppresses
> > lines that match
> > + their ancestor line has been added.
> > +
> > Changes from Ant 1.7.0 TO Ant 1.7.1
> > =============================================
> >
> >
> > Modified:
> > ant/core/trunk/docs/manual/CoreTypes/filterchain.html
> > URL:
> http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/CoreTypes/filterchain.html?rev=808018&r1=808017&r2=808018&view=diff
> >
> ==============================================================================
> > --- ant/core/trunk/docs/manual/CoreTypes/filterchain.html
> > (original)
> > +++ ant/core/trunk/docs/manual/CoreTypes/filterchain.html
> > Wed Aug 26 14:14:12 2009
> > @@ -125,6 +125,7 @@
> > <a
> > href="#tokenfilter">TokenFilter</a><br>
> > <a
> > href="../CoreTasks/fixcrlf.html">FixCRLF</a><br>
> > <a
> > href="#sortfilter">SortFilter</a><br>
> > +<a
> > href="#sortfilter">UniqFilter</a><br>
> >
> > <h3><a
> > name="filterreader">FilterReader</a></h3>
> >
> > @@ -1494,97 +1495,21 @@
> > </copy>
> > </pre></blockquote>
> >
> > -<h3><a
> > name="sortfilter">SortFilter</a></h3>
> > +<h3><a
> > name="uniqfilter">UniqFilter</a></h3>
> >
> > -<p>This filter sorts lines lexicographically but you
> > can specifiy a
> > - custom comparator as well.</p>
> > +<p>Suppresses all lines that match their ancestor
> > line. It is most
> > + useful if combined with a sort filter.</p>
> >
> > -<table cellSpacing=0 cellPadding=2 border=1>
> > - <tr>
> > - <td vAlign=top><b>Parameter
> > Type</b></td>
> > - <td vAlign=top><b>Parameter
> > Value</b></td>
> > - <td vAlign=top
> > align="center"><b>Required</b></td>
> > - </tr>
> > - <tr>
> > - <td vAlign=top>reverse</td>
> > - <td vAlign=top align="center">Whether
> > to reverse the sort order
> > - (boolean). Will be ignored if a
> > custom comparator has been
> > - specified.</td>
> > - <td vAlign=top
> > align="center">No</td>
> > - </tr>
> > - <tr>
> > - <td vAlign=top>comparator</td>
> > - <td vAlign=top
> > align="center">Classname of a class
> > - implementing
> > <code>java.util.Comparator</code> an instance
> > of
> > - which will be used when comparing
> > lines.</td>
> > - <td vAlign=top
> > align="center">No</td>
> > - </tr>
> > -</table>
> > -<p>
> > <h4>Example:</h4>
> >
> > -This will sort the lines.
> > +This suppresses duplicate lines.
> > <blockquote><pre>
> > -<filterreader
> > classname="org.apache.tools.ant.filters.SortFilter"/>
> > +<filterreader
> > classname="org.apache.tools.ant.filters.UniqFilter"/>
> > </pre></blockquote>
> >
> > Convenience method:
> > <blockquote><pre>
> > -<sortfilter/>
> > -</pre></blockquote>
> > -
> > -This will reverse the sort order.
> > -
> > -<blockquote><pre>
> > -<filterreader
> > classname="org.apache.tools.ant.filters.SortFilter">
> > - <param name="reverse"
> > value="true"/>
> > -</filterreader>
> > -</pre></blockquote>
> > -
> > -Convenience method:
> > -<blockquote><pre>
> > -<sortfilter reverse="true"/>
> > -</pre></blockquote>
> > -
> > -You can use your own comparator, the easiest way is by
> > using typedef
> > -and the convenience method which allows to specify the
> > comparator as a
> > -nested element:
> > -<blockquote><pre>
> > -public final class EvenFirstCmp implements Comparator {
> > -
> > - public int compare(Object o1, Object o2) {
> > - String s1 = ((String)
> > o1).substring(5).trim();
> > - String s2 = ((String)
> > o2).substring(5).trim();
> > - int n1 =
> > Integer.parseInt(s1);
> > - int n2 =
> > Integer.parseInt(s2);
> > - if (n1 % 2 == 0) {
> > - if (n2 % 2 == 0)
> > {
> > -
> > return n1 - n2;
> > - } else {
> > -
> > return -1;
> > - }
> > - } else {
> > - if (n2 % 2 == 0)
> > {
> > -
> > return 1;
> > - } else {
> > -
> > return n1 - n2;
> > - }
> > - }
> > - }
> > -}
> > -</pre></blockquote>
> > -
> > -and used as
> > -
> > -<blockquote><pre>
> > -<typedef
> > classname="org.apache.tools.ant.filters.EvenFirstCmp"
> > -
> > name="evenfirst"/>
> > -...
> > - <filterchain>
> > - <sortfilter>
> > - <evenfirst/>
> > - </sortfilter>
> > - </filterchain>
> > +<uniqfilter/>
> > </pre></blockquote>
> >
> > </body></html>
> >
> > Modified:
> > ant/core/trunk/src/main/org/apache/tools/ant/antlib.xml
> > URL:
> http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/antlib.xml?rev=808018&r1=808017&r2=808018&view=diff
> >
> ==============================================================================
> > --- ant/core/trunk/src/main/org/apache/tools/ant/antlib.xml
> > (original)
> > +++ ant/core/trunk/src/main/org/apache/tools/ant/antlib.xml
> > Wed Aug 26 14:14:12 2009
> > @@ -138,5 +138,7 @@
> > <!-- filters -->
> > <componentdef name="sortfilter"
> > onerror="ignore"
> >
> > classname="org.apache.tools.ant.filters.SortFilter"/>
> > + <componentdef name="uniqfilter"
> > onerror="ignore"
> > +
> > classname="org.apache.tools.ant.filters.UniqFilter"/>
> > </antlib>
> >
> >
> > Added:
> > ant/core/trunk/src/main/org/apache/tools/ant/filters/UniqFilter.java
> > URL:
> http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/filters/UniqFilter.java?rev=808018&view=auto
> >
> ==============================================================================
> > ---
> > ant/core/trunk/src/main/org/apache/tools/ant/filters/UniqFilter.java
> > (added)
> > +++
> > ant/core/trunk/src/main/org/apache/tools/ant/filters/UniqFilter.java
> > Wed Aug 26 14:14:12 2009
> > @@ -0,0 +1,69 @@
> > +/*
> > + * Licensed to the Apache Software Foundation (ASF)
> > under one or more
> > + * contributor license agreements. See the
> > NOTICE file distributed with
> > + * this work for additional information regarding
> > copyright ownership.
> > + * The ASF licenses this file to You under the
> > Apache License, Version 2.0
> > + * (the "License"); you may not use this file except
> > in compliance with
> > + * the License. You may obtain a copy of the
> > License at
> > + *
> > + * http://www.apache.org/licenses/LICENSE-2.0
> > + *
> > + * Unless required by applicable law or agreed to in
> > writing, software
> > + * distributed under the License is distributed on
> > an "AS IS" BASIS,
> > + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
> > either express or implied.
> > + * See the License for the specific language
> > governing permissions and
> > + * limitations under the License.
> > + *
> > + */
> > +package org.apache.tools.ant.filters;
> > +
> > +import java.io.IOException;
> > +import java.io.Reader;
> > +
> > +/**
> > + * Like the Unix uniq(1) command, only returns lines that
> > are
> > + * different from their ancestor line.
> > + *
> > + * <p>This filter is probably most useful if used
> > together with a sortfilter.</p>
> > + *
> > + * @since Ant 1.8.0
> > + */
> > +public class UniqFilter extends BaseFilterReader
> > implements ChainableReader {
> > +
> > + private String lastLine = null;
> > + private String currentLine = null;
> > +
> > + public UniqFilter() { }
> > +
> > + public UniqFilter(Reader rdr) {
> > + super(rdr);
> > + }
> > +
> > + public int read() throws IOException {
> > + int ch = -1;
> > + if (currentLine != null) {
> > + ch =
> > currentLine.charAt(0);
> > + if
> > (currentLine.length() == 1) {
> > +
> > currentLine = null;
> > + } else {
> > +
> > currentLine = currentLine.substring(1);
> > + }
> > + } else {
> > + do {
> > +
> > currentLine = readLine();
> > + } while
> > (lastLine != null && currentLine != null
> > +
> > &&
> > lastLine.equals(currentLine));
> > + lastLine =
> > currentLine;
> > + if (currentLine
> > != null) {
> > +
> > return read();
> > + }
> > + }
> > + return ch;
> > + }
> > +
> > + public Reader chain(final Reader rdr) {
> > + UniqFilter newFilter = new
> > UniqFilter(rdr);
> > +
> > newFilter.setInitialized(true);
> > + return newFilter;
> > + }
> > +}
> >
> > Propchange:
> > ant/core/trunk/src/main/org/apache/tools/ant/filters/UniqFilter.java
> >
> ------------------------------------------------------------------------------
> > svn:eol-style = native
> >
> > Added:
> > ant/core/trunk/src/tests/antunit/filters/expected/sortuniq.txt
> > URL:
> http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/filters/expected/sortuniq.txt?rev=808018&view=auto
> >
> ==============================================================================
> > ---
> > ant/core/trunk/src/tests/antunit/filters/expected/sortuniq.txt
> > (added)
> > +++
> > ant/core/trunk/src/tests/antunit/filters/expected/sortuniq.txt
> > Wed Aug 26 14:14:12 2009
> > @@ -0,0 +1,4 @@
> > +A
> > +AA
> > +B
> > +C
> >
> > Propchange:
> > ant/core/trunk/src/tests/antunit/filters/expected/sortuniq.txt
> >
> ------------------------------------------------------------------------------
> > svn:eol-style = native
> >
> > Added:
> > ant/core/trunk/src/tests/antunit/filters/expected/uniq.txt
> > URL:
> http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/filters/expected/uniq.txt?rev=808018&view=auto
> >
> ==============================================================================
> > ---
> > ant/core/trunk/src/tests/antunit/filters/expected/uniq.txt
> > (added)
> > +++
> > ant/core/trunk/src/tests/antunit/filters/expected/uniq.txt
> > Wed Aug 26 14:14:12 2009
> > @@ -0,0 +1,5 @@
> > +A
> > +AA
> > +B
> > +C
> > +B
> >
> > Propchange:
> > ant/core/trunk/src/tests/antunit/filters/expected/uniq.txt
> >
> ------------------------------------------------------------------------------
> > svn:eol-style = native
> >
> > Added:
> > ant/core/trunk/src/tests/antunit/filters/input/uniq.txt
> > URL:
> http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/filters/input/uniq.txt?rev=808018&view=auto
> >
> ==============================================================================
> > --- ant/core/trunk/src/tests/antunit/filters/input/uniq.txt
> > (added)
> > +++ ant/core/trunk/src/tests/antunit/filters/input/uniq.txt
> > Wed Aug 26 14:14:12 2009
> > @@ -0,0 +1,6 @@
> > +A
> > +AA
> > +AA
> > +B
> > +C
> > +B
> >
> > Propchange:
> > ant/core/trunk/src/tests/antunit/filters/input/uniq.txt
> >
> ------------------------------------------------------------------------------
> > svn:eol-style = native
> >
> > Added:
> > ant/core/trunk/src/tests/antunit/filters/uniq-test.xml
> > URL:
> http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/filters/uniq-test.xml?rev=808018&view=auto
> >
> ==============================================================================
> > --- ant/core/trunk/src/tests/antunit/filters/uniq-test.xml
> > (added)
> > +++ ant/core/trunk/src/tests/antunit/filters/uniq-test.xml
> > Wed Aug 26 14:14:12 2009
> > @@ -0,0 +1,49 @@
> > +<?xml version="1.0"?>
> > +<!--
> > + Licensed to the Apache Software
> > Foundation (ASF) under one or more
> > + contributor license agreements.
> > See the NOTICE file distributed with
> > + this work for additional information
> > regarding copyright ownership.
> > + The ASF licenses this file to You under
> > the Apache License, Version 2.0
> > + (the "License"); you may not use this
> > file except in compliance with
> > + the License. You may obtain a copy
> > of the License at
> > +
> > + http://www.apache.org/licenses/LICENSE-2.0
> > +
> > + Unless required by applicable law or
> > agreed to in writing, software
> > + distributed under the License is
> > distributed on an "AS IS" BASIS,
> > + WITHOUT WARRANTIES OR CONDITIONS OF ANY
> > KIND, either express or implied.
> > + See the License for the specific
> > language governing permissions and
> > + limitations under the License.
> > + -->
> > +<project default="antunit"
> > xmlns:au="antlib:org.apache.ant.antunit">
> > + <import file="../antunit-base.xml" />
> > +
> > + <target name="setUp">
> > + <mkdir dir="${output}"/>
> > + </target>
> > +
> > + <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="testSortUniq" depends="setUp">
> > + <copy file="input/uniq.txt"
> > +
> > tofile="${output}/uniq.txt">
> > + <filterchain>
> > + <sortfilter/>
> > + <uniqfilter/>
> > + </filterchain>
> > + </copy>
> > + <au:assertFilesMatch
> > +
> > expected="expected/sortuniq.txt"
> > +
> > actual="${output}/uniq.txt"/>
> > + </target>
> > +</project>
> >
> > Propchange:
> > ant/core/trunk/src/tests/antunit/filters/uniq-test.xml
> >
> ------------------------------------------------------------------------------
> > svn:eol-style = native
> >
> >
> >
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
>
>