Subversion Repositories bacoAlunos

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1777 jmachado 1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2
<html>
3
  <head>
4
    <title>Ant-contrib Tasks: PropertySelector</title>
5
  </head>
6
 
7
  <body>
8
    <h1>PropertySelector</h1>
9
 
10
    <p>Selects property names that match a given regular expression and
11
       returns them in a delimited list</p>
12
 
13
    <h2>Parameters</h2>
14
    <table border="1" cellpadding="2" cellspacing="0">
15
      <tr>
16
        <th>Attribute</th>
17
        <th>Description</th>
18
        <th>Required</th>
19
      </tr>
20
      <tr>
21
        <td valign="top">property</td>
22
        <td valign="top">The name of the property you wish to set.</td>
23
        <td align="center" valign="top">Yes.</td>
24
      </tr>
25
      <tr>
26
        <td valign="top">override</td>
27
        <td valign="top">If the property is already set, should we change it's value.
28
            Can be <code>true</code> or <code>false</code></td>
29
        <td align="center" valign="top">No. Defaults to <code>false</code></td>
30
      </tr>
31
      <tr>
32
        <td valign="top">match</td>
33
        <td valign="top">The regular expression which is used to select
34
            property names for inclusion in the list.  This follows
35
            the standard regular expression syntax accepted by ant's
36
            regular expression tasks.</td>
37
        <td align="center" valign="top">Yes.</td>
38
      </tr>
39
      <tr>
40
        <td valign="top">select</td>
41
        <td valign="top">A pattern which indicates what selection pattern you want
42
            in the returned list.  This used the substitution pattern
43
            syntax to indicate where to insert groupings created as a result
44
            of the regular expression match.</td>
45
        <td align="center" valign="top">No. default is &quot;\0&quot;.</td>
46
      </tr>
47
      <tr>
48
        <td valign="top">casesensitive</td>
49
        <td valign="top">Should the match be case sensitive</td>
50
        <td align="center" valign="top">No. default is &quot;true&quot;.</td>
51
      </tr>
52
      <tr>
53
        <td valign="top">delimiter</td>
54
        <td valign="top">The delimiter used to seperate entries in the resulting
55
               property</td>
56
        <td align="center" valign="top">No. default is &quot;,&quot;.</td>
57
      </tr>
58
      <tr>
59
        <td valign="top">distinct</td>
60
        <td valign="top">Should the returned entries be a distinct set (no duplicate
61
               entries)</td>
62
        <td align="center" valign="top">No. default is &quot;false&quot;.</td>
63
      </tr>
64
    </table>
65
 
66
   <h2>Select expressions</h2>
67
 
68
   Expressions are selected in a the same syntax as a regular expression
69
   substitution pattern.
70
 
71
   <ul type="o">
72
    <li><code>\0</code> indicates the entire property name (default).
73
    <li><code>\1</code> indicates the first grouping
74
    <li><code>\2</code> indicates the second grouping
75
    <li>etc...
76
   </ul>
77
 
78
    <h2>Example</h2>
79
 
80
    The following code
81
 
82
    <pre>
83
    <code>
84
    &lt;property name="package.ABC.name" value="abc pack name" /&gt;
85
    &lt;property name="package.DEF.name" value="def pack name" /&gt;
86
    &lt;property name="package.GHI.name" value="ghi pack name" /&gt;
87
    &lt;property name="package.JKL.name" value="jkl pack name" /&gt;
88
 
89
    &lt;propertyselector property="pack.list"
90
                         delimiter=","
91
                         match="package\.([^\.]*)\.name"
92
                         select="\1"
93
                         casesensitive="false" /&gt;
94
 
95
    </code>
96
    </pre>
97
 
98
    would yield the results
99
 
100
    <pre>
101
    <code>
102
    ABC,DEF,GHI,JKL
103
    </code>
104
    </pre>
105
 
106
    You could then iterate through this list using the <a href="foreach.html"
107
    >ForEach Task</a> as follows:
108
 
109
    <pre>
110
    <code>
111
    &lt;foreach list="${pack.list}"
112
                delimiter=","
113
                target="print.name"
114
                param="pack.id" /&gt;
115
 
116
    &lt;target name="print.name" &gt;
117
      &lt;propertycopy name="pack.name" value="package.${pack.id}.name" /&gt;
118
      &lt;echo message="${pack.name}" /&gt;
119
    &lt;/target&gt;
120
    </code>
121
    </pre>
122
 
123
    Would print
124
 
125
    <pre>
126
    <code>
127
      [echo] abc pack name
128
      [echo] def pack name
129
      [echo] ghi pack name
130
      [echo] jkl pack name
131
    </code>
132
    </pre>
133
 
134
    <hr>
135
    <p align="center">Copyright &copy; 2003 Ant-Contrib Project. All
136
    rights Reserved.</p>
137
 
138
  </body>
139
</html>