Hi,
it looks like there's growing demand for being able to unmarshal from
AnyNode objects in one way or the other. Right now, I cannot offer you
any satisfying solution to your problem, but
a) we are aware of the problem.
b) We do have a possible solution in mind.
and
c) we are having quite some (slow) discussion about more sophisticated
approaches in the future.
The solution I have in mind right now would add an unmarshal(Class,
AnyNode) method to the Unmarshaller class, allowing to provide Castor
with a hint when streaming the AnyNode instance into Castor again.
Werner
poijava wrote:
> Hi,
>
> My unmarshaller.unmarshal as follows is returning AnyNode objects. I want
> this to return an arraylist of EqfAvailibityItem objects. Can anyone please
> help?
>
> public <T> ArrayList<T> retrieveListFromExcelFile() {
>
> ArrayList<T> components = new ArrayList<T>();
>
>
> // Generate XML Data From Excel
> excelToXMLTransform.generateXML();
>
> Mapping mapping = new Mapping();
>
> try {
>
> log.info("Mapping the XML data from " +
> inputXMLFileName + " to Java
> Objects");
>
> mapping.loadMapping(mappingFile);
>
> Unmarshaller unmarshaller = new
> Unmarshaller(ArrayList.class);
>
> unmarshaller.setMapping(mapping);
>
> components = (ArrayList<T>) unmarshaller.unmarshal(new
> FileReader(inputXMLFileName));
>
>
> } catch (MappingException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> } catch (MarshalException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> } catch (ValidationException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> } catch (FileNotFoundException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> } catch (IOException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
>
> return components;
> }
>
> I am using a mapping file as follows:
>
> <?xml version="1.0"?>
> <!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Object Mapping DTD Version
> 1.0//EN" "http://castor.exolab.org/mapping.dtd">
>
> <mapping>
>
>
> <description>A mapping file for our Address Book application</description>
>
> <class name="com.EqfAvailibityItem">
>
> <field name="clientCode" type="string">
> <bind-xml name="Client_Code" node="element"></bind-xml>
> </field>
>
> <field name="secCode" type="string" >
> <bind-xml name="sec_code" node="element"></bind-xml>
> </field>
>
> <field name="secName" type="string" >
> <bind-xml name="sec_name" node="element"></bind-xml>
> </field>
>
> <field name="secDesc" type="string" >
> <bind-xml name="sec_desc" node="element"></bind-xml>
> </field>
>
> <field name="insID" type="string" >
> <bind-xml name="Instr_Id" node="element"></bind-xml>
> </field>
>
> <field name="issueCcy" type="string" >
> <bind-xml name="issue_ccy" node="element"></bind-xml>
> </field>
>
> <field name="quantity" type="int" >
> <bind-xml name="Quantity" node="element"></bind-xml>
> </field>
>
> </class>
>
>
> </mapping>
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email