David-

If you don't know what the contents of the map will be you can specify
a superclass (Object often works) or an interface, and Castor will (in
order) either find a mapping for that class (the mapping doesn't have
to be connected to the HashMap mapping in any way), or introspect the
class (look for JavaBean-style get/set methods to determine the fields
to be persisted).

That all being said, there currently is a bug report about Castor's
handling of Collections and arrays as HashMap values (they marshal
fine but have difficulty unmarshalling).  So some of the discussion
above depends on your application.

Let us know if you have further questions.

Stephen


On 4/2/06, David Gagnon <[EMAIL PROTECTED]> wrote:
> Hi Stephen!
>
>   The KEYS are all Strings but the value can be complex value.  I
> checked the thread you pointed me and I this possible to marshal a map
> without knowing what it contains?  For what I understand I need to know
> the MAPPING to marshal a map.  I would like to marshal the map without
> knowing what it contains and of course be able to unmarshal it after.
> Is that possible ?
>
> Thanks for your help!
>
> /David
>
> Stephen Bash wrote:
>
> >David-
> >
> >Castor does in general support marshalling and unmarshalling Java
> >Maps.  In your example, are the Address and PhoneNumber objects the
> >key and value respectively?  In my work I've almost always used a
> >primitive key with a complex value, but I'm pretty sure full objects
> >can be used for both key and value if desired.
> >
> >For an example of the mapping document Castor would need to handle a
> >map, see the following post:
> >
> >http://www.mail-archive.com/[email protected]/msg01939.html
> >
> >HTH,
> >Stephen
> >
> >
> >On 4/2/06, David Gagnon <[EMAIL PROTECTED]> wrote:
> >
> >
> >>Hi all,
> >>
> >>  I'm searching a way to marshal a hashmap that contains custom type
> >>like a CivicAddress, PhoneNumber into an XML file.
> >>
> >>I need to be able to read this XML and getting back the same HashMap
> >>with the same properties.The properties in the Map aren't known.
> >>
> >>I look into castor to find an answer as well as Betwixt, XMLBeans, JAXB
> >>after trying stuff for few hours .. im just lost:-(
> >>Is that possible to do this with castor .. or any other XML framework?
> >>
> >>Thanks to share your knowledge with me :-)
> >>
> >>Any help will be appreciated.
> >>
> >>Thanks
> >>/David
> >>
> >>
> >>-------------------------------------------------
> >>If you wish to unsubscribe from this list, please
> >>send an empty message to the following address:
> >>
> >>[EMAIL PROTECTED]
> >>-------------------------------------------------
> >>
> >>
> >>
> >>
>
>
>
> -------------------------------------------------
> If you wish to unsubscribe from this list, please
> send an empty message to the following address:
>
> [EMAIL PROTECTED]
> -------------------------------------------------
>
>

Reply via email to