Hello all,
I've been using Castor these past couple of days to try to get a little serialization going between my Java program and XML in a readable way. Though it has a few faults, Castor's automatic xml generation via reflection is actually very functional. Unfortunately, one thing that seems to be fairly well left out of the examples is dealing with generics. It seems the reflection API does a wonderful job as it is, but as it is inadvertently grabbing a lot of redundant data just because methods start with get___()
, I wanted to write my own mapping file to stave this off.
Firstly, it seems altogether fair that in the attributes to a "field
" element, one should define "type
". However, it does not specify what should be done if this type is abstract or simply an interface. What should I put as the type then?
Secondly, most "collection" type objects specified in Castor (List
, Vector
, Collection
, Set
, etc) only require 1 generic type, so specifying "type
" as what's inside and "collection="true"
" are enough. However, it does not specify what I should do in the case of a collection like a Map
, where 2 types are necessary. How can I specify both the key type and value type?
Any help at all would be greatly appreciated!