Hi again!
Thanks for the tip.
I looked and found some discussions about "serailizing boolean as 0/1 pair"
which is more or less the same as my problem. I tried to create my own
FieldHandlerFactory (note 1 below) and add it to the ClassDescriptorResolver
(see note 2 below), but I can't get it to work at all.
When I debug I can see that the getSupportedTypes()-method is called, but that
is all that is called in my factory, ie createFieldHandler(Class arg0) is never
called.
So first of all, is the Class-array returned from getSupportedTypes() correct?
If so, how come the createFieldHandler is never called?
If anybody has done something similar, could you perhaps send an example of the
code?
Best regards
Daniel
Note 1: //a snippet of my factory
public class MyDoubleFactory extends FieldHandlerFactory {
public Class[] getSupportedTypes() {
return new Class[] {
double.class,
java.lang.Double.class
};
}
}
Note 2: //attaching my factory to the marshaller
Marshaller marshaller = new Marshaller(new PrintWriter(System.out));
FieldHandlerFactory factory=new MyDoubleFactory();
ClassDescriptorResolverImpl cdr = new ClassDescriptorResolverImpl();
cdr.getIntrospector().addFieldHandlerFactory(factory);
marshaller.setResolver(cdr);
> -----Ursprungligt meddelande-----
> Från: Keith Visco [mailto:[EMAIL PROTECTED]
> Skickat: den 19 april 2006 07:57
> Till: [email protected]
> Ämne: Re: [castor-user] Serializing of double results in
> scientific expressionin XML-output
>
> Daniel,
>
> If you search the archives a bit you'll find out that you can
> set a FieldHandler
> "globally" programmatically by implementing a
> FieldHandlerFactory and specifying this on the
> ClassDescriptorResolverImpl's Introspector instance.
>
> --Keith
>
> Daniel Nilsson wrote:
> > Hi!
> > I have a problem with marshalling of double values. Ie if a have a
> > value, lets say 0.000001, the marshalled XML contains the
> Scientific
> > representation, ie 1E-5, not 0.000001 as I want.
> >
> > Is there a way to globally handle this ? Ie set some kind of global
> > wrapper for the double-type? My wrapper could then handle the
> > serializing of the double-type-elements, instead of the default
> > built-in handler.
> >
> > I have read the documentation about the FieldHandlers but if I
> > understand that part correct I have to specify if I want to use the
> > "my-double-FieldHandler" for each element I want to use it for in
> > either a mapping-file (which I don't use at the moment) or in the
> > bindings-file when generating my java-sources. But I can't seem to
> > find a way to set a handler globally for an entire class.
> >
> >
> > Best regards
> > Daniel Nilsson
> >
> >
> > -------------------------------------------------
> > 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]
-------------------------------------------------