| 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
| 2 | <html> |
| 3 | <head> |
| 4 | <title>Ant-contrib Tasks: SortList</title> |
| 5 | </head> |
| 6 | |
| 7 | <body> |
| 8 | <h1>SortList</h1> |
| 9 | |
| 10 | <p>Sort a delimited list of items in their natural string order. Note that |
| 11 | the <code>value</code> and <code>refid</code> attributes are mutually exclusive, |
| 12 | and the <code>value</code> attribute takes precedence if both are specified.</p> |
| 13 | |
| 14 | <h2>Parameters</h2> |
| 15 | <table border="1" cellpadding="2" cellspacing="0"> |
| 16 | <tr> |
| 17 | <th>Attribute</th> |
| 18 | <th>Description</th> |
| 19 | <th>Required</th> |
| 20 | </tr> |
| 21 | <tr> |
| 22 | <td valign="top">property</td> |
| 23 | <td valign="top">The name of the property to set.</td> |
| 24 | <td align="center" valign="top">Yes.</td> |
| 25 | </tr> |
| 26 | <tr> |
| 27 | <td valign="top">override</td> |
| 28 | <td valign="top">If the property is already set, should we change it's value. |
| 29 | Can be <code>true</code> or <code>false</code></td> |
| 30 | <td align="center" valign="top">No. Defaults to <code>false</code></td> |
| 31 | </tr> |
| 32 | <tr> |
| 33 | <td valign="top">value</td> |
| 34 | <td valign="top">The list of values to process, with the |
| 35 | delimiter character, indicated by the "delimiter" |
| 36 | attribute, separating each value.</td> |
| 37 | <td align="center" valign="top">Yes, unless "refid" is |
| 38 | specified.</td> |
| 39 | </tr> |
| 40 | <tr> |
| 41 | <td valign="top">refid</td> |
| 42 | <td valign="top">The id of where the list of values to sort is |
| 43 | stored.</td> |
| 44 | <td align="center" valign="top">Yes, unless "value" is |
| 45 | specified.</td> |
| 46 | </tr> |
| 47 | <tr> |
| 48 | <td valign="top">delimiter</td> |
| 49 | <td valign="top">The delimiter string that separates the |
| 50 | values in the "list" attribute.</td> |
| 51 | <td align="center" valign="top">No, defaults to ",".</td> |
| 52 | </tr> |
| 53 | <tr> |
| 54 | <td valign="top">casesensitive</td> |
| 55 | <td valign="top">If <code>true</code>, does a case sensitive sorting |
| 56 | of the strings. If <code>false</code> does case insensitive sorting. |
| 57 | </td> |
| 58 | <td align="center" valign="top">No. Defaults to true.</td> |
| 59 | </tr> |
| 60 | <tr> |
| 61 | <td valign="top">numeric</td> |
| 62 | <td valign="top">If <code>true</code>, does a numeric sorting, treating |
| 63 | all list entries as if they were numbers. |
| 64 | </td> |
| 65 | <td align="center" valign="top">No. Defaults to false.</td> |
| 66 | </tr> |
| 67 | |
| 68 | <tr> |
| 69 | <td valign="top">orderPropertyFile</td> |
| 70 | <td valign="top">If specified, the list will sorted as if they were property |
| 71 | names, and will be sorted in the order those properties appear |
| 72 | in the given property file. Any properties in the |
| 73 | <code>value</code> attribute which do not appear in the properties file |
| 74 | will be inserted at the end of the list. This property is most useful |
| 75 | when used in conjunction with the <code><propertyselector></code> |
| 76 | task (see Example 2). |
| 77 | </td> |
| 78 | <td align="center" valign="top">No.</td> |
| 79 | </tr> |
| 80 | |
| 81 | <tr> |
| 82 | <td valign="top">orderPropertyFilePrefix</td> |
| 83 | <td valign="top">If <code>orderPropertyFile</code> is specified, this |
| 84 | value (with a trailing '.') will be prefixed to each property in the |
| 85 | specified <code>orderPropertyFile</code> to determine sorting order |
| 86 | </td> |
| 87 | <td align="center" valign="top">No.</td> |
| 88 | </tr> |
| 89 | |
| 90 | </table> |
| 91 | |
| 92 | <hr /> |
| 93 | |
| 94 | <h2>Example 1</h2> |
| 95 | <pre> |
| 96 | <code> |
| 97 | <property name="my.list" value="z,y,x,w,v,u,t" /> |
| 98 | <sortlist property="my.sorted.list" value="${my.list}" |
| 99 | delimiter="," /> |
| 100 | <echo message="${my.sorted.list}" /> |
| 101 | </code> |
| 102 | |
| 103 | prints |
| 104 | |
| 105 | <code> |
| 106 | [echo] t,u,v,w,x,y,z |
| 107 | </code> |
| 108 | |
| 109 | <h2>Example 2</h2> |
| 110 | <pre> |
| 111 | test.properties |
| 112 | --------------- |
| 113 | a.name=a |
| 114 | c.name=c |
| 115 | b.name=b |
| 116 | |
| 117 | <code> |
| 118 | <property file="test.properties" prefix="test" /> |
| 119 | <propertyselector property="my.list" |
| 120 | delimiter="," |
| 121 | match="test\..*\.name" |
| 122 | select="\0" /> |
| 123 | <sortlist property="my.sorted.list" |
| 124 | value="${my.list}" |
| 125 | delimiter="," |
| 126 | orderPropertyFile="test.properties" |
| 127 | orderPropertyFilePrefix="test" /> |
| 128 | |
| 129 | <echo message="${my.sorted.list}" /> |
| 130 | |
| 131 | prints |
| 132 | |
| 133 | <code> |
| 134 | [echo] test.a.name,test.c.name,test.b.name |
| 135 | </code> |
| 136 | |
| 137 | Notice that the <code>test.properties</code> file did not have "test." |
| 138 | prefixing all the properties. The <code>orderPropertyFilePrefix</code> was |
| 139 | used to do that. |
| 140 | <hr> |
| 141 | <p align="center">Copyright © 2002-2003 Ant-Contrib Project. All |
| 142 | rights Reserved.</p> |
| 143 | |
| 144 | </body> |
| 145 | </html> |