[Index]

map


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.


Property Summary

element  
elementType The required element type.
values Any values.

Example Summary

Example 1 A simple map with element access.
Example 2 Adding additional elements to a map.

Property Detail

element

AccessREAD_ONLY

elementType

Configured ByELEMENT
AccessREAD_WRITE
RequiredNo. Elements will be left being what they want to be.

The required element type. If this is specified all elements of the array will attempt to be converted to this type.

values

Configured ByELEMENT
AccessREAD_WRITE
RequiredNo.

Any values.


Examples

Example 1

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 2

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


(c) Rob Gordon 2005 - 2017