I have cleaned up my test case considerably; I think it's a lot more clear 
now. If you like, re-download at

 http://pendaran.arborius.net/~jphekman/testcase.tgz

* edit Mapper.java to point to correct file locations

* export 
CLASSPATH=$CLASSPATH:build/classes:lib/castor-xml.jar:lib/xml-apis.jar:lib/xercesImpl.jar:lib/commons-logging.jar

* ant build

* java com.ingenta.Mapper

* Note that there is a commented line in containerClass.xml; if you 
swap this in for the current field descriptor for getVscs(), you will see 
that the exception goes away.

Also, I found the underlying problem (mine, not castor's) which had
originally pushed me to make this syntax change. I will be returning to
the working syntax in my project, and am no longer blocked. I'm more than 
happy to continue to help clarify this bug (assuming it is a bug and not 
just bad syntax -- but there should probably be a better error message in 
that case).

Jessica

On Wed, Nov 30, 2005 at 10:57:36PM -0600, Keith Visco wrote:
> Hi Jessica,
> 
> I haven't seen that problem before. Is it possible for you to send me a 
> working (ie compilable and demonstrates the problem) test case which I 
> can run locally?
> 
> --Keith
> 
> Jessica Perry Hekman wrote:
> >Hi all. I have a class which has a method (getCurrency()) which returns 
> >type java.util.Currency. The doc seems to suggest that writing a custom 
> >field handler is the way to proceed, and provides good instruction on how 
> >to do so. I created:
> >
> >package com.ingenta.ics.api.rest.product;
> >
> >import org.exolab.castor.mapping.GeneralizedFieldHandler;
> >import org.exolab.castor.mapping.FieldDescriptor;
> >
> >import java.util.Currency;
> >
> >/**
> > * The FieldHandler for the Currency class
> >**/
> >public class CurrencyFieldHandler
> >    extends GeneralizedFieldHandler
> >{
> >
> >    public CurrencyFieldHandler() {
> >        super();
> >    }
> >
> >    public Object convertUponGet(Object value) {
> >        if (value == null) return null;
> >        Currency currency = (Currency)value;
> >        return currency.getCurrencyCode();
> >    }
> >
> >
> >    public Object convertUponSet(Object value) {
> >        return Currency.getInstance((String)value);
> >    }
> >
> >    public Class getFieldType() {
> >        return Currency.class;
> >    }
> >
> >    public Object newInstance( Object parent )
> >        throws IllegalStateException
> >    {
> >        //-- Since it's marked as a string...just return null,
> >        //-- it's not needed.
> >        return null;
> >    }
> >
> >}
> >
> >and in the XML:
> >
> ><class name="com.ingenta.ics.ecommerce.api.item.Price">
> >   <map-to xml="price"/>
> >   <field name="id" type="com.ingenta.ics.item.Id" />
> >   <field name="amount" type="big-decimal"/>
> >   <field name="currency" type="string" 
> >          handler="com.ingenta.ics.api.rest.product.CurrencyFieldHandler"/>
> ></class>
> >
> >Now, marshalling works beautifully. Unmarshalling gives me:
> >
> >1) 
> >testProduct(com.ingenta.ics.api.item.ProductMarshallingTest)java.lang.NullPointerException
> > at 
> >org.exolab.castor.xml.util.XMLFieldDescriptorImpl.hashCode(XMLFieldDescriptorImpl.java:416)
> >        at java.util.HashMap.hash(HashMap.java:261)
> >        at java.util.HashMap.containsKey(HashMap.java:339)
> >
> >I am not sure what's going on -- was I supposed to implement hashCode? 
> >Castor's doc doesn't say so. Is this error familiar to anyone?
> >
> >Thanks in advance,
> >
> >Jessica
> >
> >
> >-------------------------------------------------
> >If you wish to unsubscribe from this list, please 
> >send an empty message to the following address:
> >
> >[EMAIL PROTECTED]
> >-------------------------------------------------
> >
> >
> 
> 
> -------------------------------------------------
> If you wish to unsubscribe from this list, please 
> send an empty message to the following address:
> 
> [EMAIL PROTECTED]
> -------------------------------------------------
> 

-------------------------------------------------
If you wish to unsubscribe from this list, please 
send an empty message to the following address:

[EMAIL PROTECTED]
-------------------------------------------------

Reply via email to