package routines; /* * user specification: the function's comment should contain keys as follows: 1. write about the function's comment.but * it must be before the "{talendTypes}" key. * * 2. {talendTypes} 's value must be talend Type, it is required . its value should be one of: String, char | Character, * long | Long, int | Integer, boolean | Boolean, byte | Byte, Date, double | Double, float | Float, Object, short | * Short * * 3. {Category} define a category for the Function. it is required. its value is user-defined . * * 4. {param} 's format is: {param} [()] [ : ] * * 's value should be one of: string, int, list, double, object, boolean, long, char, date. 's value is the * Function's parameter name. the {param} is optional. so if you the Function without the parameters. the {param} don't * added. you can have many parameters for the Function. * * 5. {example} gives a example for the Function. it is optional. */ public class CustomRSE_ { /** * RoundUp * * * {talendTypes} String * * {Category} User Defined * * {param} * * {example} RoundUp() # !. */ public static String RoundUp(Double sommeRse) { String rse=""; if (sommeRse == null) { return rse; } String dec = String.valueOf(sommeRse); int dot = dec.indexOf("."); String integer = dec.substring(0,dot); String decimal = dec.substring(dot+1); int decimallength = decimal.length(); int decPart = decimallength>2 ? 2 : decimallength; if (Integer.parseInt(integer)>=10) rse="10"; else if (Integer.parseInt(decimal.substring(0,decPart))==5) rse=String.valueOf(Integer.parseInt(integer)+0.5); else if(0<=Integer.parseInt(decimal.substring(0,decPart)) && Integer.parseInt(decimal.substring(0,decPart))<25) { rse=String.valueOf(Integer.parseInt(integer)); } else if((25 10.0 ? 10.0 : ((double)Math.round(d * 2) / 2); if (arrondi % 1 == 0) { return "" + (int)arrondi; } else { return "" + arrondi; } } }