-----Original Message-----
From: Emerson, Matt
Sent: Wednesday, March 09, 2005 6:15 PM
To: [email protected]
Subject: [WARNING: This message originated from outside of Fidelity] [castor-user] Marshalling/Unmarshalling ArrayLists and Lists of Lists
I have created two classes: Product and SubProduct. The product is designed to hold a two-dimensional array of SubProducts. There are two types of storage, a 2-D array and a List of Lists.
Public class Product
{
private List listList;
private SubProduct[][] array;public Product()
public void setListList(List data) { this.listList = data; }
public List setArray(SubProduct[][] data) { this.array = data; }public List getListList() { return this.listList; }
public SubProduct[][] getArray() { return this.array; }
}Public class SubProduct
{
private String name;
private String value;public void setName(String data) { this.name = data; }
publci void sety Value(String data) { this.value = data; }
}My mapping is as follows:
<mapping>
<description>Description of the mapping for the Product Class</description>
<class name="com.fmr.cfit.matt.castor.Product">
<map-to xml="WrapperProductClass"></map-to>
<field name="array" type="com.fmr.cfit.matt.castor.SubProduct">
<bind-xml name="row" location="data_array"/>
</field>
<field name="listList" collection="collection" type="com.fmr.cfit.matt.castor.SubProduct">
<bind-xml name="current_row" location="listList"/>
</field>
</class>
<class name="com.fmr.cfit.matt.castor.SubProduct">
<map-to xml="sub_product"></map-to>
<field name="name" type="java.lang.String">
<bind-xml name="name" node="attribute"/>
</field>
<field name="value" type="java.lang.String">
<bind-xml name="value" node="element"/>
</field>
</class>
</mapping>When I marshal, a class of type Product, everything works fine.
However, when I try to unmarshall the results back into an object, I get the following error. I get it for both the array and the list of lists. Does anyone know why this would be occurring?
#endElement: class
#endElement: mapping
#startElement: WrapperProductClass
#startElement: data_array wrapper-element: data_array
#startElement: row #startElement: sub_productorg.xml.sax.SAXException: unable to find FieldDescriptor for 'sub_product' in ClassDescriptor of sub_product
void org.exolab.castor.xml.UnmarshalHandler.startElement(java.lang.String, java.lang.String, org.exolab.castor.xml.AttributeSet) UnmarshalHandler.java:1791void org.exolab.castor.xml.UnmarshalHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes) unable to find FieldDescriptor for 'sub_product' in ClassDescriptor of sub_produc UnmarshalHandler.java:1292
void org.apache.xerces.parsers.SAXParser.startElement(org.apache.xerces.utils.QName, org.apache.xerces.framework.XMLAttrList, int) SAXParser.java:1371
void org.apache.xerces.validators.common.XMLValidator.callStartElement(org.apache.xerces.utils.QName) XMLValidator.java:840
boolean org.apache.xerces.framework.XMLDocumentScanner.scanElement(org.apache.xerces.utils.QName) XMLDocumentScanner.java:1852 boolean org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(boolean) XMLDocumentScanner.java:1233 boolean org.apache.xerces.framework.XMLDocumentScanner.parseSome(boolean) XMLDocumentScanner.java:380
void org.apache.xerces.framework.XMLParser.parse(org.xml.sax.InputSource) XMLParser.java:908
java.lang.Object org.exolab.castor.xml.Unmarshaller.unmarshal(org.xml.sax.InputSource) Unmarshaller.java:605java.lang.Object org.exolab.castor.xml.Unmarshaller.unmarshal(java.io.Reader) Unmarshaller.java:513
void com.fmr.cfit.matt.castor.TestCastor.runTest2() TestCastor.java:76
void com.fmr.cfit.matt.castor.TestCastor.main(java.lang.String[]) TestCastor.java:36Thanks for the help,
Matt
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-user
