foreach

Description

A job which executes its child jobs for each of the provided values. The child job can access the current value using the pseudo property 'current' to gain access to the current value. The pseudo property 'index' is also available.

The return state of this job depends on the return state of the children (like sequential). Hard resetting this job will cause the children to be destroyed and recreated on the next run (with possibly new values). Soft resetting this job will reset the children but when re-run will not reconfigure the values.

Properties

NameDescriptionRequired
name A name, can be any text. No.
values Any value. No.
xml The xml configuration that will be parsed for each value. Yes.
current The current value R/O.
index The current index in the values. R/O.

Example


 <oddjob id="this">
   <foreach id="copy-reps">
     <values>
      <list>
       <values>
        <file file="${this.dir}/data/demo1.rep"/>
        <file file="${this.dir}/data/demo2.rep"/>
        <file file="${this.dir}/data/demo3.rep"/>
       </values>
      </list>
     </values>
     <xml>
      <xml>
       <copy to="${this.dir}/work">
        <from>
         <value value="${copy-reps.current}"/>
        </from>
       </copy>
      </xml>
     </xml>
   </foreach>
 </oddjob>
 

Also exists has a similar example.


(c) Rob Gordon 2005 - 2009