Hi Keith,

Removed the type attribute but no success. Still unmarshalls as a Hashtable
not containing the key specified.

<mapping xmlns="http://castor.exolab.org/";>
    <class name="adpsis.posse.posseErrors.PosseErrors">
        <map-to xml="posse-errors"/>
        <field name="errors" collection="hashtable">
            <bind-xml name="errors" node="element">
                <class name="org.exolab.castor.mapping.MapItem">
                     <field name="key" type="java.lang.String">
                         <bind-xml name="code" node="attribute"/>
                     </field>
                     <field name="value"
type="adpsis.posse.posseErrors.MyMap"/>
                 </class>
            </bind-xml>
        </field>
    </class>
</mapping>

-Brett

-----Original Message-----
From: Keith Visco [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 23, 2004 6:11 PM
To: [EMAIL PROTECTED]
Subject: Re: [castor-dev] Hashtable Unmarshalling




Hi Brett,

If you look at the example, you'll notice I didn't specify
type="java.util.Hashtable". Actually, I don't believe I specified a type
at all.

When you use collections, the collection="..." specifies the collection
type. The type attribute is used for specifying the object type within
the collection.

When dealing with Hashtable/HashMap in 0.9.5.3 Castor automatically sets
the type attribute to "org.exolab.castor.mapping.MapItem", so you can
leave out the type attribute.

--Keith


"Schmoll, Brett x66244" wrote:
> 
> Thanks for your response Keith. I'd like to get this to work using the
> current 0.9.5.3 behaviour. I reviewed the sample provided and that all
makes
> sense.....however, I'm still having difficulties getting a string key and
> object value mapped into a hashtable.
> 
> Latest map file:
> <mapping xmlns="http://castor.exolab.org/";>
>     <class name="adpsis.posse.posseErrors.PosseErrors">
>         <map-to xml="posse-errors"/>
>         <field name="errors" collection="hashtable"
> type="java.util.Hashtable">
>             <bind-xml name="errors" node="element">
>                 <class name="org.exolab.castor.mapping.MapItem">
>                     <field name="key" type="java.lang.String">
>                         <bind-xml name="code" node="attribute"/>
>                     </field>
>                     <field name="value"
> type="adpsis.posse.posseErrors.MyMap"/>
>                 </class>
>             </bind-xml>
>         </field>
>     </class>
> </mapping>
> 
> Simplified XML:
> <?xml version="1.0" encoding="UTF-8" ?>
> <posse-errors>
>         <errors code="6503" xsi:type="java:adpsis.posse.posseErrors.MyMap"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
>                 <description>getEntireResult() failed!</description>
>                 <systemmsg>System Message 1:</systemmsg>
>         </errors>
>         <errors code="6502" xsi:type="java:adpsis.posse.posseErrors.MyMap"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
>                 <description>Bean not found: </description>
>                 <systemmsg>System Message 2: </systemmsg>
>         </errors>
> </posse-errors>
> 
> After unmarshalling this, I have a hashtable containing
> {(MyMap1,MyMap1),(MyMap2,MyMap2)} where MyMap1 is the 1st errors stanza
and
> MyMap2 is the 2nd errors stanza. What I'm trying to get is
> {("6503",MyMap1),("6502",MyMap2)}. Getting closer but still confused.
> 
> Thanks,
> -Brett
> 
> -----Original Message-----
> From: Keith Visco [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, March 23, 2004 4:55 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [castor-dev] Hashtable Unmarshalling
> 
> Brett,
> 
> For backward compatibility with pre 0.9.5.3 versions you can uncomment
> the below property from the castor.properties file:
> 
> # This section defines Backward compatibility switches
> #
> # Hashtable/Map default mapping
> #  - For backward compatibility with 0.9.5.2 and earlier
> #
> #org.exolab.castor.xml.saveMapKeys=false
> 
> If you want an example of using 0.9.5.3 HashMaps, you can look at the
> following:
> 
> ftp://ftp.exolab.org/pub/castor/examples/CastorXML/HashMaps/example1.zip
> 
> --Keith
> 
> > "Schmoll, Brett x66244" wrote:
> >
> > Hi,
> >
> > I'm trying to upgrade to castor-0.9.5.3 and am having a problem
> > unmarshalling a HashTable that previously worked with 9.3.21.
> >
> > Here is the map file:
> >
> > <mapping xmlns="http://castor.exolab.org/";
> > xmlns:cst="http://castor.exolab.org/";>
> >     <class cst:name="adpsis.posse.posseErrors.PosseErrors"
> > cst:access="shared">
> >         <map-to cst:xml="posse-errors"/>
> >         <field cst:name="errors" cst:type="java.util.Hashtable">
> >         <bind-xml name="errors" node="element"/>
> >         </field>
> >     </class>
> >     <class cst:name="java.util.Hashtable" cst:access="shared">
> >         <map-to cst:xml="hashtable"/>
> >         <field cst:name="empty" cst:type="boolean">
> >         <bind-xml name="empty" node="attribute"/>
> >         </field>
> >     </class>
> > </mapping>
> >
> > XML Snippet:
> > <?xml version="1.0" encoding="UTF-8" ?>
> > <posse-errors>
> >         <errors code="6503" logged="true" overrideable="false"
> > severity="2" xsi:type="java:adpsis.posse.posseErrors.PosseError"
> > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
> >
> >                 <id>GET_ENTIRE_RESULT_EXCEPTION</id>
> >                 <disposition>dialog</disposition>
> >                 <description>getEntireResult() failed!</description>
> >                 <systemmsg>getEntireResult() failed!</systemmsg>
> >         </errors>
> > ...
> >
> > I've looked at the new HashTable/HashMap behaviour for 0.9.5.3 and the
> > nested class mapping supported by 0.9.5.3 and tried several different
> > map files but still encounter the "java.lang.IllegalArgumentException:
> > Type conversion error: could not set value of
> > errors(java.util.Hashtable) with value of type
> > org.exolab.castor.mapping.MapItem"
> >
> > Searching the archives I was unable to find an example available on
> > the list.
> >
> > TIA,
> > -Brett
> >
> > This message and any attachments are intended only for the use of the
> > addressee and may contain information that is privileged and
> > confidential. If the reader of the message is not the intended
> > recipient or an authorized representative of the intended recipient,
> > you are hereby notified that any dissemination of this communication
> > is strictly prohibited. If you have received this communication in
> > error, please notify us immediately by e-mail and delete the message
> > and any attachments from your system.
> 
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
>         unsubscribe castor-dev
> 
>   ------------------------------------------------------------------------
> 
>    Part 1.2    Type: application/ms-tnef
>            Encoding: base64

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

<<application/ms-tnef>>

Reply via email to