Hi Steven, adding parameters that should be passed to a FieldHandler to field mapping should be easy but I don't know if there are any difficulties to pass them to the FieldHandler at construction. As I never worked at FieldHandlers myself I don't know if an own instance is created for every field the same FieldHandler class is used.
Even if it would also be possible to introduce a subtag of field that allows to specify multiple paramaters I'd be in favor of a single attribute 'handler-param' on the field tag that will be passed as string to the handler. One may define his own notation for this string to pass more value to the handler. I suggest you to create a new jira issue on that enhancement. Having said that the chances to get such an enhancement fixed soon will increase dramatically if you could provide us with a patch ;-) Regards Ralf [EMAIL PROTECTED] schrieb: > Hi folks, > > I'm trying to figure out how to do a custom FieldHandler that can have > some parameters. > > In the on-going saga of my project, I have to apply some formatting > rules to some of the outgoing XML. Specifically, for certain steps I need > to have fixed-width content in the elements, and do one of the following: > > truncate to length > pad right to length with 0 characters > pad right to length with spaces > pad left to length with 0 characters > pad left to length with spaces > > I also have to do a FieldHandler to wrap all of the elements in CDATA[] > tags. This lead me to wonder if it makes sense to use a FieldHandler for > my output formatting as well. This lead me to actually read the docs at: > > http://www.castor.org/xml-fieldhandlers.html > > It looks like a custom FieldHandler is a good idea. The problem is > that I have to specify the field width and maybe a few other details, > otherwise I end up with classes like: > > PadRight20SpacesFieldHandler.java > PadRight18SpacesFieldHandler.java > PadRight18zerosFieldHandler.java > > And that is just silly :-). > > What's a good way to get the parameter in? > > If Castor doesn't have any support for something like this now, one > thought is add some sort of custom formatting attribute on > <field>, or possibly an element inside <field>. Or maybe use something > like Java Message Format > > (http://java.sun.com/j2se/1.4.2/docs/api/java/text/MessageFormat.html) > > ...though I'm not certain it will support the sort of formatting I need. > > However, having a single string parameter that can use whatever formatting > syntax the custom FieldHandler desires (java MessageFormat, sprintf, etc) > might be a good middle ground. > > Steven J. Owens > [EMAIL PROTECTED] > > > > ------------------------------------------------- > If you wish to unsubscribe from this list, please > send an empty message to the following address: > > [EMAIL PROTECTED] > ------------------------------------------------- -- Syscon Ingenieurbüro für Meß- und Datentechnik GmbH Ralf Joachim Raiffeisenstraße 11 D-72127 Kusterdingen Germany Tel. +49 7071 3690 52 Mobil: +49 173 9630135 Fax +49 7071 3690 98 Email: [EMAIL PROTECTED] Web: www.syscon-world.de ------------------------------------------------- If you wish to unsubscribe from this list, please send an empty message to the following address: [EMAIL PROTECTED] -------------------------------------------------

