commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akiraleon123 <akira.leon...@gmail.com>
Subject Re: digester ignore data mismatch exception?
Date Tue, 20 Nov 2007 21:23:27 GMT

Hi Simon,
   Thanks a lot for your reply. It is ok for my application to have
un-initialized data in objects when invalid i/p is seen instead of stopping
the parsing activity. Also, thanks for the pattern related answer. That
helped.

Akira.



Simon Kitching-4 wrote:
> 
> Hi Akira,
> 
> I can't think of any obvious way to handle this. Digester was never
> designed to half-process half-broken input files.
> 
> If you only want specific parts of the input file, then you could write
> an XSLT to first transform the original input into one that can be fed
> into digester.
> 
> Or you could write a SAXFilter class to modify the input in some way.
> Remember that Digester is just a sax handler class, ie processes a
> stream of sax events. The methods that take a stream or file as input
> are just convenience methods. So modifying the event stream before
> digester sees it is perfectly valid.
> 
> Or as you say, custom BeanUtils converters could be used to provide
> default values in case of invalid input. This approach cannot prevent
> any digester rules from being executed though, so you will end up with
> an object tree with some incompletely-initialised objects in it.
> 
> Regards,
> 
> Simon
> 
> On Tue, 2007-11-20 at 11:25 -0800, akiraleon123 wrote:
>> The only way i see is to change source code in beanutils(may be writing
>> custom converter or catching the conversionexception etc.,) and recompile
>> it. I 'd appreciate if you can let me know if there is any graceful way
>> to
>> handle this requirement.
>> 
>> thanks.
>> akira
>> 
>> akiraleon123 wrote:
>> > 
>> > Hi All,
>> >  Any help is sincerely appreciated.
>> > 
>> > How can i instruct digester to ignore the data type mismatch exceptions
>> > being caused by beanutils and proceed further?
>> > So, from the previous xml file, though the first resource causes an
>> > exception, 
>> > 
>> > 
>> > org.apache.commons.beanutils.ConversionException: For input string:
>> "fcd"
>> > 	at
>> >
>> org.apache.commons.beanutils.converters.BigDecimalConverter.convert(BigDecimalConverter.java:162)
>> > 
>> > 
>> > 
>> > i want to get the second resource object.
>> > 
>> > 
>> > <country>
>> > <companies>
>> > <company name="dell">
>> > <resources>
>> > 
>> > <resource value="fcd"/> <!--data type mismatch-->
>> > 
>> > <resource value="33.44"/>
>> > 
>> > </resources>
>> > </company>
>> > </companies>
>> > </country>
>> > 
>> > 
>> > My class file:
>> > 
>> > class Resource{
>> > private BigDecimal value;
>> > //getters, setters
>> > }
>> > 
>> > 
>> > 
>> > thanks,
>> > akira.
>> > 
>> > 
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/digester-ignore-data-mismatch-exception--tf4839300.html#a13866138
Sent from the Commons - User mailing list archive at Nabble.com.


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


Mime
View raw message