Edit C:\galaxie\jobs\MAURY_GUIDE_EXPORT_2023_0.2\MAURY_GUIDE_EXPORT_2019\src\main\java\routines\CustomRSE_.java
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} <type>[(<default value or closed list values>)] <name>[ : <comment>] * * <type> 's value should be one of: string, int, list, double, object, boolean, long, char, date. <name>'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<Integer.parseInt(decimal.substring(0,decPart)) && Integer.parseInt(decimal.substring(0,decPart)) <50 ) || (50<=Integer.parseInt(decimal.substring(0,decPart)) && Integer.parseInt(decimal.substring(0,decPart))<75 ) ){ rse=String.valueOf(Integer.parseInt(integer)+0.5); } else if(75<=Integer.parseInt(decimal.substring(0,decPart))) { rse=String.valueOf(Integer.parseInt(integer)+1); } return rse; } /** * arrondir : arrondi le double passé en paramètre à 0.5 près avec un pas de 0.25. * Si le résultat est supérieur à 10 on le ramène à 10. * * {talendTypes} String * * {Category} CustomRSE_ * * {param} String("sommeRSE") input: la somme des questions du formulaire * * {example} arrondir(9.75) #10 * {example} arrondir(11.32) #10 * {example} arrondir(8.37) #8.5 */ public static String arrondir(Double d) { if (d == null) { return null; } double arrondi = ((double)Math.round(d * 2) / 2) > 10.0 ? 10.0 : ((double)Math.round(d * 2) / 2); if (arrondi % 1 == 0) { return "" + (int)arrondi; } else { return "" + arrondi; } } }
Ms-Dos/Windows
Unix
Write backup
jsp File Browser version 1.2 by
www.vonloesch.de