Hello again
I have something like
ClassDescriptorResolverImpl cdr = new
ClassDescriptorResolverImpl();
cdr.associate(java.sql.Timestamp.class, new
CustomDateClassDescriptor());
cdr.associate(java.util.Date.class, new
CustomDateClassDescriptor());
DocumentRoot root = new DocumentRoot(object);
StringWriter writer = new StringWriter();
Marshaller marshaller = new Marshaller(writer);
marshaller.setResolver(cdr);
marshaller.marshal(root);
return writer.toString();
And still it doesnt look like its even calling my resolver.
I have put some trace debugs and my CustomDateClassDescriptor is never
called.
Any ideas?
Thanks
Regard
henry
-----Message d'origine-----
De : Keith Visco [mailto:[EMAIL PROTECTED]
Envoy� : 24 septembre, 2003 15:59
� : Voyer Henry
Objet : Re: RE : [castor-dev] Castor XML : How to programaticaly process
types?
Oops, I left out one part:
After you do the cdr.associate(...);
You then need to set this in the Marshaller or Unmarshaller:
Marshaller m = new Marshaller(writer);
m.setMapping(...);
m...
m.setResolver(cdr);
And the same for the Unmarshaller.
--Keith
Voyer Henry wrote:
>
> Thanks a lot
>
> :)
>
> -----Message d'origine-----
> De : Keith Visco [mailto:[EMAIL PROTECTED]
> Envoy� : 24 septembre, 2003 15:06
> � : [EMAIL PROTECTED]
> Objet : Re: [castor-dev] Castor XML : How to programaticaly process
> types?
>
> Henry,
>
> You can implement an org.exolab.castor.xml.XMLClassDescriptor for
> java.util.Date and then register this with the ClassDescriptorResolver
> before processing:
>
> import org.exolab.castor.xml.ClassDescriptorResolver;
> import org.exolab.castor.xml.util.ClassDescriptorResolverImpl;
>
> ClassDescriptorResolverImpl cdr = new ClassDescriptorResolverImpl();
> cdr.associate(java.util.Date.class, new MyDateDescriptor());
>
> A perfect example on how to write the MyDateDescriptor class would be:
>
> org/exolab/castor/xml/descriptors/DateClassDescriptor.java
>
> you may also want to look at:
>
> org/exolab/castor/xml/handlers/DateFieldHandler.java
>
> --Keith
>
> > Voyer Henry wrote:
> >
> > Hi everyone
> >
> > I used to have mappings and handlers for my objects.
> >
> > Since I have dozens of classes, I need to stop using mappings and
> > try to use programmed configurations. Since the classes can change.
> >
> > Is there a way ,with examples, to specify the handler to use for
> > different types. Types like dates, timestamps, etc, objects
> >
> > via a java interface or class.
> > Etc.
> >
> > Thanks
> >
> > Regards
> >
> > henry
>
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
> unsubscribe castor-dev
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev