Create a String with a single char with dynamic range

i am making a report using JasperReports, which is connecting to a database table that has an integer field "LEVEL". This level will store some numbers... 1, 2, 3, and going on. In the report, i want to create a string with this numbers of underlines, which means if the level is 4 the generated string would be "__". I know i can do it with in java something like this:

int i = 3;
char[] vect = new char[i];
Arrays.fill(vect, '_');

But in JasperReports i can not call commands, i could if the Arrays.fill would return the array itself instead of void. Is there another way?


you could use a for loop to append a string. Im not sure if I know exactly what you mean but maybe something like this

int i = 3;
String s;
for(int k = 0; k < i; i++){
    s = s + "_";

not tested, but looks ok

If number of LEVEL is not much higher number, then you could conditionally write it with if else as shown below:

                       $F{level}.equals("3")?"___":____  <---- last one is 4

It goes on...

It won't be a good solution but you can't have another option in jasper for such operation. :)

Need Your Help

Firefox addon expose chrome function to website

javascript save firefox-addon

I would like to ask you how can I expose function to webpage content using addon.

IndexedDBShim.js error : JavaScript runtime error: Assignment to read-only properties is not allowed in strict mode

javascript jquery indexeddb shim

I am experimenting with IndexedDB jquery API as indexedDB isnt compatible with safari / ipad. Ive just started using it and got this error when only running HTML and im not able to use anything in ...