commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Goodwin <mgood...@metalexis.com>
Subject [betwixt] object<->string conversion .betwixt file
Date Fri, 28 Jan 2005 19:35:46 GMT
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

-- 
Matt Goodwin
mgoodwin@metalexis.com
(515)708-0114
Metalexis
"Transcending the Ordinary"


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message