Jump to content
JasperReports Library 7.0 is now available ×

Parsing and casting


Recommended Posts

By: Mihai Gheorghiu - tanethq

Parsing and casting

2002-02-22 14:17

RH7.2, jdk1.4.0rc

Please read the following declarations:

 

<variable name="NoRecs" class="java.lang.Integer" resetType="Report" resetGroup="" calculation="Count">

<variableExpression>(($F{Account}==null)?(new Integer(1)):(new Integer(1)))</variableExpression>

</variable>

 

<variable name="PosAmt" class="java.lang.Double" resetType="Report" resetGroup="" calculation="Sum">

<variableExpression>(($F{Amount}>=(new Double(0.0)))?($F{Amount}):(new Double(0.0)))</variableExpression>

</variable>

 

<variable name="NegAmt" class="java.lang.Double" resetType="Report" resetGroup="" calculation="Sum">

<variableExpression>(($F{Amount}>(new Double(0.0)))?(new Double(0.0)):($F{Amount}))</variableExpression>

</variable>

 

<variable name="PosLF" class="java.lang.Double" resetType="Report" resetGroup="" calculation="Sum">

<variableExpression>(($F{LateFees}>=(new Double(0.0)))?($F{LateFees}):(new Double(0.0)))</variableExpression>

</variable>

 

<variable name="NegLF" class="java.lang.Double" resetType="Report" resetGroup="" calculation="Sum">

<variableExpression>(($F{LateFees}>(new Double(0.0)))?(new Double(0.0)):($F{LateFees}))</variableExpression>

</variable>

 

1. Parsing

If I want to revert the >= sign, without changing the order of the options, I need the < sign. However, if I do this, I get a parsing error. If this is not a Java version compatibility error, I think it needs attention.

2. Casting (sorry, it's long)

dori.jasper.engine.JRException: Errors were encountered when compiling report design:

Note: sun.tools.javac.Main has been deprecated.

Report1.java:148: Incompatible type for >. Can't convert java.lang.Double to int.

value = (java.lang.Double)(((((java.lang.Double)field_LateFees.getValue())>(new Double(0.0)))?(new Double(0.0)):(((java.lang.Double)field_LateFees.getValue()))));

^

Report1.java:213: Incompatible type for >. Can't convert java.lang.Double to int.

value = (java.lang.Double)(((((java.lang.Double)field_Amount.getValue())>(new Double(0.0)))?(new Double(0.0)):(((java.lang.Double)field_Amount.getValue()))));

^

Report1.java:233: Invalid cast from int to java.lang.Double.

value = (java.lang.Double)(((java.lang.Double)variable_PosAmt.getValue()) + ((java.lang.Double)variable_NegAmt.getValue()));

^

Report1.java:233: Incompatible type for +. Can't convert java.lang.Double to int.

value = (java.lang.Double)(((java.lang.Double)variable_PosAmt.getValue()) + ((java.lang.Double)variable_NegAmt.getValue()));

^

Report1.java:238: Invalid cast from int to java.lang.Double.

value = (java.lang.Double)(((java.lang.Double)variable_PosLF.getValue()) + ((java.lang.Double)variable_NegLF.getValue()));

^

Report1.java:238: Incompatible type for +. Can't convert java.lang.Double to int.

value = (java.lang.Double)(((java.lang.Double)variable_PosLF.getValue()) + ((java.lang.Double)variable_NegLF.getValue()));

^

Report1.java:248: Incompatible type for >=. Can't convert java.lang.Double to int.

value = (java.lang.Double)(((((java.lang.Double)field_LateFees.getValue())>=(new Double(0.0)))?(((java.lang.Double)field_LateFees.getValue())):(new Double(0.0))));

^

Report1.java:258: Incompatible type for >=. Can't convert java.lang.Double to int.

value = (java.lang.Double)(((((java.lang.Double)field_Amount.getValue())>=(new Double(0.0)))?(((java.lang.Double)field_Amount.getValue())):(new Double(0.0))));

^

Report1.java:356: Incompatible type for >. Can't convert java.lang.Double to int.

value = (java.lang.Double)(((((java.lang.Double)field_LateFees.getOldValue())>(new Double(0.0)))?(new Double(0.0)):(((java.lang.Double)field_LateFees.getOldValue()))));

^

Report1.java:421: Incompatible type for >. Can't convert java.lang.Double to int.

value = (java.lang.Double)(((((java.lang.Double)field_Amount.getOldValue())>(new Double(0.0)))?(new Double(0.0)):(((java.lang.Double)field_Amount.getOldValue()))));

^

Report1.java:441: Invalid cast from int to java.lang.Double.

value = (java.lang.Double)(((java.lang.Double)variable_PosAmt.getOldValue()) + ((java.lang.Double)variable_NegAmt.getOldValue()));

^

Report1.java:441: Incompatible type for +. Can't convert java.lang.Double to int.

value = (java.lang.Double)(((java.lang.Double)variable_PosAmt.getOldValue()) + ((java.lang.Double)variable_NegAmt.getOldValue()));

^

Report1.java:446: Invalid cast from int to java.lang.Double.

value = (java.lang.Double)(((java.lang.Double)variable_PosLF.getOldValue()) + ((java.lang.Double)variable_NegLF.getOldValue()));

^

Report1.java:446: Incompatible type for +. Can't convert java.lang.Double to int.

value = (java.lang.Double)(((java.lang.Double)variable_PosLF.getOldValue()) + ((java.lang.Double)variable_NegLF.getOldValue()));

^

Report1.java:456: Incompatible type for >=. Can't convert java.lang.Double to int.

value = (java.lang.Double)(((((java.lang.Double)field_LateFees.getOldValue())>=(new Double(0.0)))?(((java.lang.Double)field_LateFees.getOldValue())):(new Double(0.0))));

^

Report1.java:466: Incompatible type for >=. Can't convert java.lang.Double to int.

value = (java.lang.Double)(((((java.lang.Double)field_Amount.getOldValue())>=(new Double(0.0)))?(((java.lang.Double)field_Amount.getOldValue())):(new Double(0.0))));

^

Report1.java:564: Incompatible type for >. Can't convert java.lang.Double to int.

value = (java.lang.Double)(((((java.lang.Double)field_LateFees.getValue())>(new Double(0.0)))?(new Double(0.0)):(((java.lang.Double)field_LateFees.getValue()))));

^

Report1.java:629: Incompatible type for >. Can't convert java.lang.Double to int.

value = (java.lang.Double)(((((java.lang.Double)field_Amount.getValue())>(new Double(0.0)))?(new Double(0.0)):(((java.lang.Double)field_Amount.getValue()))));

^

Report1.java:649: Invalid cast from int to java.lang.Double.

value = (java.lang.Double)(((java.lang.Double)variable_PosAmt.getEstimatedValue()) + ((java.lang.Double)variable_NegAmt.getEstimatedValue()));

^

Report1.java:649: Incompatible type for +. Can't convert java.lang.Double to int.

value = (java.lang.Double)(((java.lang.Double)variable_PosAmt.getEstimatedValue()) + ((java.lang.Double)variable_NegAmt.getEstimatedValue()));

^

Report1.java:654: Invalid cast from int to java.lang.Double.

value = (java.lang.Double)(((java.lang.Double)variable_PosLF.getEstimatedValue()) + ((java.lang.Double)variable_NegLF.getEstimatedValue()));

^

Report1.java:654: Incompatible type for +. Can't convert java.lang.Double to int.

value = (java.lang.Double)(((java.lang.Double)variable_PosLF.getEstimatedValue()) + ((java.lang.Double)variable_NegLF.getEstimatedValue()));

^

Report1.java:664: Incompatible type for >=. Can't convert java.lang.Double to int.

value = (java.lang.Double)(((((java.lang.Double)field_LateFees.getValue())>=(new Double(0.0)))?(((java.lang.Double)field_LateFees.getValue())):(new Double(0.0))));

^

Report1.java:674: Incompatible type for >=. Can't convert java.lang.Double to int.

value = (java.lang.Double)(((((java.lang.Double)field_Amount.getValue())>=(new Double(0.0)))?(((java.lang.Double)field_Amount.getValue())):(new Double(0.0))));

^

24 errors, 1 warning

 

at dori.jasper.engine.JRCompiler.compileReport(JRCompiler.java:78)

at dori.jasper.engine.JasperManager.compileReportToFile(JasperManager.java:857)

at dori.jasper.engine.JasperManager.compileReportToFile(JasperManager.java:845)

at TestApp.main(TestApp.java:10)

 

Are the operators valid only for integers?

Thank you all.

 

 

By: Teodor Danciu - teodord

RE: Parsing and casting

2002-02-24 03:38

 

Hi,

 

Here are some answers for you:

 

----------------------------------------

1. Parsing

If I want to revert the >= sign, without changing the order of the options, I need the < sign. However, if I do this, I get a parsing error. If this is not a Java version compatibility error, I think it needs attention.

----------------------------------------

 

There is no compatibility error.

In XML, when you want to put special characters

like '<', '&' in an element content, you should

wrap them in this sequence, so that the parser

doesn't try to interpret them.

 

Your expression should look like this

(just like for the "queryString"):

 

<variable name="NoRecs" class="java.lang.Integer" resetType="Report" resetGroup="" calculation="Count">

<variableExpression>

<![CDATA[

(($F{Account}==null)?(new Integer(1)):(new Integer(1)))

]]>

</variableExpression>

</variable>

 

 

---------------------------------------------

2. Casting (sorry, it's long)

dori.jasper.engine.JRException: Errors were encountered when compiling report design:

Note: sun.tools.javac.Main has been deprecated.

Report1.java:148: Incompatible type for >. Can't convert java.lang.Double to int.

value = (java.lang.Double)(((((java.lang.Double)field_LateFees.getValue())>(new Double(0.0)))?(new Double(0.0)):(((java.lang.Double)field_LateFees.getValue()))));

^

---------------------------------------------

 

In Java, you can not use >, <, <=, >= operators to compare objects (instances of java.lang.Double for example).

Those operators work only with primitive types.

Use "compareTo()" method instead.

 

 

Good luck!

Teodor

 

 

 

By: Teodor Danciu - teodord

Mailing list

2002-02-24 04:03

 

Hi,

 

You could post messages also on the

JasperReports mailing list.

 

Thanks,

Teodor

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...