Hi,

The question of Roman helped a little bit to solve my problem.
Un/marshalling workes fine now. However when I unmarshall my HashMap the value 
and the key are both of type org.exolab.castor.mapping.MapItem. The problem is 
that I can't cast the value back to the original type. Can somebody give me a 
hint what I need to do.

<class name="GUI.SaveData">
  <map-to xml="SavaData"/>
  <field name="proj" />
  <field name="graphicData" collection="map" container="false">
     <bind-xml name="graphData" node="element" >
        <class name="org.exolab.castor.mapping.MapItem">
           <field name="key" type="java.lang.Object">
                <bind-xml name="id" node="attribute" location="param"/>
           </field>
           <field name="value" type="GUI.ImageAndPositionData">
                <bind-xml name="value" node="attribute" location="param"/>
           </field>
         </class>
     </bind-xml>
  </field>
</class>

graphicData is my HashMap.
Katja

> 
> Hello Keith,
> 
> Your idea that I should update my Castor.jar helped.
> But I'm having the next problem. 
> org.xml.sax.SAXException: unable to add 'graphic-data' to <SavaData> due to 
the 
> following exception: 
> >>>--- Begin Exception ---<<< 
> java.lang.IllegalArgumentException: Type conversion error: could not set 
value 
> of graphicData(java.util.HashMap) with value of type 
> org.exolab.castor.mapping.MapItem
> at org.exolab.castor.mapping.loader.FieldHandlerImpl.setValue
> FieldHandlerImpl.java:474)
> at org.exolab.castor.xml.UnmarshalHandler.endElement
(UnmarshalHandler.java:970)
> ...
> >>>---- End Exception ----<<< 
> {file: [not available]; line: 2; column: 1337}
> 
> My mapping file looks like this now:
> <class name="GUI.SaveData">
>               <map-to xml="SavaData"/>
>               <field name="proj" />
>               <field name="graphicData"/>
>       </class>
>       <class name="org.exolab.castor.mapping.MapItem">
>         <field name="key" type="java.lang.Object">
>                <bind-xml name="id" node="element"/>
>         </field>
>         <field name="value" type="GUI.ImageAndPositionData"/>
>       </class>
> ...
> I understand the mistake but I don't know how to solve it.
> Let me know, if you need more detailed information.
> Katja
> 
> ----------------------------------------------------------- 
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
>         unsubscribe castor-dev
> 

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to