Using Containers - Collections

<objs><obj id="myId" type="my.class.Type" hint="collection">...</obj><objs>

All collection classes in Java are derived from java.util.Collection.
This specimen is used to store a set of values (whatever type you like) in a box. The general structure in DDTUnit looks like this:

  <obj id="myVector" type="java.util.Vector" hint="collection">
    <item type="string">firstEntry</item>
    <item type="string">secondEntry</item>
    <item type="string">thirdEntry</item>
  </obj>
And here is the equivalent example in shortcut notation:
  <obj id="myVector" type="vector" hint="collection" valuetype="string">
    <item>firstEntry</item>
    <item>secondEntry</item>
    <item>thirdEntry</item>
  </obj>
and at last a mixed value example for collection:
  <obj id="myVector" type="vector" hint="collection" valuetype="string">
    <item>firstEntry</item>
    <item type="int">4711</item>
    <item>thirdEntry</item>
  </obj>
This will instanciate to a sequence of [String, Integer, String].

The item tags can contain every structure that is allowed for standard obj tags as well.
To specify an empty collection just use an empty xml tag:

  <obj id="myVector" type="vector" hint="collection" valuetype="string" />
To specify the collection object as "null" use the special key !NULL!
  <obj id="myVector" type="vector" hint="collection" valuetype="string">!NULL!</obj>

Here is an example from the DDTUnit test suite.

sf logo