Defining Object Containers - Maps

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

All map or dictionary like classes in Java are derived from java.util.Map.
This class can be used to store a set of key/value pairs. The general structure looks like this:

  <obj id="myMap" type="java.util.HashMap" hint="map">
    <item>
      <key type="java.lang.String">firstkey</key>
      <value type="java.lang.String">firstValue</value>
    </item>
    <item>
      <key type="java.lang.String">secondkey</key>
      <value type="java.lang.String">secondValue</value>
    </item>
  </obj>
The key and value tags can contain every structure that is allowed for standard obj tags as well.
To specify a mixed key/value constallation just provide different type attributes to the key or value.
If you prefere shortcut notation with homogenous key/value pairs define it like this:
  <obj id="myMap" type="java.util.HashMap" hint="map"
    keytype="java.lang.String" valuetype="string">
    <item>
      <key>firstkey</key>
      <value>firstValue</value>
    </item>
    <item>
      <key>secondkey</key>
      <value>secondValue</value>
    </item>
  </obj>
As in all the other examples you can use type shortcuts for all types as defined in Object Type Abbreviation.

To specify an empty map just use an empty xml tag:

  <obj id="myMap" type="hashmap" hint="map" keytype="string" valuetype="string" />
To specify the map object as "null" use the special key !NULL!
  <obj id="myMap" type="hashmap" hint="map" keytype="string" valuetype="string">!NULL!</obj>
sf logo