Bonjour,
Some problem:
------------------------------------------------------
Here is the bean
------------------------------------------------------
import java.io.*;
import java.util.*;
public class PollBean {
private long[] aChoices = new long[4];
final public void setChoices(long[] val) {
aChoices = val;
}
final public long[] getChoices() {
return aChoices;
}
public String toString() {
StringBuffer b = new StringBuffer(300);
for (int i=0; i<aChoices.length; i++)
b.append(aChoices[i]).append(", ");
return b.toString();
}
}
------------------------------------------------------
Here is the main file
------------------------------------------------------
import java.io.*;
import org.exolab.castor.xml.*;
public class Test2
{
public static void main(String[] argv) {
long[] choices = {1,2,3,4};
// build a test bean
PollBean bean = new PollBean();
bean.setChoices(choices);
System.out.println("marshal: " + bean.toString() );
try {
// write it out as XML (if not already present)
File file = new File("test2.xml");
Writer writer = new FileWriter(file);
Marshaller.marshal(bean, writer);
// now restore the value and list what we get
Reader reader = new FileReader(file);
PollBean read = (PollBean)
Unmarshaller.unmarshal(PollBean.class, reader);
System.out.println("unmarshal: " + read.toString() );
} catch (IOException ex) {
ex.printStackTrace(System.err);
} catch (MarshalException ex) {
ex.printStackTrace(System.err);
} catch (ValidationException ex) {
ex.printStackTrace(System.err);
}
}
}
------------------------------------------------------
Here is the xml file
------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<poll-bean>
<choices>1</choices>
<choices>2</choices>
<choices>3</choices>
<choices>4</choices>
</poll-bean>
------------------------------------------------------
Here is the output
------------------------------------------------------
marshal: 1, 2, 3, 4,
unmarshal: 0, 0, 0, 0, 1, 2, 3, 4,
Strange result...
Any idea?
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev