I answered my own question, I had to specify "arraylist" instead of "collection" for the collection type..



Tim Mulle' wrote:


Hi,

I have a map that contains strings as the keys and ArrayLists as the value for the keys. Is it possible to have Castor map this to something like:

<key name="Key">
  <value>A</value>
   <value>B</value>
</key>

Basically, I'm not sure how write the values out.. I tried something like:

<field name="roleMappings" collection="map">
<bind-xml name="mapping" location="role-mappings">
<class name="org.exolab.castor.mapping.MapItem">
<field name="key" type="string">
<bind-xml name="name" node="attribute"/>
</field>
<field name="value" type="string" collection="collection">
<bind-xml node="element"/>
</field>
</class>
</bind-xml>
</field>


but that didn't work, and I got an exception:

org.exolab.castor.mapping.MappingException: The return type for method public java.lang.Object org.exolab.castor.mapping.MapItem.getValue() does not match the declared field type java.util.Collection

Do I need a custom field handler to handle this situation?

Thanks,
- Tim



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






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

Reply via email to