|
I'm having trouble using a "GeneralizedFieldHandler" to convert from a
string element to another-typed field. Fragments follow: schema: <element name="foo" type="xs:string"/> binding.xml: <elementBinding name="foo"> <member name="convertedFoo" java-type="Long" handler="foo.MyFieldHandler"/> </elementBinding> the field handler: class MyFieldHandler extended GeneralizedFieldHandler { Object convertUponSet(Object in) { return new Long((String) in); } } The generated code (object model): Long convertedFoo; void setConvertedFoo(Long x) { convertedFoo = x; } Now, this all looks more-or-less ok, but the problem is that the generated Descriptor file has already interpreted the foo element as a Long before it gets to the field handler, presumably because of this line in the descriptor file: desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(Long.class, "convertedFoo", "foo", org.exolab.castor.xml.NodeType.Element); (Note the Long.class here) I think the field descriptor ought to *always* match the schema, not whatever the binding file says. Of course, changing my binding file's java-type to String (to overcome that problem) causes the member to be defined as a string, which also breaks the field handler (though in a different way). The documentation on "Writing custom field handlers" has the following note: Note: Currently the GeneralizedFieldHandler cannot be used from a binding-file for use with the SourceGenerator, an enhancement patch will be checked into CVS for this feature, shortly after 0.9.6 final is released. I'd assumed that this patch was applied long ago - perhaps not after all? Thanks, Michael --
-------------------------------------------------
If you wish to unsubscribe from this list, please
send an empty message to the following address:
[EMAIL PROTECTED]
-------------------------------------------------
|

