Looking through previous posts I found 

http://svn.castor.codehaus.org/browse/castor/castor/trunk/xmlctf/tests/MasterTestSuite/mapping/collections/Maps
and used that as my basis. I am trying to marshal/unmarshal a class that has
a Map within a Map as follows:

public class UserRightsMessage extends Message
{
        private Map<String, Map<String, UserRights>> usersRights;
        
        public UserRightsMessage()
        {
                usersRights = new HashMap<String, Map<String, UserRights>>();
        }
        
        public void setUsersRights(Map<String, Map<String, UserRights>>
newUserRights)
        {
                usersRights = newUserRights;
        }
        
        public Map<String, Map<String, UserRights>> getUsersRights()
        {
                return usersRights;
        }       
}

And my mapping xml file looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//EN"
                         "http://castor.org/mapping.dtd";>

<mapping>
<class name="UserRightsMessage" auto-complete="true">
        <field name="userRights" collection="map">
                <bind-xml name="map">
                        <class name="org.exolab.castor.mapping.MapItem">
                                <field name="key" type="java.lang.String">
                                        <bind-xml name="string1" 
node="attribute"/>
                                </field>
                                <field name="value" collection="map">
                                        <bind-xml name="nested">
                                                <class 
name="org.exolab.castor.mapping.MapItem">
                                                        <field name="key" 
type="java.lang.String">
                                                                <bind-xml 
name="string2"/>
                                                        </field>
                                                        <field name="value" 
type="UserRights"/>
                                                </class>
                                        </bind-xml>
                                </field>
                        </class>
                </bind-xml>
        </field>
</class>
</mapping>

When I try to call my context.addMapping() with this XML file I get an
exception complaining that:

 org.exolab.castor.mapping.MappingException: The method
getUserRights/isUserRights in class UserRightsMessage accepting/returning
object of type interface java.util.Map was not found.

This exception is a bit confusing because I clearly have a getUserRights
method that returns a Map, and I'm assuming that the isUserRight should be
setUserRights, and I have a setUserRights which takes a Map object.

Thanks in advance!
-- 
View this message in context: 
http://www.nabble.com/Nested-HashMap-XML-mapping-issues.-tp21612371p21612371.html
Sent from the Castor - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to