I'm using Castor to marshal/unmarshal my Java objects, one of which contains an EnumMap. Can Castor marshal/unmarshal EnumMaps? I have a mapping file with some nested HashMaps, but I've never pushed an EnumMap through Castor. If it is possible, how is it done through the mapping file?
One of the big problems is that Enums can't really be serialized and restored, at least not in Java 1.5. And I think also not in Java 1.6.
As enums can not - by default - be serialized or XMLEncoded I very much doubt an EnumMap can be serialized. From the castor web page :
While you can always use your own custom FieldHandler for handling type-safe enumeration classes, Castor does have a built-in approach to dealing with these types of classes. If the type-safe enum class has a public static valueOf(String) method Castor will call that method so that the proper instance of the enumeration is returned. Note: You'll also need to disable the default constructor check in the mapping file (see section 7.4 above to see more on this).
if that does not work you have to write your own field handler.
I hope this helps a bit.