Discussions
Categories
Choose a Product
THRUST SERVICES
CORE APPS
CE PRODUCTS
...
Quick Links
POPULAR
HELPFUL TIPS
Groups
My Links
FOR SIGNED IN MEMBERS:
Back to website
Home
Designing Analytics Reports
Convert numbers to Persian numbers
Migrateduser
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
There are no comments yet