We have a generic Castor loader class that we want to load objects from
XML files given the class type and the mapping file.
We have a very simple xml file that we want an ArrayList to be populated
from.
XML FILE:
<security-servers>
<server>Server 1</server>
<server>Server 2</server>
</security-servers>
We tried to simply map the arraylist as a class
<?xml version="1.0"?>
<!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Object Mapping DTD Version
1.0//EN"
"http://castor.exolab.org/mapping.dtd">
<mapping>
<description>Mapping file ArrayList</description>
<class name="java.util.ArrayList" verify-constructable="false">
<!-- No name, since the field in the ArrayList class is private
-->
<field name="" type="java.lang.Object" set-method="add"
get-method="get">
<bind-xml node="element"
location="security-servers/server"/>
</field>
</class>
</mapping>
The problem we are running into is that there is no get() method, only
get(index) on ArrayList...
Can we even map an arraylist as a standalone class?
// Example usage
List servers = (List)CastorLoader.load(ArrayList.class,
"ArrayListMap.xml");
Thanks,
- Tim
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-user