I have a hierarchy of objects that includes things like

 Map<String,my.pkg.Component> componentMap;

What I would like to have come out for this is

   <component name="fred">
        ...component serialization...
   </component>

What I get with the "usual" annotation set up is

   @XStreamImplicit(itemFieldName="component")
   Map<String,my.pkg.Component> componentMap;

   <component>
        <string>fred</string>
        <my.pkg.Component>
            ...component serialization...
        </my.pkg.Component>
   </component>

I can almost get what I want by doing something that is probably not something that was designed :-)

   @XStreamImplicit(itemFieldName="component", keyFieldName="name")
   Map<String,my.pkg.Component> componentMap;

   <component>
       ...component serialization...
   </component>

However, as you can see, I've completely lost the key at that point.

I realize that putting the key as an attribute is a problem for unmarshalling since the key type is lost. In this case, I don't care because I won't be unmarshalling (really, never). at least never back into the types from which this output was derived.

I can, of course, write a custom Converter (and I have one), but I was hoping I could throw away some code and just use annotations. Is there any hope of adding support for this type of conversion? I could probably even live with something that includes fields I don't care about like

   <component key="fred" keyType="string">
   ...
   </component>

That is, forcing the map key to be named "key" and forcibly adding a field to aid unmarshalling.

roland

--
                       PGP Key ID: 66 BC 3B CD
Roland B. Roberts, PhD                             RL Enterprises
[email protected]                             6818 Madeline Court
[email protected]                            Brooklyn, NY 11220

Reply via email to