Jump to content
JasperReports Library 7.0 is now available ×

patrick.krings

Members
  • Posts

    2
  • Joined

  • Last visited

patrick.krings's Achievements

Newbie

Newbie (1/14)

  • Week One Done
  • One Month Later
  • One Year In
  • First Post Rare
  • Conversation Starter Rare

Recent Badges

0

Reputation

  1. I had the same issue running iReport 5.6.0. You indeed need something like JRE 7 installed. Head to your iReport installation and edit iReportetcireport.conf: jdkhome must be set to your JRE 7 installation path, e.g.: jdkhome="C:jre1.7.0_80"[/code]
  2. Hey everyone! I am having a bit of trouble with getting my report with subreports to run. As a datasoure I get some XML and I want to sum up some of the values for specific entries. Basically this works fine, but in addition I have to deal with some Strings that cannot be parsed to Double value. For example I might get "a1.0a" instead of just "1.0" from XML source. It is fine if I just get a 0.0 if the number cannot be parsed. What I have tried so far is to use the static java.util.regex.Pattern.matches-function like this: java.util.regex.Pattern.matches(("[\x00-\x20]*" + "[+-]?(" + "NaN|" + "Infinity|" + "(((" + "(\p{Digit}+)" + "(\.)?(" + "(\p{Digit}+)" + "?)(" + ("[eE][+-]?" + "(\p{Digit}+)") + ")?)|" + "(\.(" + "(\p{Digit}+)" + ")(" + ("[eE][+-]?" + "(\p{Digit}+)") + ")?)|" + "((" + "(0[xX]" + "(\p{XDigit}+)" + "(\.)?)|" + "(0[xX]" + "(\p{XDigit}+)" + "?(\.)" + "(\p{XDigit}+)" + ")" + ")[pP][+-]?" + "(\p{Digit}+)" + "))" + "[fFdD]?))" + "[\x00-\x20]*"), $F{MENGE})[/code]This code basically checks if the field MENGE only contains digits or comma or dots. It returns a boolean, so it can be used in the conditional statement () ? true : false to either do the conversion or just return 0.0. Unfortunately I am just receiving the following exception: Error filling print... Unparseable number: "a1.0a" The complete code for the Variable Expression looks like this: java.util.regex.Pattern.matches(("[\x00-\x20]*" + "[+-]?(" + "NaN|" + "Infinity|" + "(((" + "(\p{Digit}+)" + "(\.)?(" + "(\p{Digit}+)" + "?)(" + ("[eE][+-]?" + "(\p{Digit}+)") + ")?)|" + "(\.(" + "(\p{Digit}+)" + ")(" + ("[eE][+-]?" + "(\p{Digit}+)") + ")?)|" + "((" + "(0[xX]" + "(\p{XDigit}+)" + "(\.)?)|" + "(0[xX]" + "(\p{XDigit}+)" + "?(\.)" + "(\p{XDigit}+)" + ")" + ")[pP][+-]?" + "(\p{Digit}+)" + "))" + "[fFdD]?))" + "[\x00-\x20]*"), $F{MENGE}) ? ($F{EINHEIT}.equals("l") ? Double.valueOf($F{MENGE}): ($F{EINHEIT}.equals("m³") ? Double.valueOf($F{MENGE})*1000: ($F{EINHEIT}.equals("ml") ? Double.valueOf($F{MENGE})*0.001: ($F{EINHEIT}.equals("g") ? Double.valueOf($F{MENGE}): ($F{EINHEIT}.equals("t") ? Double.valueOf($F{MENGE})*1000000: ($F{EINHEIT}.equals("kg") ? Double.valueOf($F{MENGE})*1000: ($F{EINHEIT}.equals("mg") ? Double.valueOf($F{MENGE})*0.001: ($F{EINHEIT}.equals("Stk") ? Double.valueOf($F{MENGE}) : Double.valueOf($F{MENGE}))))))))) : 0.0[/code]If the field MENGE is a number some unit conversion is done and returned. If it is not a number just 0.0 shall be returned. It works perfectly fine for only digits/numbers inside the field MENGE. Might it be true that the conversion of the field MENGE happens in any case and the return value is only used IF the condition returns true? Any help will be appreciated!
×
×
  • Create New...