Re: [Simple-support] ElementListUnion - Duplicate annotation exception .
Brought to you by:
niallg
|
From: Shyam S. <sh...@ou...> - 2013-03-25 17:06:23
|
You mean , I should create two ElementLists , one for Thing.class and one for AnotherThing.class with the same name ?
Shyam S
From: Nia...@yi...
To: sh...@ou...; sim...@li...
Subject: RE: [Simple-support] ElementListUnion - Duplicate annotation exception .
Date: Sun, 24 Mar 2013 22:50:10 +0000
Hi,
If the tags have the same name then you should not use @ElementListUnion, use @ElementList instead.
Niall
From: Shyam Sankaran [mailto:sh...@ou...]
Sent: Saturday, 23 March 2013 6:01 PM
To: sim...@li...
Subject: [Simple-support] ElementListUnion - Duplicate annotation exception .
Hi,
I tried deseiarilizing a list object. Since I will know the type of the list only at run time , I declared it using ElementListUnion as :
Customer.java
@ElementListUnion({ @ElementList(inline = false, type = Thing.class),
@ElementList(inline = false, type = AnotherThing.class) })
List<Object> things ;
My Response xml is :
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<customer>
<address>
<no>122</no>
<street>chennai</street>
</address>
<id>122</id>
<name>James Bond</name>
<things>
<thing>
<val>185</val>
</thing>
<thing>
<val>162</val>
</thing>
</things>
</customer>
But Iam getting the following
exception.
03-21 18:56:31.940: E/AndroidRuntime(2289): Caused by:
org.simpleframework.xml.core.PersistenceException: Duplicate annotation
of name 'things' on
@org.simpleframework.xml.ElementListUnion(value=[@org.simpleframework.xml.ElementList(data=false,
empty=true, entry=, inline=false, name=, required=true, type=class
com.data.Thing), @org.simpleframework.xml.ElementList(data=false,
empty=true, entry=, inline=false, name=, required=true, type=class
com.data.AnotherThing)]) on field 'things' java.util.List
com.data.Customer.things
When I remove one ElementList it works fine .
eg. :
@ElementListUnion({ @ElementList(inline = false, type = Thing.class),
})
List<Object> things ;
is working fine.
Am I missing something here. Please Help. I have been on this for more than 3 days now.
Regards,
Shyam S
|