Title: Would my fix to handle Enumeration while Marshalling array of containers make it in the 0.9.5.3 rc1?

Hi Keith,

That works great. This solves most of my problems :)

Also I was wondering if my fix to handle the "java.lang.IllegalArgumentException: object is not an instance of declaring class" while marshalling an array of containers which has a container would make it to the 0.9.5.3 RC1. The fix was to add an "else if clause" to handle the Enumeration, very similar to the array handling.

If it is not, could you please let me know when.

Thanks

Balaji

-----Original Message-----
From: Keith Visco [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 19, 2004 7:52 PM
To: '[EMAIL PROTECTED]'
Subject: Re: [castor-dev] How do I handle Multiple elements in the XML map to the same object type in Java.




Balaji,

You're in luck! :-)

There is a new feature in the 0.9.5.3 RC1 that allows you to nest a class mapping, so you can change the mapping for the company field:

<field name="company" type="ClientData">
  <bind-xml node="element">
    <!-- custom mapping for ClientData -->
    <class name="ClientData">
       <field name="name" type="string">
          <bind-xml name="CompanyName"/>
       </field>
       ...
    </class>
  </bind-xml>
</field>


--Keith


> "Adikesavelu, Balaji" wrote:
>
> I have a common Java Object type, but the XML representation is in
> different elements.
>
> For the sake of the discussion, I have changed the MyOrder.java to
> illustrate my case:
>
> I added another member _company of type ClientData. Please note that
> in the Order.XML the name and address elements are represented as
> companyname and companyAddress.
>
> How do I handle the mapping for the ClientData?
>
> Listing of MyOrder.java:
>
> /*
>  * Created on Feb 9, 2004
>  *
>  * To change the template for this generated file go to
>  * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and
> Comments  */
> package castorMapping;
>
> /**
>  * @author A249234
>  *
>  * To change the template for this generated type comment go to
>  * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and
> Comments  */
> import java.util.Vector;
> import java.util.Enumeration;
>
> public class MyOrder {
>
>         private String _ref;
>         private ClientData _client;
>         private ClientData _company;
>         private Vector _items;
>         private float _total;
>
> ......... all the remaining code.
> ........
> ........
>         public ClientData getCompany() {
>                 return _company;
>         }
>
>         /**
>          * @param data
>          */
>         public void setCompany(ClientData data) {
>                 _company = data;
>         }
>
> }
>
> Listing of Order.xml:
> <Order reference="12343-AHSHE-314159">
>         <Client>
>                 <Name>Jean Smith</Name>
>                 <Address>2000, Alameda de las Pulgas, San Mateo, CA
> 94403</Address>
>         </Client>
>         <Company>
>                 <CompanyName>Jean Smith</CompanyName>>
>                 <CompanyAddress>2000, Alameda de las Pulgas, San
> Mateo, CA 94403</CompanyAddress>>
>         </Company>
>
>         <Item reference="RF-0001">
>                 <Description>Stuffed Penguin</Description>
>                 <Quantity>10</Quantity>
>                 <UnitPrice>8.95</UnitPrice>
>         </Item>
>
>         <Item reference="RF-0034">
>                 <Description>Chocolate</Description>
>                 <Quantity>5</Quantity>
>                 <UnitPrice>28.50</UnitPrice>
>         </Item>
>
>         <Item reference="RF-3341">
>                 <Description>Cookie</Description>
>                 <Quantity>30</Quantity>
>                 <UnitPrice>0.85</UnitPrice>
>         </Item>
> </Order>
>
> Thanks
>
> Any help would be greatly appreciated.
>
> Balaji

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

Reply via email to