Thanks for the response. I briefly took a look at flavour, but it appeared to be something that wasn't supported currently and not having looked at a roadmap or anything I was a little nervous to use it since I didn't know what the actual intended use was (outside of one post that briefly discussed flavour). Sorry to hear about your development machine, best wishes with that. I took your advice and worked up something. It's kind of a combination of what you suggested. I've got it working. Basically, I'm setting 2 options variables. 1) The classname of the objectStringConverter and 2) the classname of a Converter class that ConvertUtils will use. I did this because it seemed to stick as close to the current implementation as I could. I modified the Updater interface to take a 3rd parameter - an instance of an ObjectStringConverter. I use that to do the conversion. I pass the Converter class through in a context variable and use that with ConvertUtils. I'm hoping that the ConvertUtils.register and ConvertUtils.deregister isn't too much of a performace drag. I will try to put a patch out there tomorrow (or asap - wife is 1 week overdue with a little one so it's anyday). Take a look and let me know what you think.

Thanks,

Matt


robert burrell donkin wrote:

hi matt

this kind of scenario was intended to be supported by the flavour
parameter passed into the converter. the idea was that the flavour is an
arbitrary string which could be set either in a betwixt file or by some
course grained strategy. if the converter understood the flavour then it
could perform the appropriate conversion.


my main development machine recently blew up on me and i'm still in the
process of configuring my secondary machine for apache development. so
i'm not really in a position to do much development right now. there's a
chance that support for flavours in dot betwixt files has already been
added. if not, then perhaps you'd like to replace your workaround with
an implementation that allows the flavour of the conversion to be set by
an attribute in the betwixt file. i'd be very happy to review any such
contribute if you'd like to donate it to apache. (the best way is by
submitting a patch through bugzilla). please consider adding unit tests
and documentation.

i do agree that it would be cool to be able to interrogate the options
for the current element within the converter. perhaps it would be
possible to add this information to the context (perhaps through a magic
variable) or just by adding an extra signature to the
ObjectStringConverter. that would allow a default implementation to
instantiate a converter to delegate to based on a magic option (just as
you had it). i like this solution but suspect that it would probably
require a little more effort that adding flavour support.


i'd probably support both mechanisms and be willing to review
contributed patchs.

on a more general note, i'm now wondering whether it might be a good
idea to allow the binding configuration to be specified within a betwixt
file (possibly by use of a factory class). comments welcomed :)

- robert

On Fri, 2005-01-28 at 19:35, Matt Goodwin wrote:


I have been able to be able to write out a bean with a date to a format other than the default by specifying an options parameter and doing a quick hack
to the betwixt source. Here is the .betwixt file.
<?xml version='1.0' ?>
<info>
<element name='ActivitySummary'>
<element name='CommissionsYTD' property='commissionsYTD'/>
<element name='LastCommissionAmt' property='lastCommissionAmt'/>
<element name='LastCommissionDate' property='lastCommissionDate'>
<option>
<name>org.apache.commons.betwixt.object-string-converter</name>
<value>com.equitrust.util.betwixt.strategy.SegDateObjectStringConverter</value>
</option>
</element>
<element name='PremiumYTD' property='premiumYTD'/>
</element>
</info>


I modded the source in the AbstractBeanWriter in the convertToString method by just simply checking of the existence of the option for object-string-converter and then instantiating the converter specified. Real ugly hack, but it works. However, this does not work for string to
object conversion because digester just uses the objectStringConverter on the BindingConfiguration. I've been trying to trace through and see where
the objectStringConverter is set on the BindingConfiguration and see what ways I can override this with the .betwixt file. Does anyone see a way I can do this? I'd like to be able to specify everything in the .betwixt file so I don't have to specify my converter in code, and also in case I need to use a different format for a different element (it appears that the converter when registering it will convert all elements of the type - in my case date - using the same converter). Open to any ideas.


Thanks,

Matt
p.s. If you see a better way to do the ObjectToString conversion besides my hack, please input that as well




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-- Matt Goodwin [EMAIL PROTECTED] (515)708-0114 Metalexis "Transcending the Ordinary"


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to