How define type in runtime for ReportingEngine


I have next method
public Object getValue(String attribute)
and this method can return different types (String, Long, Double) depending on attribute;
And I use ReportingEngine for word template and inside of template I execute getValue which return Long.
I need find sum of 2 values
<<[content.getValue (“number”) + content.getValue (“number”)]>>
And I have next exception
java.lang.IllegalStateException: An error has been encountered at the end of expression ‘content.getValue (“number”) + content.getValue (“number”)’. Can not apply operator ‘+’ to operands of type ‘class java.lang.Object’ and ‘class java.lang.Object’.
If we change signature for public Long getValue(String attribute) it works correct.
So is it possible return Object but check real type in runtime and if it possible use corresponded function (like + or - or other methods related to long)?



Please also ZIP and attach your simplified template document and runnable Java application (source code without compilation errors) that helps us to reproduce this issue on our end. We will then investigate the issue on our end and provide you more information. (13.4 KB)

I provided 2 templates. One working example and second throws exception. So is it possible to fix second template without changing signature of getValue method?


Thanks for the additional information. We have logged your requirement in our issue tracking system. The ID of your ticket is WORDSNET-17506. We will further look into the details of this problem and will keep you posted on further updates.


We have modified your template document (see (5.4 KB)) to make it work as expected. Please also note that class Long should be made known by the engine before building a report as follows.


For more information, see “Setting up Known External Types” section of documentation. Hope, this helps.

Thanks for your solution. But in my case I don’t know exactly what type will return method. So I can not cast type manually in template. It can be different type denends on parameter of method. Is it possible to define type in runtime?


We have noted these details and will keep you posted on further updates.