|
|
@@ -125,6 +125,7 @@ nested elements.<br> |
|
|
|
<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 @@ This may be used as follows: |
|
|
|
</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. |
|
|
|
<blockquote><pre> |
|
|
|
<filterreader classname="org.apache.tools.ant.filters.SortFilter"/> |
|
|
|
</pre></blockquote> |
|
|
|
|
|
|
|
Convenience method: |
|
|
|
<blockquote><pre> |
|
|
|
<sortfilter/> |
|
|
|
</pre></blockquote> |
|
|
|
|
|
|
|
This will reverse the sort order. |
|
|
|
|
|
|
|
This suppresses duplicate lines. |
|
|
|
<blockquote><pre> |
|
|
|
<filterreader classname="org.apache.tools.ant.filters.SortFilter"> |
|
|
|
<param name="reverse" value="true"/> |
|
|
|
</filterreader> |
|
|
|
<filterreader classname="org.apache.tools.ant.filters.UniqFilter"/> |
|
|
|
</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> |