Re: [Simple-support] @ElementMap
Brought to you by:
niallg
|
From: Niall G. - Y. <Nia...@yi...> - 2012-11-28 22:26:09
|
Hi Jochen,
I am afraid I do not understand the question, can you put this in a test case with some asserts, then perhaps I can figure out what you are trying to do.
Thanks,
Niall
From: jo...@va... [mailto:jo...@va...]
Sent: Thursday, 29 November 2012 1:34 AM
To: sim...@li...
Subject: [Simple-support] @ElementMap
----- Forwarded message -----
From: "van Waasen Jochen (KFSC 11)" <joc...@cr...<mailto:joc...@cr...>>
To: <sim...@li...<mailto:sim...@li...>>
Cc: <jo...@va...<mailto:jo...@va...>>
Subject: @ElementMap
Date: Wed, Nov 28, 2012 15:17
Hi,
I am new to simpleXML and stuck with @ElementMap.
I would like to parse the following:
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.5">
<dict>
<key>key01</key><string>value01</string>
<key>key02</key><string>value02</string>
<key>key03</key><string>value03</string>
</dict>
</plist>
My class looks like this:
import java.util.Map;
import org.simpleframework.xml.Attribute;
import org.simpleframework.xml.ElementMap;
import org.simpleframework.xml.Root;
@Root(name = "plist")
public class PropertyList{
@ElementMap(name = "dict",
key="key", keyType=String.class,
value="string", valueType=String.class,
required=false, inline=false)
private Map<String, String> plDictionary;
@Attribute(required = true)
private String version;
public String getVersion(){
return this.version;
}
public Map<String, String> getMap(){
return this.plDictionary;
}
public void setMap(Map<String, String> theMap){
this.plDictionary = theMap;
}
}
As a result I get a Map which contains another Map with null values.
I would expect only ONE Map to be created.
If I change the XML to this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.5">
<dict>
<dict>
<key>key01</key><string>value01</string>
<key>key02</key><string>value02</string>
<key>key03</key><string>value03</string>
</dict>
</dict>
</plist>
Then the Map inside the Map has the values.
What is wrong in my config? I just want to have ONE Map that holds these values.
How can this be achieved?
Thanks
Jochen
|