Sylvain,
 
have a look at the current CTF tests for mapping 'maps' of any kind at 
 
http://svn.castor.codehaus.org/browse/castor/castor/trunk/src/tests/xml/
MasterTestSuite/mapping/Maps
 
As it stands right now, all these test sfinish without any problems. And
I have actually added a test case (treeMap sub-dir) that sucessfully
(un)marshalls a TreeMap as a result of our conversation. If you manage
to give me a version of this very code that you manage to break, feel
free to do so ....
 
Werner


________________________________

        From: castor sylvain [mailto:[EMAIL PROTECTED] 
        Sent: Dienstag, 28. November 2006 09:34
        To: [email protected]
        Subject: Re: [castor-user] Howto map a TreeMap ?
        
        
        Thanks, Werner for your response
        
        But as i mentioned in my previous post, i've already tried a) : 
        it doesn't fix anything.
        
        And b) doesn't change anything at all.
        I invite you to make a test, with a TreeMap based on a Java
Comparator 
        
        ;-)
        
        
        
        On 11/24/06, Werner Guttmann <[EMAIL PROTECTED]> wrote: 

                Hi,
                
                there's a few items you'll need to fix:
                
                a) field mapping for "radios" should read ...
                
                   <field name=3D"radios" collection=3D"map">
                
                b) Code to initialize the radios member in FormRadio
should read ... 
                
                   private Map radios = new TreeMap();
                
                I hope this clarifies a few things
                Werner
                
                castor sylvain wrote:
                > Hi,
                >
                > I desperatly try to map a ordered TreeMap.
                > (It works fine if this map is a basic HashMap) 
                >
                > The mapping :
                >     [...]
                >     <class name="com.mycompany.myproduct.FormRadio">
                >         <field name="radios" collection="hashtable">
                >             <bind-xml name="radio"> 
                >                 <class
name="org.exolab.castor.mapping.MapItem">
                >                     <field name="key"
type="java.lang.String">
                >                         <bind-xml name="key"
node="attribute" /> 
                >                     </field>
                >                     <field name="value"
type="java.lang.String">
                >                         <bind-xml node="text"/>
                >                     </field> 
                >                 </class>
                >             </bind-xml>
                >         </field>
                >     </class>
                >     [...]
                >
                >
                > The class :
                > import java.util.Map;
                > public class FormRadio extends FormField {
                >     private Map radios = null;
                >     [...]
                >     public Map getRadios() {
                >         return radios;
                >     }
                >     public void setRadios(Map radios) { 
                >         this.radios = radios;
                >     }
                > }
                >
                >
                > The "radios" map on FormRadio class is a TreeMap,
based/ordered on a
                > Java Comparator.
                > It doesn't really fail, but the "value" fields of my
TreeMap are not 
                > outputed.
                > (only the keys are outputed in attribute, as
specified).
                >
                > Even if i replace :
                > 1) collection="hashtable" ... by : collection="map"
                > 2) <bind-xml node="text"/> ... by : <bind-xml
name="value" 
                > node="attribute"/>
                >
                >
                > Thanks in advance for any workaround, or any
suggestion about a matching
                > mapping file.
                > ;-)
                >
                >
                >
                
                
        
--------------------------------------------------------------------- 
                To unsubscribe from this list please visit:
                
                    http://xircles.codehaus.org/manage_email
                
                



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

    http://xircles.codehaus.org/manage_email

Reply via email to