Hi,

I tried with the daily snapshot of  2/1/2002 and still have the same bug.

gregori


Keith Visco wrote:

>Which version of Castor are you using? Can you try this with the CVS
>version?
>
>Also please include the XML files that were created during marshalling.
>
>Thanks,
>
>--Keith
>
>Gregori Faroux wrote:
>
>>Hi,
>>
>>I looked in the archive and did not find a solution to my problem. I
>>have a simple bean with 2 fields: one is a String, one is a Vector.
>>Then I create an instance of the bean.
>>Then I set the String.
>>I add in the vector an int.
>>
>>If I use marshall and unmarshall WITHOUT specifing a mapping file, then
>>everything is fine.
>>But, when I use marshall and unmarshall WITH a mapping file, then the
>>bean inside the vector is NOT unmarshall correctly. The value inside the
>>Vector is a String with tags instead of being a simple int.
>>
>>The mapping file I used is this one: (I convert English names to French
>>one).
>><mapping>
>>  <class name="castorvalidation.MyBean">
>>    <map-to xml="ma-classe"/>
>>    <field name="myString" type="java.lang.String">
>>      <bind-xml name="ma-chaine" node="element"/>
>>    </field>
>>    <field name="myVector" collection="vector">
>>      <bind-xml name="mon-vecteur"/>
>>    </field>
>>  </class>
>></mapping>
>>
>>Here is the result using Unmarshaller without mapping: (after of course,
>>I used marshall without mapping)
>>- myString = un message
>>- myVector :
>>--- 2
>>
>>Here is the result using Unmarshaller with mapping (after of course, I
>>used marshall with mapping)
>>- myString = un message
>>- myVector :
>>--- <mon-vecteur>2</mon-vecteur>
>>
>>I do not know what I do wrong or if it's a bug, but I do not think it's
>>normal to have the tag "<mon-vecteur>2</mon-vecteur>" instead of an int !?
>>
>>In the rest of the email you will find the code.
>>
>>Thank you for your time and hopefully someone will guide me,
>>
>>Gregori
>>
>>------ Mybean.java ------------
>>package castorvalidation;
>>import java.util.Vector;
>>public class MyBean
>>{
>>  private String _myString;
>>  private Vector _myVector;
>>
>>  public void setMyString(String aString) { _myString = aString; }
>>  public String getMyString() { return(_myString); }
>>  public void setMyVector(Vector aVector) { _myVector = aVector; }
>>  public Vector getMyVector() { return(_myVector); }
>>
>>  public MyBean(){}
>>
>>  public String toString()
>>  {
>>    StringBuffer res = new StringBuffer();
>>    res.append(" _myString: ");
>>    res.append(_myString);
>>    for (int i = 0; i < _myVector.size(); i++)
>>    {
>>      res.append(" vec elm(");
>>      res.append(i);
>>      res.append(")= ");
>>      res.append(_myVector.elementAt(i).toString());
>>    }
>>    return(res.toString());
>>  }
>>}
>>
>>---- the code to populate the bean ----------------
>>MyBean bean = new MyBean();
>>Vector vec = new Vector();
>>vec.add(new Integer(2));
>>bean.setMyString("un message");
>>bean.setMyVector(vec);
>>runMarshall(bean);
>>runUnMarshall();
>>
>>---------- methods used to marshall and unmarshall ----------
>>  private void runMarshall(MyBean bean)
>>  {
>>    try
>>    {
>>      FileWriter writer = new FileWriter("bean.xml");
>>      Marshaller marshaller = new Marshaller(writer);
>>      Mapping mapping = new Mapping();
>>      mapping.loadMapping("mapping.xml");
>>      marshaller.setMapping( mapping );
>>      marshaller.marshal(bean);
>>      writer.close();
>>    } catch (Exception e)
>>    {
>>      e.printStackTrace();
>>    }
>>  }
>>
>>  /**
>>   * runUnMarshall()
>>   */
>>  private void runUnMarshall()
>>  {
>>    try
>>    {
>>      Unmarshaller unmarshaller = new Unmarshaller(MyBean.class);
>>      Mapping mapping = new Mapping();
>>      mapping.loadMapping("mapping.xml");
>>      unmarshaller.setMapping( mapping );
>>      MyBean beanRead = (MyBean) unmarshaller.unmarshal(new
>>FileReader("bean.xml"));
>>      System.err.println("- myString = " + beanRead.getMyString());
>>      System.err.println("- myVector : ");
>>      Vector vecRead = beanRead.getMyVector();
>>      if (vecRead != null)
>>      {
>>        for (int i = 0; i < vecRead.size(); i++)
>>        {
>>          System.err.println("--- " + vecRead.elementAt(i).toString());
>>        }
>>      }
>>    } catch (Exception e)
>>    {
>>      e.printStackTrace();
>>    }
>>  }
>>
>>-----------------------------------------------------------
>>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
>
>

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

Reply via email to