[Simple-support] Problems using ElementMap
Brought to you by:
niallg
|
From: Hugo S. <hug...@gm...> - 2008-07-23 14:12:19
|
Hello,
I'm trying to read some XML data using @ElementMap.
Here's the XML:
...
<time>
<timeSelection>
<maxSelectableInterval>500000</maxSelectableInterval>
<defaultTimeSelectionMode>CUSTOM</defaultTimeSelectionMode>
<preselectedIntervals>
<preselectedInterval section="OPERATION">
<timeUnit>DAY</timeUnit>
<offset>0</offset>
</preselectedInterval>
<preselectedInterval section="DETAIL">
<timeUnit>DAY</timeUnit>
<offset>0</offset>
</preselectedInterval>
<preselectedInterval section="MAINTENANCE">
<timeUnit>DAY</timeUnit>
<offset>0</offset>
</preselectedInterval>
<preselectedInterval section="ADMIN">
<timeUnit>DAY</timeUnit>
<offset>0</offset>
</preselectedInterval>
</preselectedIntervals>
</timeSelection>
</time>
...
Here's the Code:
@Root(name = "time")
public class Time
{
@Element
public TimeSelectionEntries timeSelection;
}
public class TimeSelectionEntries
{
@Element
public int maxSelectableInterval;
@Element
public TimeSelectionMode defaultTimeSelectionMode;
@ElementMap(entry="preselectedInterval", key="section", attribute=true)
public Map<SessionController.Sections, TimeSelection> preselectedIntervals;
}
public class TimeSelection
{
@Element
TimeSelectionMode timeUnit;
@Element
int offset;
// Further code not of interest here...
}
SessionController.Sections and TimeSelectionMode are enumerations. I tried using Strings instead of enumerations but also no success.
Here's the Exception:
org.simpleframework.xml.load.ValueRequiredException: Unable to satisfy @org.simpleframework.xml.Element(name=, data=false, required=true) on field 'timeUnit' for class ... .TimeSelection at line 125
at org.simpleframework.xml.load.Composite.validate(Composite.java:389)
at org.simpleframework.xml.load.Composite.readElements(Composite.java:252)
at org.simpleframework.xml.load.Composite.read(Composite.java:194)
at org.simpleframework.xml.load.Composite.read(Composite.java:140)
...
I don't understand the Exception because as you can see the element timeUnit is definitively there. What am I doing wrong??
Thank you!
Hugo
--
GMX Kostenlose Spiele: Einfach online spielen und Spaß haben mit Pastry Passion!
http://games.entertainment.gmx.net/de/entertainment/games/free/puzzle/6169196
|