Description
A list provides a way of setting properties that are
either List
types or arrays. A list can include any other
type including another list or array type.
Handling of multi-dimensional arrays has not been considered. Such properties
are probably best defined with a custom ArooaValue
.
Example
A simple list of things. The list contains 3 things two Strings and a
nested list that contains one String.
<oddjob>
<job>
<sequential>
<jobs>
<variables id="vars">
<ourList>
<list>
<values>
<value value="Hello World"/>
<value value="Goodbye World"/>
<list>
<values>
<value value="I'm in another list"/>
</values>
</list>
</values>
</list>
</ourList>
</variables>
<repeat id="each">
<values>
<value value="${vars.ourList}"/>
</values>
<job>
<echo>${each.current}</echo>
</job>
</repeat>
</jobs>
</sequential>
</job>
</oddjob>
The output is:
Hello World
Goodbye World
[I'm in another list]
Example
A Merged list. This list merges a plain value, a sub list and
and array into a list of 5 separate values.
<oddjob id="this">
<job>
<sequential>
<jobs>
<variables id="vars">
<aList>
<list merge="true">
<values>
<value value="apples"/>
<list>
<values>
<value value="oranges"/>
<value value="bananas"/>
</values>
</list>
<tokenizer text="kiwis, mangos"/>
</values>
</list>
</aList>
</variables>
<foreach>
<values>
<value value="${vars.aList}"/>
</values>
<configuration>
<xml>
<foreach id="loop">
<job>
<echo>${loop.current}</echo>
</job>
</foreach>
</xml>
</configuration>
</foreach>
</jobs>
</sequential>
</job>
</oddjob>
The output is:
apples
oranges
bananas
kiwis
mangos
Example
A Converted list. The elements of the list are converted to an array of
Strings.
<oddjob id="this">
<job>
<sequential>
<jobs>
<variables id="vars">
<aList>
<list>
<elementType>
<class name="[Ljava.lang.String;"/>
</elementType>
<values>
<value value=""grapes, red", "grapes, white", gratefruit"/>
<list>
<values>
<value value="apples"/>
<value value="pears"/>
</values>
</list>
</values>
</list>
</aList>
</variables>
<foreach>
<values>
<value value="${vars.aList}"/>
</values>
<configuration>
<xml>
<foreach id="loop">
<job>
<foreach>
<values>
<value value="${loop.current}"/>
</values>
<configuration>
<xml>
<foreach id="inner">
<job>
<echo>${inner.current}</echo>
</job>
</foreach>
</xml>
</configuration>
</foreach>
</job>
</foreach>
</xml>
</configuration>
</foreach>
</jobs>
</sequential>
</job>
</oddjob>
The output is:
grapes, red
grapes, white
gratefruit
apples
pears
Although it can't be seen in the output, but can be seen when this
example is run in Oddjob Explorer, the list contains to String array
elements.Example
Add to a list the fly. This example demonstrates setting the
hidden 'add' property. The property is hidden so that it can't be set
via configuration which could be confusing. A side affect of this is that
it is also hidden from the Reference Guide generator.
<oddjob id="this">
<job>
<sequential>
<jobs>
<variables id="vars">
<aList>
<list/>
</aList>
</variables>
<set>
<values>
<value key="vars.aList.add" value="apples"/>
</values>
</set>
<set>
<values>
<value key="vars.aList.add" value="bananas"/>
</values>
</set>
<repeat id="each">
<values>
<value value="${vars.aList}"/>
</values>
<job>
<echo>${each.current}</echo>
</job>
</repeat>
</jobs>
</sequential>
</job>
</oddjob>
The output is:
apples
bananas
- See Also:
- Serialized Form
- Author:
- Rob Gordon.