Thanks for the reply.
I did anticipate that i might not be able to get a solution here and hence i came out with a cheap scheme to help solve my immediate problem, and this is what i have done. I have a Map object as shown below
{ "service-name"="My Service",
"service-provider"="A Complex Person Object"}the above Map object is converted to a XML Map object (all the values in this XML Map are either java primitive wrappers or a xml String that describe the complex object). Notice the "service-provider" value in the above Map object is converted to a xml string using betwixt. The key of "service-provider" is appended with the Type of the complex object, this is to enable me to convert the xml back to an object. All the non-primitive java types (String, Integer, Boolean etc) will not be converted to any xml representation, all Java primitive wrappers will be left as is in the new XML Map object
{"service-name"="My Service",
"service-provider:com.foo.Person"="<com.foo.Person> A Complex Person Object</com.foo.Person>"}
All i need to do now is to serialize the Xml Map object for later use. To access the objects in the XML Map, i'll de-serialize the XML Map object and convert all the non-primitive Java types (Strings with <tags>) to object and place them in a new Map object.
chung-onn
On 9 Feb 04, at 5:49 AM, robert burrell donkin wrote:
On 7 Feb 2004, at 11:09, Cheong Chung Onn wrote:
Hi all,
I sieved through the archive and found that a year ago, someone has asked a similar question. But the solution seems complicated, and now 1 year has past, i wonder if there is a more elegant way of solving the problem.
i agree that the solution to maps is a little complicated and inelegant and it would be great if better ways could be found. any new ideas would be welcomed :)
Essentially, i have a Map object converted to xml in the form ... <entry> <key> xxx</key> <value>yyy</value> </entry> ...
The problem here is the "Type" info is missing for both <key> and <value>, is it possible now to provide a hint to Betwixt to enable it to do a round trip for a Map object. I am thinking that if i do have a table which maps the <key>s to <value>s Type and assuming all the <key> elements are String typed, can round tripping of a Map instance be done in a simple and straight forward manner?
<entry> <key>aPerson</key> <= aPerson - String type <value> <= Person.class <person> <name>John Doe</name> </person> </value> </entry>
Any suggestion will be much appreciated. Thanks in advance.
here's the way i see this problem...
it's probably quite common that the key for a map will turn out to be a simple value indexing a complex type.
index: "AA11235" complex type: <person><name>John Doe</name>...</person>
it seems to me that often a natural way to express this in xml would be as an additional attribute so the resultant would be something like:
<person key='AA11235'><name>John Doe</name>...</person>
(the key attribute may or may not exist on the actual object mapped).
does this seem to ring true or are there other, more useful and common strategies for mapping map entries that other people can think up?
- robert
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
