Re: [Simple-support] Providing Extra Type Information to the Serialization Engine
Brought to you by:
niallg
|
From: Niall G. <gal...@ya...> - 2011-05-14 08:43:30
|
This is why I developed UnionList, its not dynamic, but does allow for multiple entry types.
--- On Sat, 14/5/11, Azubuko Obele <buk...@gm...> wrote:
From: Azubuko Obele <buk...@gm...>
Subject: Re: [Simple-support] Providing Extra Type Information to the Serialization Engine
To: "Niall Gallagher" <gal...@ya...>
Cc: sim...@li...
Received: Saturday, 14 May, 2011, 12:53 AM
Yes, I suspected as much. The information is not completely lost at runtime (I believe it is possible to examine the subclass and recover the generic parameters using reflection) but there will be an issue of linking up the generic specialization to a given field. I wonder if it would make sense to allow subclasses to contribute such information somehow. For example, perhaps something like:
public abstract class ItemList<T> {
@ElementList(inline = true, required = false)
private List<T> items = new ArrayList<T>();
}
@ContributeType(name="items", class=B.class)
public class BList extends ItemList<B> {
}
I'm trying to get this working locally but I'm running into a bit of trouble. I've been looking through the Traverser class and trying to figure out where exactly the serialization engine is picking up the type associated with a collection so I can inject this information but it's not clear where exactly this happens. Could you perhaps point me in the right direction?
Thanks
On Sat, May 14, 2011 at 3:32 AM, Niall Gallagher <gal...@ya...> wrote:
This is a limitation of Java. In c# and other typed languages T would be available, however Java generics are not reified, so this type information is erased at compile time. It is impossible to know what T is at runtime I am afraid.
--- On Fri, 13/5/11, Azubuko Obele <buk...@gm...> wrote:
From: Azubuko Obele <buk...@gm...>
Subject: Re: [Simple-support] Providing Extra Type Information to the Serialization Engine
To: "Niall Gallagher" <gal...@ya...>
Cc: sim...@li...
Received: Friday, 13 May, 2011, 9:16 PM
Hey Niall,
UnionList looks cool but I'm not sure how it helps me. The problem is I have a base class with a generic collection (see below). Subclasses
specialize this generic parameter but SimpleXml complains that it doesn't know the type of the inherited collection being de/serialized.
--- On Fri, 13/5/11, Azubuko Obele <buk...@gm...> wrote:
From: Azubuko Obele <buk...@gm...>
Subject: [Simple-support] Providing Extra Type Information to the Serialization Engine
To: sim...@li...
Received: Friday, 13 May, 2011, 4:55 AM
Hello,
If I have a generic class like:
public class ItemList<T> {
@ElementList(inline = true, required = false)
private List<T> items = new ArrayList<T>();
}
And then I have subclasses of this like AList extends ItemList<A> and BList extends ItemList<B> ... Simple will fail to serialize such classes because it can't determine the type of the generic property. Is there perhaps a mechanism so that I might be able to provide this information to the engine somehow?
Thanks
-----Inline Attachment Follows-----
------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
-----Inline Attachment Follows-----
_______________________________________________
Simple-support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simple-support
|