Description
A map allows a map of strings to values to be created.
This map will be converted to a map of string to objects during configuration
of a job.
As yet there is no merging of maps supported by this type.
Example
A simple map with element access.
<oddjob>
<job>
<sequential>
<jobs>
<properties>
<values>
<value key="night.type" value="school night"/>
</values>
</properties>
<variables id="vars">
<beersAllowed>
<map>
<elementType>
<class name="int"/>
</elementType>
<values>
<value key="weekend" value="4"/>
<value key="school night" value="1"/>
</values>
</map>
</beersAllowed>
</variables>
<echo>On a ${night.type} I am allowed ${vars.beersAllowed.element(${night.type})} beer(s).</echo>
</jobs>
</sequential>
</job>
</oddjob>
The output is:
On a school night I am allowed 1 beer(s).
Example
Adding additional elements to a map. Also demonstrates iterable access
to the map.
<oddjob id="this">
<job>
<sequential>
<jobs>
<variables id="vars">
<aMap>
<map/>
</aMap>
</variables>
<set>
<values>
<value key="vars.aMap.add(morning snack)" value="apples"/>
</values>
</set>
<set>
<values>
<value key="vars.aMap.add(afternoon snack)" value="bananas"/>
</values>
</set>
<repeat id="each">
<values>
<value value="${vars.aMap}"/>
</values>
<job>
<echo>${each.current.key} is ${each.current.value}</echo>
</job>
</repeat>
</jobs>
</sequential>
</job>
</oddjob>
The output is:
morning snack is apples
afternoon snack is bananas
- See Also:
- Serialized Form
- Author:
- Rob Gordon.