Say you have an object of a Java class called Outer, which contains a member
object of class Inner named inner. Outer contains just public member data,
so using field elements with direct="true" attributes in the mapping file is
enough for its mapping, but Inner is a bit more complicated, so it needs a
custom, compile-time class descriptor-which implies that it's not mentioned
in the mapping file.
This works great for marshalling. When castor sees a Outer object, it
consults the class element for Outer in the mapping file, sees the inner
member, looks up the custom Inner class descriptor, and calls its getValue()
to find what it should write.
For unmarshalling, though, it doesn't quite work the same way. The custom
class descriptor for Inner is never used. I hoped that as an Outer object
was unmarshalled, it would see the "Inner" element, and use the custom Inner
custom class descriptor to create the new Inner object. At first, I noticed
that the custom class descriptor resolver was never getting called. So I
changed a few lines in UnmarshalHandler.java to always call the class
descriptor resolver when looking for a member's class descriptor, rather
than relying on the parent's default field handler for that member. But that
still didn't work...
Before I caused irrepairable damage to my copy of Castor, I wanted to ask:
is this by design? Since marshalling will use a field's custom class
descriptor to get it's value, why doesn't unmarshalling use it to create and
set it's value?
Joe
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev