NumberFormatException: For input string: "200%"

0
I can't seem to log an issue into the bug system, so reporting it here:

I've got an isStyledText==true field, and it just so happened that the field's value evaluated to:

<font size="200%">public </font>notes.

This resulted in the following exciting exception:

java.lang.NumberFormatException: For input string: "200%"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1207)
at java.lang.Float.valueOf(Float.java:205)
at java.lang.Float.<init>(Float.java:289)
at net.sf.jasperreports.engine.util.JRStyledTextParser.parseStyle(JRStyledTextParser.java:362)
at net.sf.jasperreports.engine.util.JRStyledTextParser.parse(JRStyledTextParser.java:140)
at net.sf.jasperreports.engine.fill.JRFillTextElement.getStyledText(JRFillTextElement.java:466)
at net.sf.jasperreports.engine.fill.JRFillTextElement.getText(JRFillTextElement.java:492)
at net.sf.jasperreports.engine.fill.JRFillTextField.prepare(JRFillTextField.java:485)
at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:345)
at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:311)
at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:275)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:1291)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillGroupFooter(JRVerticalFiller.java:685)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillGroupFooters(JRVerticalFiller.java:659)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportContent(JRVerticalFiller.java:239)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:132)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:750)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:647)
at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:63)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:402)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:234)
at net.sf.jasperreports.engine.JasperRunManager.runReportToPdf(JasperRunManager.java:203)


That's a bit harsh. Perhaps like in other cases where the styled text violates the styled rules, JasperReports should just output the raw text rather than throwing such a nasty exception.

This is particularly painful for me, because the text is submitted by the user -- for me, it is not part of the report defininition, so it is very hard to catch such a problem.

Thanks,
Dave Cherkassky
DJiNN Software.
dcherk's picture
12
Joined: Jul 18 2006 - 11:13pm
Last seen: 15 years 6 months ago

2 Answers:

0
Hi,

When the styled text content is not a valid XML, we interpret it as raw text, without raising any exceptions.
But in this particular case, the styled text is a valid XML, with tags that our styled text recognizes, is just that the value for the size attribute is unexpected.
Our HTML support in styled text right now, does not support the % character, or any other letter. It only supports integer numbers there representing the size of the font as you would normally specify using the fontSize attribute in JasperReports.

Note that our HTML support is limited, so any other HTML constructs that would work in a browser do not necessarily work in JR.

Thank you,
Teodor
teodord's picture
5675
Joined: Jun 30 2006 - 9:00am
Last seen: 1 week 3 days ago
0
Teodor:

I understand why it happened from a technical point of view, and I've already implemented a work-around.

But what I am saying is that its not very usable from a business point of view, so I think you might want to improve the functionality here a little bit...

Thanks for your explanation though -- it'll help me think of other scenarios that might result in similar issues and write some preventitive code.

Dave Cherkassky.
dcherk's picture
12
Joined: Jul 18 2006 - 11:13pm
Last seen: 15 years 6 months ago
Feedback
randomness