Re: [Simple-support] deserializing polymorphic classes
Brought to you by:
niallg
|
From: Niall G. <gal...@ya...> - 2011-03-08 11:27:51
|
Hi,
If the root element contains a class= attribute it will be able to figure out the type to be deserialized.
Niall
--- On Mon, 7/3/11, hatchetman82 <hat...@gm...> wrote:
> From: hatchetman82 <hat...@gm...>
> Subject: [Simple-support] deserializing polymorphic classes
> To: sim...@li...
> Received: Monday, 7 March, 2011, 8:21 AM
> Hi.
>
> suppose i have an abstract root class with a @Root
> annotation, with a
> lot of concrete implementing classes.
> is it possible to read any child class of this root class
> without
> knowing its type in advance?
> ideally something like :
>
> @Root
> public abstract class AbstractParentClass {}
>
> @Root(name="concrete")
> public class ConcreteClass extends AbstractParentClass{}
>
> @Root(name="concrete2")
> public class ConcreteClass2 extends AbstractParentClass{}
>
>
> Serializer s = new Persister();
> ConcreteClass a = new ...
> String serializedForm = serialize(a);
>
> AbstractParentClass b = s.read(AbstractParentClass.class,
> serializedForm);
>
> ------------------------------------------------------------------------------
> What You Don't Know About Data Connectivity CAN Hurt You
> This paper provides an overview of data connectivity,
> details
> its effect on application quality, and explores various
> alternative
> solutions. http://p.sf.net/sfu/progress-d2d
> _______________________________________________
> Simple-support mailing list
> Sim...@li...
> https://lists.sourceforge.net/lists/listinfo/simple-support
>
|