[Simple-support] Problem with subclass annotation
Brought to you by:
niallg
|
From: Vincent S. <vin...@gm...> - 2012-01-18 12:22:08
|
Hello, I'm struggling with the following problem. Let's say we have the following XML: <?xml version="1.0"?> <wrapper xmlns="http://www.example.org" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <obj xsi:type="FieldSubClass1"> <property1>some text</property1> <property2>some text</property2> </obj> <obj xsi:type="FieldSubClass2"> <property1>some text</property1> <property2>some text</property2> <property3>some text</property3> </obj> <obj xsi:type="FieldSubClass3"> <property1>some text</property1> <property2>some text</property2> </obj> </wrapper> The Java classes are: public class Wrapper { private List<Field> fieldList = null; } public class Field { private String property1 = null; } public class FieldSubClass1 extends Field { private String property2 = null; } public class FieldSubClass2 extends Field { private String property2 = null; private String property3 = null; } public class FieldSubClass3 extends Field { private String property2 = null; } Is it possible to use Simple for this problem? Simple would need to analyse the xsi:type attribute to find out which sub class to instantiate, as the sub classes cannot be distinguished by their properties. I tried a lot of different combinations of annotations but haven't been able to created the designated result. Any help would be much appreciated. Kind regards, Vincent -- Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de |