Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Convert numbers to Persian numbers
muzy
I am new to Birt. I am using Birt 3.7 in eclipse Indigo. I created a plugin for Birt Function to convert numbers to Persian numbers. It works fine only when the data type of the field in the report is set to string. When it is set to Decimal I am getting the actual numbers. I want it to work with the Decimal data type as well. How could I do this. I had shown my plugin code below<br />
<br />
public Object execute( Object[] args, IScriptFunctionContext obj ) throws BirtException<br />
{<br />
if ( args == null || args.length != 1 )<br />
throw new IllegalArgumentException( "The number of arguement is incorrect." );<br />
if( args[0] == null){<br />
return null;<br />
}else{<br />
final String farsi = "\u06f0\u06f1\u06f2\u06f3\u06f4\u06f5\u06f6\u06f7\u06f8\u06f9";<br />
BigDecimal getNumber;<br />
String input;<br />
if (args[0] instanceof BigDecimal)<br />
{<br />
getNumber = (BigDecimal) args[0];<br />
input = getNumber.toString();<br />
}<br />
else<br />
{<br />
input = (String) args[0];<br />
}<br />
System.out.println("Plugin ********** Farsi -> Before Modification "+input);<br />
<br />
char[] chars = new char[input.length()];<br />
for(int i=0;i<input.length();i++)<br />
{<br />
char ch = input.charAt(i);<br />
if(ch >=48 && ch <=57)<br />
{<br />
chars
= farsi.charAt(ch-48);<br />
}<br />
else<br />
{<br />
chars
= ch;<br />
}<br />
<br />
}<br />
String getOutput = new String(chars);<br />
String output = new StringBuffer(getOutput).reverse().toString();<br />
System.out.println("Plugin ********** Farsi -> After Modification "+output);<br />
return (Object) output;<br />
}<br />
}
Find more posts tagged with
Comments
mwilliams
So, you get the unchanged value, if you pass a Decimal? No errors are thrown?
muzy
Yes I am getting the unchanged value when is pass this as decimal. I am reversing the numbers at the end. So I getting the value as reversed. No errors where thrown.
mwilliams
Can you send the plug-in jar, to me, so I can plug it in and try it?