JAXB Marshall Map<Integer, ArrayList<String>>

Ich habe ein Objekt, ich möchte marshall.

@XmlRootElement
public class BoxItem {
  @XmlElement
  Map<Integer, ArrayList<String>> intgerStringArrMap;

  BoxItem() {
      intgerStringArrMap = new HashMap<Integer, ArrayList<String>>();
      for (int i = 0; i < 3; i++) {
          ArrayList<String> stringArrayList = new ArrayList<String>();
          for (int j = 0; j < 10; j++) {
              stringArrayList.add(new BigInteger(130, new SecureRandom()).toString(32));
          }
         intgerStringArrMap.put(i, stringArrayList);
      }
  }
}

Nun nehmen wir an, wir haben eine boxItem = new BoxItem()

Wenn ich rufe, jaxbMarshaller.Marschall(boxItem, System.out); die Werte sind leer, die für jeden Eintrag.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<boxItem>
    <intgerStringArrMap>
        <entry>
            <key>0</key>
            <value/>
        </entry>
        <entry>
            <key>1</key>
            <value/>
        </entry>
        <entry>
            <key>2</key>
            <value/>
        </entry>
    </intgerStringArrMap>
</boxItem>

Wie marshall die Elemente in der ArrayList in eine Karte Wert?

InformationsquelleAutor zeal | 2013-10-08
Schreibe einen Kommentar