diff --git a/docs/manual/CoreTypes/filterchain.html b/docs/manual/CoreTypes/filterchain.html index 7002362d0..f99550528 100644 --- a/docs/manual/CoreTypes/filterchain.html +++ b/docs/manual/CoreTypes/filterchain.html @@ -1547,8 +1547,116 @@ This may be used as follows:
(documentation pending)
since Ant 1.8.0
+The sort filter reads all lines and sorts them. The sort order can
+ be reversed and it is possible to specify a custom implementation of
+ the java.util.Comparator
interface to get even more
+ control.
Parameter Name | +Parameter Value | +Required | +
reverse | +whether to reverse the sort order, + defaults to false. Note: this parameter is ignored if + the comparator parameter is present as well. | +No | +
comparator | +Class name of a class that
+ implements java.util.Comparator for Strings. This
+ class will be used to determine the sort order of lines. |
+ No | +
This filter is also available using the
+ name sortfilter
. The reverse
parameter
+ becomes an attribute, comparator
can be specified by
+ using a nested element.
+ ++ <copy todir="build"> + <fileset dir="input" includes="*.txt"/> + <filterchain> + <sortfilter/> + </filterchain> + </copy> +
+Sort all files *.txt
from src location
+into build location. The lines of each file are sorted in
+ascendant order comparing the lines via the
+String.compareTo(Object o)
method.
+
+ ++ <copy todir="build"> + <fileset dir="input" includes="*.txt"/> + <filterchain> + <sortfilter reverse="true"/> + </filterchain> + </copy> +
+Sort all files *.txt
from src location into reverse
+order and copy them into build location.
+
+ ++ <copy todir="build"> + <fileset dir="input" includes="*.txt"/> + <filterchain> + <filterreader classname="org.apache.tools.ant.filters.SortFilter"> + <param name="comparator" value="org.apache.tools.ant.filters.EvenFirstCmp"/> + </filterreader/> + </filterchain> + </copy> +
+Sort all files *.txt
from src location using as
+sorting criterium EvenFirstCmp
class, that sorts the file
+lines putting even lines first then odd lines for example. The modified files
+are copied into build location. The EventFirstCmp
,
+has to an instanciable class via Class.newInstance()
,
+therefore in case of inner class has to be static. It also has to
+implement java.util.Comparator
interface, for example:
+
+ package org.apache.tools.ant.filters; + ...(omitted) + public final class EvenFirstCmp implements <b>Comparator</b> { + public int compare(Object o1, Object o2) { + ...(omitted) + } + } ++ +
The example above is equivalent to:
+ ++ <componentdef name="evenfirst" + classname="org.apache.tools.ant.filters.EvenFirstCmp"/> + <copy todir="build"> + <fileset dir="input" includes="*.txt"/> + <filterchain> + <sortfilter> + <evenfirst/> + </sortfilter/> + </filterchain> + </copy> +