[Index]

list


A list provides a way of setting properties that are either java.util.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 org.oddjob.arooa.ArooaValue.


Property Summary

elementType The required element type.
merge If the element is a list or array the values are merged into this list.
unique Ensures the list contains only unique elements.
values Any values.

Example Summary

Example 1 A simple list of things.
Example 2 A Merged list.
Example 3 A Converted list.
Example 4 Add to a list the fly.

Property Detail

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.

merge

Configured ByATTRIBUTE
AccessREAD_WRITE
RequiredNo, defaults to not merging.

If the element is a list or array the values are merged into this list.

unique

Configured ByATTRIBUTE
AccessREAD_WRITE
RequiredNo.

Ensures the list contains only unique elements.

values

Configured ByELEMENT
AccessREAD_WRITE
RequiredNo.

Any values.


Examples

Example 1

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 2

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 3

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="&quot;grapes, red&quot;, &quot;grapes, white&quot;, 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 4

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


(c) Rob Gordon 2005 - 2017