Edit C:\galaxie\jobs\GALAXIE__JOBs\backup\GALAXIE__PCKG\src\main\java\routines\Utils.java
package routines; import java.awt.AlphaComposite; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Image; import java.awt.RenderingHints; import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.ObjectOutputStream; import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; import java.util.Enumeration; import java.util.HashSet; import java.util.Hashtable; import java.util.Iterator; import java.util.LinkedList; import java.util.Map; import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.text.DateFormat; import java.text.DecimalFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import javax.imageio.ImageIO; import javax.imageio.ImageReadParam; import javax.imageio.ImageReader; import javax.imageio.stream.ImageInputStream; import com.sun.org.apache.xerces.internal.impl.dv.util.Base64; import sun.misc.BASE64Encoder; import sun.misc.BASE64Decoder; //import org.apache.commons.lang3.StringUtils; /* * 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 Utils { public static int compteurBase = 0; public static int compteurContrat = 0; public static int compteurCmdCheque = 0; public static int compteurOppNumRef = 0; public static int compteurOppNumCommFil = 0; public static int compteurOppNumFactFil = 0; public static int compteurGl = 0; public static String idFctGuest = ""; public static String MailNotification = ""; public static String MailSender = ""; public static String MailSmtp = ""; public static String MillesimeGuide = ""; private static final Pattern REMOVE_TAGS = Pattern.compile("<.+?>"); private static final int IMG_WIDTH = 100; private static final int IMG_HEIGHT = 81; private static Map<String,String> html_specialchars_table = new Hashtable<String,String>(); static { //html_specialchars_table.put("<","<"); //html_specialchars_table.put(">",">"); html_specialchars_table.put("&","&"); } public static String getId(long basCounter) { String dbString = "0000FF"; String tmpString = (new StringBuilder("0000000000")).append( Long.toHexString(basCounter)).toString(); String regString = tmpString.substring(tmpString.length() - 10, tmpString.length()); return (new StringBuilder(String.valueOf(dbString))).append(regString) .toString(); } public static String MauryGetPriceOfSoireeEtap(String TypePres, String PrixMin, String PrixMax, String SoireEtap) { String str_price = ""; String unite = ""; Double price_min = 0.0; Double price_max = 0.0; DecimalFormat format = new DecimalFormat("0.##"); if(TypePres != null && TypePres.indexOf(";") != -1){ String[] ArrayPres = TypePres.split(";"); String[] ArrayPrixMin = PrixMin.split(";"); String[] ArrayPrixMax = PrixMax.split(";"); int taille_p = ArrayPres.length; for(int i= 0; i < taille_p ; i++){ unite = ArrayPres[i]; ArrayPrixMax[i] = ArrayPrixMax[i].replace("null", ""); ArrayPrixMin[i] = ArrayPrixMin[i].replace("null", ""); if(unite.equals("SET")){ if(ArrayPrixMin[i].equals("") && ArrayPrixMax[i].equals("")){ str_price = str_price + ""; }else if(ArrayPrixMin[i].equals("0") && ArrayPrixMax[i].equals("0")){ str_price = str_price + ""; }else if(ArrayPrixMax[i].equals("") || ArrayPrixMax[i].equals("0")){ try { price_min = Double.parseDouble(ArrayPrixMin[i]); } catch(NumberFormatException e) { } str_price = str_price + SoireEtap+format.format(Math.round(price_min)); }else{ try { price_min = Double.parseDouble(ArrayPrixMin[i]); } catch(NumberFormatException e) { } try { price_max = Double.parseDouble(ArrayPrixMax[i]); } catch(NumberFormatException e) { } if(format.format(price_min).equals(format.format(price_max))){ str_price = str_price +SoireEtap+format.format(Math.round(price_min)); }else{ str_price = str_price +SoireEtap+format.format(Math.round(price_min))+"/"+format.format(Math.round(price_max)); } } } } }else if(TypePres != null && !TypePres.isEmpty()){ unite = TypePres; PrixMin = PrixMin.replace("null", ""); PrixMax = PrixMax.replace("null", ""); if(unite.equals("SET")){ if(PrixMin.equals("") && PrixMax.equals("")){ str_price = str_price + ""; }else if(PrixMin.equals("0") && PrixMax.equals("0")){ str_price = str_price + ""; }else if(PrixMax.equals("") || PrixMax.equals("0")){ try { price_min = Double.parseDouble(PrixMin); } catch(NumberFormatException e) { } str_price = str_price +SoireEtap+format.format(Math.round(price_min)); }else{ try { price_min = Double.parseDouble(PrixMin); } catch(NumberFormatException e) { } try { price_max = Double.parseDouble(PrixMax); } catch(NumberFormatException e) { } if(format.format(price_min).equals(format.format(price_max))){ str_price = str_price +SoireEtap+format.format(Math.round(price_min)); }else{ str_price = str_price +SoireEtap+format.format(Math.round(price_min))+"/"+format.format(Math.round(price_max)); } } } } return str_price; } public static String MauryGetPriceOfPrestation(String TypePres, String PrixMin, String PrixMax, String PtitDej) { String str_price = ""; String unite = ""; Double price_min = 0.0; Double price_max = 0.0; DecimalFormat format = new DecimalFormat("0.##"); if(TypePres != null && TypePres.indexOf(";") != -1){ String[] ArrayPres = TypePres.split(";"); String[] ArrayPrixMin = PrixMin.split(";"); String[] ArrayPrixMax = PrixMax.split(";"); int taille_p = ArrayPres.length; for(int i= 0; i < taille_p ; i++){ unite = ArrayPres[i]; ArrayPrixMax[i] = ArrayPrixMax[i].replace("null", ""); ArrayPrixMin[i] = ArrayPrixMin[i].replace("null", ""); if(unite.equals("CHB")){ if(ArrayPrixMin[i].equals("") && ArrayPrixMax[i].equals("")){ str_price = str_price + ""; }else if(ArrayPrixMin[i].equals("0") && ArrayPrixMax[i].equals("0")){ str_price = str_price + ""; }else if(ArrayPrixMax[i].equals("") || ArrayPrixMax[i].equals("0")){ try { price_min = Double.parseDouble(ArrayPrixMin[i]); } catch(NumberFormatException e) { } str_price = str_price+PtitDej+format.format(Math.round(price_min)); }else{ try { price_min = Double.parseDouble(ArrayPrixMin[i]); } catch(NumberFormatException e) { } try { price_max = Double.parseDouble(ArrayPrixMax[i]); } catch(NumberFormatException e) { } if(format.format(price_min).equals(format.format(price_max))){ str_price = str_price+PtitDej+format.format(Math.round(price_min)); }else{ str_price = str_price+PtitDej+format.format(Math.round(price_min))+"/"+format.format(Math.round(price_max)); } } }else if(unite.equals("PDJ")){ if(ArrayPrixMin[i].equals("") && ArrayPrixMax[i].equals("")){ str_price = str_price + ""; }else if(ArrayPrixMin[i].equals("0") && ArrayPrixMax[i].equals("0")){ str_price = str_price + ""; }else if(ArrayPrixMax[i].equals("") || ArrayPrixMax[i].equals("0")){ try { price_min = Double.parseDouble(ArrayPrixMin[i]); } catch(NumberFormatException e) { } str_price = str_price + "@34"+format.format(price_min); }else{ try { price_min = Double.parseDouble(ArrayPrixMin[i]); } catch(NumberFormatException e) { } try { price_max = Double.parseDouble(ArrayPrixMax[i]); } catch(NumberFormatException e) { } if(format.format(price_min).equals(format.format(price_max))){ str_price = str_price + "@34"+format.format(price_min); }else{ str_price = str_price + "@34"+format.format(price_min)+"/"+format.format(price_max); } } }else if(unite.equals("MNU")){ if(ArrayPrixMin[i].equals("") && ArrayPrixMax[i].equals("")){ str_price = str_price + ""; }else if(ArrayPrixMin[i].equals("0") && ArrayPrixMax[i].equals("0")){ str_price = str_price + ""; }else if(ArrayPrixMax[i].equals("") || ArrayPrixMax[i].equals("0")){ try { price_min = Double.parseDouble(ArrayPrixMin[i]); } catch(NumberFormatException e) { } str_price = str_price + "@35"+format.format(Math.round(price_min)); }else{ try { price_min = Double.parseDouble(ArrayPrixMin[i]); } catch(NumberFormatException e) { } try { price_max = Double.parseDouble(ArrayPrixMax[i]); } catch(NumberFormatException e) { } if(format.format(price_min).equals(format.format(price_max))){ str_price = str_price + "@35"+format.format(Math.round(price_min)); }else{ str_price = str_price + "@35"+format.format(Math.round(price_min))+"/"+format.format(Math.round(price_max)); } } }else if(unite.equals("DPS")){ if(ArrayPrixMin[i].equals("") && ArrayPrixMax[i].equals("")){ str_price = str_price + ""; }else if(ArrayPrixMin[i].equals("0") && ArrayPrixMax[i].equals("0")){ str_price = str_price + ""; }else if(ArrayPrixMax[i].equals("") || ArrayPrixMax[i].equals("0")){ try { price_min = Double.parseDouble(ArrayPrixMin[i]); } catch(NumberFormatException e) { } str_price = str_price + "@36"+format.format(Math.round(price_min)); }else{ try { price_min = Double.parseDouble(ArrayPrixMin[i]); } catch(NumberFormatException e) { } try { price_max = Double.parseDouble(ArrayPrixMax[i]); } catch(NumberFormatException e) { } if(format.format(price_min).equals(format.format(price_max))){ str_price = str_price + "@36"+format.format(Math.round(price_min)); }else{ str_price = str_price + "@36"+format.format(Math.round(price_min))+"/"+format.format(Math.round(price_max)); } } }else if(unite.equals("FEN")){ if(ArrayPrixMin[i].equals("") && ArrayPrixMax[i].equals("")){ str_price = str_price + ""; }else if(ArrayPrixMin[i].equals("0") && ArrayPrixMax[i].equals("0")){ str_price = str_price + ""; }else if(ArrayPrixMax[i].equals("") || ArrayPrixMax[i].equals("0")){ try { price_min = Double.parseDouble(ArrayPrixMin[i]); } catch(NumberFormatException e) { } str_price = str_price + "@37"+format.format(Math.round(price_min)); }else{ try { price_min = Double.parseDouble(ArrayPrixMin[i]); } catch(NumberFormatException e) { } try { price_max = Double.parseDouble(ArrayPrixMax[i]); } catch(NumberFormatException e) { } if(format.format(price_min).equals(format.format(price_max))){ str_price = str_price + "@37"+format.format(Math.round(price_min)); }else{ str_price = str_price + "@37"+format.format(Math.round(price_min))+"/"+format.format(Math.round(price_max)); } } } } }else if(TypePres != null && !TypePres.isEmpty()){ unite = TypePres; PrixMin = PrixMin.replace("null", ""); PrixMax = PrixMax.replace("null", ""); if(unite.equals("CHB")){ if(PrixMin.equals("") && PrixMax.equals("")){ str_price = str_price + ""; }else if(PrixMin.equals("0") && PrixMax.equals("0")){ str_price = str_price + ""; }else if(PrixMax.equals("") || PrixMax.equals("0")){ try { price_min = Double.parseDouble(PrixMin); } catch(NumberFormatException e) { } str_price = str_price+PtitDej+format.format(Math.round(price_min)); }else{ try { price_min = Double.parseDouble(PrixMin); } catch(NumberFormatException e) { } try { price_max = Double.parseDouble(PrixMax); } catch(NumberFormatException e) { } if(format.format(price_min).equals(format.format(price_max))){ str_price = str_price+PtitDej+format.format(Math.round(price_min)); }else{ str_price = str_price+PtitDej+format.format(Math.round(price_min))+"/"+format.format(Math.round(price_max)); } } }else if(unite.equals("PDJ")){ if(PrixMin.equals("") && PrixMax.equals("")){ str_price = str_price + ""; }else if(PrixMin.equals("0") && PrixMax.equals("0")){ str_price = str_price + ""; }else if(PrixMax.equals("") || PrixMax.equals("0")){ try { price_min = Double.parseDouble(PrixMin); } catch(NumberFormatException e) { } str_price = str_price + "@34"+format.format(price_min); }else{ try { price_min = Double.parseDouble(PrixMin); } catch(NumberFormatException e) { } try { price_max = Double.parseDouble(PrixMax); } catch(NumberFormatException e) { } if(format.format(price_min).equals(format.format(price_max))){ str_price = str_price + "@34"+format.format(price_min); }else{ str_price = str_price + "@34"+format.format(price_min)+"/"+format.format(price_max); } } }else if(unite.equals("MNU")){ if(PrixMin.equals("") && PrixMax.equals("")){ str_price = str_price + ""; }else if(PrixMin.equals("0") && PrixMax.equals("0")){ str_price = str_price + ""; }else if(PrixMax.equals("") || PrixMax.equals("0")){ try { price_min = Double.parseDouble(PrixMin); } catch(NumberFormatException e) { } str_price = str_price + "@35"+format.format(Math.round(price_min)); }else{ try { price_min = Double.parseDouble(PrixMin); } catch(NumberFormatException e) { } try { price_max = Double.parseDouble(PrixMax); } catch(NumberFormatException e) { } if(format.format(price_min).equals(format.format(price_max))){ str_price = str_price + "@35"+format.format(Math.round(price_min)); }else{ str_price = str_price + "@35"+format.format(Math.round(price_min))+"/"+format.format(Math.round(price_max)); } } }else if(unite.equals("DPS")){ if(PrixMin.equals("") && PrixMax.equals("")){ str_price = str_price + ""; }else if(PrixMin.equals("0") && PrixMax.equals("0")){ str_price = str_price + ""; }else if(PrixMax.equals("") || PrixMax.equals("0")){ try { price_min = Double.parseDouble(PrixMin); } catch(NumberFormatException e) { } str_price = str_price + "@36"+format.format(Math.round(price_min)); }else{ try { price_min = Double.parseDouble(PrixMin); } catch(NumberFormatException e) { } try { price_max = Double.parseDouble(PrixMax); } catch(NumberFormatException e) { } if(format.format(price_min).equals(format.format(price_max))){ str_price = str_price + "@36"+format.format(Math.round(price_min)); }else{ str_price = str_price + "@36"+format.format(Math.round(price_min))+"/"+format.format(Math.round(price_max)); } } }else if(unite.equals("FEN")){ if(PrixMin.equals("") && PrixMax.equals("")){ str_price = str_price + ""; }else if(PrixMin.equals("0") && PrixMax.equals("0")){ str_price = str_price + ""; }else if(PrixMax.equals("") || PrixMax.equals("0")){ try { price_min = Double.parseDouble(PrixMin); } catch(NumberFormatException e) { } str_price = str_price + "@37"+format.format(Math.round(price_min)); }else{ try { price_min = Double.parseDouble(PrixMin); } catch(NumberFormatException e) { } try { price_max = Double.parseDouble(PrixMax); } catch(NumberFormatException e) { } if(format.format(price_min).equals(format.format(price_max))){ str_price = str_price + "@37"+format.format(Math.round(price_min)); }else{ str_price = str_price + "@37"+format.format(Math.round(price_min))+"/"+format.format(Math.round(price_max)); } } } } return str_price; } public static String MauryGetEquipements(String CodeEquipements,String TypePres, String PrixMin, String PrixMax) { String str_eq = ""; Set<String> linkedlist = new HashSet<String>(); if(CodeEquipements != null && !CodeEquipements.isEmpty()){ boolean exit_spa = false; boolean exit_wifi_internet = false; String soireEtape = ""; if(CodeEquipements.indexOf("@78") == -1){ soireEtape = MauryGetPriceOfSoireeEtap(TypePres, PrixMin, PrixMax, "@60"); CodeEquipements = CodeEquipements.replace("@60@61", soireEtape); }else{ soireEtape = MauryGetPriceOfSoireeEtap(TypePres, PrixMin, PrixMax, "@61"); CodeEquipements = CodeEquipements.replace("@60@61", soireEtape); } if(CodeEquipements.indexOf("@553") != -1){ exit_spa = true; CodeEquipements = CodeEquipements.replace("@551", ""); CodeEquipements = CodeEquipements.replace("@552", ""); } if(CodeEquipements.indexOf("@46") != -1 && CodeEquipements.indexOf("@59") != -1){ exit_wifi_internet = true; CodeEquipements = CodeEquipements.replace("@59", ""); } String unite = ""; String[] ArrayEq = CodeEquipements.split(";"); int taille_eq = ArrayEq.length; for(int i= 0; i < taille_eq ; i++){ unite = ArrayEq[i]; if(unite != null && !unite.equals("null") && !unite.equals("")){ if(linkedlist.add(unite)){ str_eq += unite; } } } } return str_eq; } public static String MauryGetOtherLabels(final String CodeOtherLabels) { String str_ol = ""; final Set<String> linkedlist = new HashSet<String>(); if (CodeOtherLabels != null && !CodeOtherLabels.isEmpty()) { String unite = ""; final String[] ArrayOl = CodeOtherLabels.split(";"); for (int taille_eq = ArrayOl.length, i = 0; i < taille_eq; ++i) { unite = ArrayOl[i]; if (unite != null && !unite.equals("null") && !unite.equals("") && linkedlist.add(unite)) { str_ol = String.valueOf(str_ol) + unite; } } } return str_ol; } public static String MauryGetEnvies(String CodeEnvies) { String str_ev = ""; Set<String> linkedlist = new HashSet<String>(); if(CodeEnvies != null && !CodeEnvies.isEmpty()){ String unite = ""; String[] ArrayEq = CodeEnvies.split(";"); int taille_eq = ArrayEq.length; for(int i= 0; i < taille_eq ; i++){ unite = ArrayEq[i]; if(unite != null && !unite.equals("null") && !unite.equals("") && !unite.equals("0")){ if(linkedlist.add(unite)){ str_ev += unite; } } } } return str_ev; } public static String removeTags(String string) { if (string == null || string.length() == 0) { return string; } //System.out.println(string); //Matcher m = REMOVE_TAGS.matcher(string); //String txt = m.replaceAll(""); String txt = string.replaceAll("<br>", "\r\n"); //System.out.println(txt); String[] out = txt.split("\n"); String allLine = ""; for( String line : out ) { line = line.trim(); if (!line.equals("") && !line.contains("<del>")) { line = htmlspecialchars_decode_ENT_NOQUOTES(line); if(allLine.equals("")){ allLine = line; }else{ allLine = allLine + "\r\n" + line; } } } return allLine; } public static String removeExt(String string) { if (string == null || string.length() == 0) { return string; } if(string.lastIndexOf('.') == -1){ return string; } string = string.substring(0, string.lastIndexOf('.')); string = string.replace("_N", ""); return string; } public static String ReplaceNullByEmpty(String string) { return string != null && !string.equals("null") ? string : ""; } public static Integer getCompteurGl() { Utils.compteurGl++; return Utils.compteurGl; } /** * getIdEdeal: génére l'ID Edeal en 16 Caractères. * * * {talendTypes} String * * {Category} User Defined * * {example} getIdEdeal() # incrèmente le compteurBase et retourne l'ID * Edeal */ public static String getIdEdeal() { Utils.compteurBase++; return getId(Utils.compteurBase); } /** * getCodeContrat : génére un code contrat. * * * {talendTypes} int * * {Category} User Defined * * {example} getIdEdeal() # incrèmente le compteurContrat et retourne le code contrat * */ public static int getCodeContrat() { return Utils.compteurContrat++; } /** * getNumeroCommande : génére un numéro de commande opportunity. * * * {talendTypes} int * * {Category} User Defined * * {example} getIdEdeal() # incrèmente le compteurOppNumCommFil et retourne le numéro de commande * */ public static int getNumeroOppNumComm() { return Utils.compteurOppNumCommFil++; } public static int getNumeroOppNumFactFil() { return Utils.compteurOppNumFactFil++; } /** * getNumeroCommande : génére un numéro de référence opportunity. * * * {talendTypes} int * * {Category} User Defined * * {example} getIdEdeal() # incrèmente le compteurOppNumRef et retourne le numéro de référence * */ public static int getNumeroOppNumRef() { return Utils.compteurOppNumRef++; } /** * getNumeroCommande : génére un numéro de commande chèque. * * * {talendTypes} int * * {Category} User Defined * * {example} getIdEdeal() # incrèmente le compteurCmdCheque et retourne le numéro de commande * */ public static int getNumeroCommande() { return Utils.compteurCmdCheque++; } /** * getPhotoName: to extract the name of the picture from the url * * * {talendTypes} String * * {Category} User Defined * * {example} getPhotoName("x/y/z") # return getPhotoName("x/y/z")[0]="x" * getPhotoName("x/y/z")[1]="y" getPhotoName("x/y/z")[2]="z" */ public static String getPhotoName(String url) { String[] Tableau_parties_url = {}; Tableau_parties_url = url.split("\\\\"); return Tableau_parties_url[Tableau_parties_url.length - 1]; } public static boolean isLong(String s) { try { Long.parseLong(s); } catch(NumberFormatException e) { return false; } return true; } public static boolean isInteger(String s) { try { Integer.parseInt(s); } catch(NumberFormatException e) { return false; } return true; } public static boolean isDouble(String s) { try { Double.parseDouble(s); } catch(NumberFormatException e) { return false; } return true; } public static boolean isFloat(String s) { try { Float.parseFloat(s); } catch(NumberFormatException e) { return false; } return true; } /** * getEntCle : to extract the id of an enterprise from the name of its * picture * * {talendTypes} String * * {Category} User Defined * * {example} getEntCle("123_N.png") return "123" */ public static String getEntCle(String photoName) { String[] tableauPartiePhoto = photoName.split("_"); return tableauPartiePhoto[0]; } public static byte[] byteArrayFromFile(String filepath) { try { byte[] incoming_file_data = Files.readAllBytes(Paths.get(filepath)); return incoming_file_data; } catch (Exception err) { err.printStackTrace(); return null; } } /** * get stream from file * {talendTypes} Object * * {Category} User Defined */ public static Object getByteArrayFromFile(String filepath) { try { File file = new File(filepath); FileInputStream fis = new FileInputStream(file); int fileLength = (int) file.length(); byte[] incoming_file_data = new byte[fileLength]; // allocate byte array of right size fis.read(incoming_file_data, 0, fileLength ); // read into byte array fis.close(); return incoming_file_data; } catch(Exception err) { err.printStackTrace(); return null; } } /** * diviser_adresse: répartie l'adresse en numVoie, natVoie et libVoie * * * {talendTypes} String * * {Category} User Defined * * {example} diviser_adresse("27, Bd Lhotelier")[0,1,2] # Répartie l'adresse * en diviser_adresse("27, Bd Lhotelier")[0]==27 (numVoie), * diviser_adresse("27, Bd Lhotelier")[1]=="BD" (natVoie) et * diviser_adresse("27, Bd Lhotelier")[2]=="Lhotelier" (libVoie) */ public static String[] diviser_adresse(String adresse) { /*if (!StringUtils.isNotEmpty(adresse)) { adresse = ""; }*/ if(adresse == null || adresse.equals("")){ adresse = ""; } adresse = adresse.trim(); String[] tableau_parties_adresse = { "", "", adresse }; String[] diviser_adresse_virgule; String[] diviser_adresse_espace; diviser_adresse_virgule = adresse.split(","); for (int i = 0; i < diviser_adresse_virgule.length; i++) { if (isInt(diviser_adresse_virgule[i])) { tableau_parties_adresse[0] = diviser_adresse_virgule[i]; String finAdresse = ""; while ((i = i + 1) < diviser_adresse_virgule.length) { finAdresse = finAdresse + diviser_adresse_virgule[i]; } diviser_adresse_espace = finAdresse.split(" "); for (int j = 0; j < diviser_adresse_espace.length; j++) { if (diviser_adresse_espace[j].equalsIgnoreCase("Allée")) { tableau_parties_adresse[1] = "AL"; String finAdresseLbl = ""; while ((j = j + 1) < diviser_adresse_espace.length) { finAdresseLbl = finAdresseLbl + diviser_adresse_espace[j] + " "; tableau_parties_adresse[2] = finAdresseLbl.trim(); } } else if (diviser_adresse_espace[j] .equalsIgnoreCase("Av.")) { tableau_parties_adresse[1] = "AV"; String finAdresseLbl = ""; while ((j = j + 1) < diviser_adresse_espace.length) { finAdresseLbl = finAdresseLbl + diviser_adresse_espace[j] + " "; tableau_parties_adresse[2] = finAdresseLbl.trim(); } } else if (diviser_adresse_espace[j] .equalsIgnoreCase("Avenue")) { tableau_parties_adresse[1] = "AV"; String finAdresseLbl = ""; while ((j = j + 1) < diviser_adresse_espace.length) { finAdresseLbl = finAdresseLbl + diviser_adresse_espace[j] + " "; tableau_parties_adresse[2] = finAdresseLbl.trim(); } } else if (diviser_adresse_espace[j] .equalsIgnoreCase("Bd.")) { tableau_parties_adresse[1] = "BD"; String finAdresseLbl = ""; while ((j = j + 1) < diviser_adresse_espace.length) { finAdresseLbl = finAdresseLbl + diviser_adresse_espace[j] + " "; tableau_parties_adresse[2] = finAdresseLbl.trim(); } } else if (diviser_adresse_espace[j] .equalsIgnoreCase("Bd")) { tableau_parties_adresse[1] = "BD"; String finAdresseLbl = ""; while ((j = j + 1) < diviser_adresse_espace.length) { finAdresseLbl = finAdresseLbl + diviser_adresse_espace[j] + " "; tableau_parties_adresse[2] = finAdresseLbl.trim(); } } else if (diviser_adresse_espace[j] .equalsIgnoreCase("Bld")) { tableau_parties_adresse[1] = "BD"; String finAdresseLbl = ""; while ((j = j + 1) < diviser_adresse_espace.length) { finAdresseLbl = finAdresseLbl + diviser_adresse_espace[j] + " "; tableau_parties_adresse[2] = finAdresseLbl.trim(); } } else if (diviser_adresse_espace[j] .equalsIgnoreCase("Chemin")) { tableau_parties_adresse[1] = "CH"; String finAdresseLbl = ""; while ((j = j + 1) < diviser_adresse_espace.length) { finAdresseLbl = finAdresseLbl + diviser_adresse_espace[j] + " "; tableau_parties_adresse[2] = finAdresseLbl.trim(); } } else if (diviser_adresse_espace[j] .equalsIgnoreCase("Imp.")) { tableau_parties_adresse[1] = "IP"; String finAdresseLbl = ""; while ((j = j + 1) < diviser_adresse_espace.length) { finAdresseLbl = finAdresseLbl + diviser_adresse_espace[j] + " "; tableau_parties_adresse[2] = finAdresseLbl.trim(); } } else if (diviser_adresse_espace[j] .equalsIgnoreCase("Lieu-dit")) { tableau_parties_adresse[1] = "LD"; String finAdresseLbl = ""; while ((j = j + 1) < diviser_adresse_espace.length) { finAdresseLbl = finAdresseLbl + diviser_adresse_espace[j] + " "; tableau_parties_adresse[2] = finAdresseLbl.trim(); } } else if (diviser_adresse_espace[j] .equalsIgnoreCase("Passage")) { tableau_parties_adresse[1] = "PA"; String finAdresseLbl = ""; while ((j = j + 1) < diviser_adresse_espace.length) { finAdresseLbl = finAdresseLbl + diviser_adresse_espace[j] + " "; tableau_parties_adresse[2] = finAdresseLbl.trim(); } } else if (diviser_adresse_espace[j] .equalsIgnoreCase("Route")) { tableau_parties_adresse[1] = "RO"; String finAdresseLbl = ""; while ((j = j + 1) < diviser_adresse_espace.length) { finAdresseLbl = finAdresseLbl + diviser_adresse_espace[j] + " "; tableau_parties_adresse[2] = finAdresseLbl.trim(); } } else if (diviser_adresse_espace[j] .equalsIgnoreCase("Rue")) { tableau_parties_adresse[1] = "RU"; String finAdresseLbl = ""; while ((j = j + 1) < diviser_adresse_espace.length) { finAdresseLbl = finAdresseLbl + diviser_adresse_espace[j] + " "; tableau_parties_adresse[2] = finAdresseLbl.trim(); } } else if (diviser_adresse_espace[j] .equalsIgnoreCase("Place")) { tableau_parties_adresse[1] = "PL"; String finAdresseLbl = ""; while ((j = j + 1) < diviser_adresse_espace.length) { finAdresseLbl = finAdresseLbl + diviser_adresse_espace[j] + " "; tableau_parties_adresse[2] = finAdresseLbl.trim(); } } else { tableau_parties_adresse[2] = finAdresse.trim(); } } } // /************Partie du code ignorée, permet de détecter le // numVoie et la natVoie même s'il n y a pas de virgule *********/ else { diviser_adresse_espace = adresse.split(" "); if (isInt(diviser_adresse_espace[0])) { if(diviser_adresse_espace.length > i){ tableau_parties_adresse[0] = diviser_adresse_espace[i]; if (diviser_adresse_espace[1].equalsIgnoreCase("Allée")) { tableau_parties_adresse[1] = "AL"; String finAdresseLbl = ""; int k = 1; while ((k = k + 1) < diviser_adresse_espace.length) { finAdresseLbl = finAdresseLbl + diviser_adresse_espace[k] + " "; tableau_parties_adresse[2] = finAdresseLbl .trim(); } } else if (diviser_adresse_espace[1] .equalsIgnoreCase("Av.")) { tableau_parties_adresse[1] = "AV"; String finAdresseLbl = ""; int k = 1; while ((k = k + 1) < diviser_adresse_espace.length) { finAdresseLbl = finAdresseLbl + diviser_adresse_espace[k] + " "; tableau_parties_adresse[2] = finAdresseLbl .trim(); } } else if (diviser_adresse_espace[1] .equalsIgnoreCase("Avenue")) { tableau_parties_adresse[1] = "AV"; String finAdresseLbl = ""; int k = 1; while ((k = k + 1) < diviser_adresse_espace.length) { finAdresseLbl = finAdresseLbl + diviser_adresse_espace[k] + " "; tableau_parties_adresse[2] = finAdresseLbl .trim(); } } else if (diviser_adresse_espace[1] .equalsIgnoreCase("Bd.")) { tableau_parties_adresse[1] = "BD"; String finAdresseLbl = ""; int k = 1; while ((k = k + 1) < diviser_adresse_espace.length) { finAdresseLbl = finAdresseLbl + diviser_adresse_espace[k] + " "; tableau_parties_adresse[2] = finAdresseLbl .trim(); } } else if (diviser_adresse_espace[1] .equalsIgnoreCase("Bld")) { tableau_parties_adresse[1] = "BD"; String finAdresseLbl = ""; int k = 1; while ((k = k + 1) < diviser_adresse_espace.length) { finAdresseLbl = finAdresseLbl + diviser_adresse_espace[k] + " "; tableau_parties_adresse[2] = finAdresseLbl .trim(); } } else if (diviser_adresse_espace[1] .equalsIgnoreCase("Bd")) { tableau_parties_adresse[1] = "BD"; String finAdresseLbl = ""; int k = 1; while ((k = k + 1) < diviser_adresse_espace.length) { finAdresseLbl = finAdresseLbl + diviser_adresse_espace[k] + " "; tableau_parties_adresse[2] = finAdresseLbl .trim(); } } else if (diviser_adresse_espace[1] .equalsIgnoreCase("Chemin")) { tableau_parties_adresse[1] = "CH"; String finAdresseLbl = ""; int k = 1; while ((k = k + 1) < diviser_adresse_espace.length) { finAdresseLbl = finAdresseLbl + diviser_adresse_espace[k] + " "; tableau_parties_adresse[2] = finAdresseLbl .trim(); } } else if (diviser_adresse_espace[1] .equalsIgnoreCase("Imp.")) { tableau_parties_adresse[1] = "IP"; String finAdresseLbl = ""; int k = 1; while ((k = k + 1) < diviser_adresse_espace.length) { finAdresseLbl = finAdresseLbl + diviser_adresse_espace[k] + " "; tableau_parties_adresse[2] = finAdresseLbl .trim(); } } else if (diviser_adresse_espace[1] .equalsIgnoreCase("Lieu-dit")) { tableau_parties_adresse[1] = "LD"; String finAdresseLbl = ""; int k = 1; while ((k = k + 1) < diviser_adresse_espace.length) { finAdresseLbl = finAdresseLbl + diviser_adresse_espace[k] + " "; tableau_parties_adresse[2] = finAdresseLbl .trim(); } } else if (diviser_adresse_espace[1] .equalsIgnoreCase("Passage")) { tableau_parties_adresse[1] = "PA"; String finAdresseLbl = ""; int k = 1; while ((k = k + 1) < diviser_adresse_espace.length) { finAdresseLbl = finAdresseLbl + diviser_adresse_espace[k] + " "; tableau_parties_adresse[2] = finAdresseLbl .trim(); } } else if (diviser_adresse_espace[1] .equalsIgnoreCase("Route")) { tableau_parties_adresse[1] = "RO"; String finAdresseLbl = ""; int k = 1; while ((k = k + 1) < diviser_adresse_espace.length) { finAdresseLbl = finAdresseLbl + diviser_adresse_espace[k] + " "; tableau_parties_adresse[2] = finAdresseLbl .trim(); } } else if (diviser_adresse_espace[1] .equalsIgnoreCase("Rue")) { tableau_parties_adresse[1] = "RU"; String finAdresseLbl = ""; int k = 1; while ((k = k + 1) < diviser_adresse_espace.length) { finAdresseLbl = finAdresseLbl + diviser_adresse_espace[k] + " "; tableau_parties_adresse[2] = finAdresseLbl .trim(); } } else if (diviser_adresse_espace[1] .equalsIgnoreCase("Place")) { tableau_parties_adresse[1] = "PL"; String finAdresseLbl = ""; int k = 1; while ((k = k + 1) < diviser_adresse_espace.length) { finAdresseLbl = finAdresseLbl + diviser_adresse_espace[k] + " "; tableau_parties_adresse[2] = finAdresseLbl .trim(); } } else { int l = 0; String finAdresse = ""; while ((l = l + 1) < diviser_adresse_espace.length) { finAdresse = finAdresse + diviser_adresse_espace[l] + " "; tableau_parties_adresse[2] = finAdresse .trim(); } } } } } // /******************************************************************************************************************* } return tableau_parties_adresse; } /** * isInt: Teste si un String est un Int ou non * * * {talendTypes} boolean * * {Category} User Defined * * {example} isInt("27") #retourne true isInt("2s54") retourne false */ public static boolean isInt(String chaine) { boolean valeur = true; char[] tab = chaine.toCharArray(); for (char carac : tab) { if (!Character.isDigit(carac) && valeur) { valeur = false; } } return valeur; } // /*******************************************************************************************************************/// public static String StringToDouble(String chaine) { if(chaine.indexOf(",") == -1){ return chaine; } return chaine.replaceAll(",", "."); } public static Integer StringToInt(String chaine) { try { Integer.parseInt(chaine); } catch(NumberFormatException e) { return null; } return Integer.parseInt(chaine); } public static String getEntCleAvis(String SiteCode) { if(SiteCode == null || SiteCode.isEmpty()) return null; if(SiteCode != null && SiteCode.indexOf("_") == -1){ return SiteCode; } String[] tableauPartie = SiteCode.split("_"); if(tableauPartie.length == 1){ return SiteCode; } return tableauPartie[1]; } public static int getIndexOfItemInArray(String[] stringArray, String name) { if (stringArray != null && stringArray.length > 0) { ArrayList<String> list = new ArrayList<String>(Arrays.asList(stringArray)); int index = list.indexOf(name); list.clear(); return index; } return -1; } public static Double getPriceHTOfOpp(String src_ens, String AllProduct, String AllPrice) { String[] ArrayEns = src_ens.split(";"); String[] ArrayProduct = AllProduct.split(";"); String[] ArrayPrice = AllPrice.split(";"); Double PriceHt = 0.0; for(int i=0;i<ArrayEns.length;i++){ int qt = Integer.valueOf(ArrayEns[i]); int indexOfProd = -1; switch(i){ case 0: indexOfProd = getIndexOfItemInArray(ArrayProduct, "LFCCLDF"); if(indexOfProd != -1){ Double PrixU = Double.valueOf(ArrayPrice[indexOfProd]); PriceHt = PriceHt + (qt * PrixU); } break; case 1: indexOfProd = getIndexOfItemInArray(ArrayProduct, "LFCCLSF"); if(indexOfProd != -1){ Double PrixU = Double.valueOf(ArrayPrice[indexOfProd]); PriceHt = PriceHt + (qt * PrixU); } break; case 2: indexOfProd = getIndexOfItemInArray(ArrayProduct, "LFENSSAUVDFSC"); if(indexOfProd != -1){ Double PrixU = Double.valueOf(ArrayPrice[indexOfProd]); PriceHt = PriceHt + (qt * PrixU); } break; case 3: indexOfProd = getIndexOfItemInArray(ArrayProduct, "LFENSSFSC"); if(indexOfProd != -1){ Double PrixU = Double.valueOf(ArrayPrice[indexOfProd]); PriceHt = PriceHt + (qt * PrixU); } break; case 4: indexOfProd = getIndexOfItemInArray(ArrayProduct, "LFENSDFSH"); if(indexOfProd != -1){ Double PrixU = Double.valueOf(ArrayPrice[indexOfProd]); PriceHt = PriceHt + (qt * PrixU); } break; case 5: indexOfProd = getIndexOfItemInArray(ArrayProduct, "LFENSSFSH"); if(indexOfProd != -1){ Double PrixU = Double.valueOf(ArrayPrice[indexOfProd]); PriceHt = PriceHt + (qt * PrixU); } break; case 6: indexOfProd = getIndexOfItemInArray(ArrayProduct, "LFENSDFLE"); if(indexOfProd != -1){ Double PrixU = Double.valueOf(ArrayPrice[indexOfProd]); PriceHt = PriceHt + (qt * PrixU); } break; case 7: indexOfProd = getIndexOfItemInArray(ArrayProduct, "LFENSSPLE"); if(indexOfProd != -1){ Double PrixU = Double.valueOf(ArrayPrice[indexOfProd]); PriceHt = PriceHt + (qt * PrixU); } break; case 8: indexOfProd = getIndexOfItemInArray(ArrayProduct, "PLMILL"); if(indexOfProd != -1){ Double PrixU = Double.valueOf(ArrayPrice[indexOfProd]); PriceHt = PriceHt + (qt * PrixU); } break; case 9: indexOfProd = getIndexOfItemInArray(ArrayProduct, "PLMILLSUPP"); if(indexOfProd != -1){ Double PrixU = Double.valueOf(ArrayPrice[indexOfProd]); PriceHt = PriceHt + (qt * PrixU); } break; } } return PriceHt; } public static String getUpdChe(String entid, String entClass, String entType) { String[] ArrayClass = null; String[] ArrayType = null; String entidche = null; if(entType != null && entType.indexOf(";") != -1){ ArrayClass = entClass.split(";"); ArrayType = entType.split(";"); }else if(entType != null && entType.indexOf(";") == -1){ if("CHE".equals(entType)){ entidche = entClass; return entidche; } } int index_che = getIndexOfItemInArray(ArrayType, "CHE"); if(index_che != -1){ entidche = ArrayClass[index_che]; } return entidche; } public static String getUpdCoc(String entid, String entClass, String entType) { String[] ArrayClass = null; String[] ArrayType = null; String entidche = null; if(entType != null && entType.indexOf(";") != -1){ ArrayClass = entClass.split(";"); ArrayType = entType.split(";"); }else if(entType != null && entType.indexOf(";") == -1){ if("COC".equals(entType)){ entidche = entClass; return entidche; } } int index_che = getIndexOfItemInArray(ArrayType, "COC"); if(index_che != -1){ entidche = ArrayClass[index_che]; } return entidche; } public static String substrByLen(String str, int len) { String rtString; if (str == null || ("").equals(str)) { rtString = null; } else { rtString = (str.length() > len) ? str.substring(0, len) : str; } return rtString; } public static String GetFomatDate(String date) { String[] ArrayFormat = {"dd/MM/yyyy", "dd/MM/yyyy HH:mm", "dd/MM/yyyy HH:mm:ss", "dd-MM-yyyy", "yyyy-MM-dd", "yyyy-MM-dd HH:mm", "yyyy-MM-dd HH:mm:ss", "dd-MM-yyyy HH:mm", "dd-MM-yyyy HH:mm:ss"}; for(int i=0;i<ArrayFormat.length;i++){ DateFormat f1 = new SimpleDateFormat(ArrayFormat[i]); try { Date d1 = f1.parse(date); String date_str = f1.format(d1); if(date_str.equals(date)){ return ArrayFormat[i]; } } catch (ParseException e) { } } return null; } public static String GetFomatDate1(String date) { String ArrayFormat = "MM-dd-yyyy"; DateFormat f1 = new SimpleDateFormat(ArrayFormat); try { Date d1 = f1.parse(date); String date_str = f1.format(d1); if(date_str.equals(date)){ return ArrayFormat; } } catch (ParseException e) { } return null; } public static String ValidateDouble(String number) { if(number != null && number.indexOf(",") != -1){ number = number.replace(",", "."); } if(Utils.isDouble(number)){ return number; } return null; } public static String GetPerTokenByPerID(String perid) { if(perid != null && perid.length() == 16){ return perid.substring(perid.length() - 8,perid.length()); } return null; } public static String maskNumber(String number, String mask) { if(number == null || "".equals(number)) return ""; //number = number.replaceAll("\\s+",""); if(mask == null || "".equals(mask)) return number; int index = 0; int index_mask = 0; StringBuilder masked = new StringBuilder(); for (int i = 0; i < mask.length(); i++) { char c = mask.charAt(i); if (c == '?') { index_mask++; } } if(number.length() > index_mask) return number; for (int i = 0; i < mask.length(); i++) { char c = mask.charAt(i); if (c == '?') { if(number.length()> index){ masked.append(number.charAt(index)); } index++; } else { masked.append(c); } } return masked.toString(); } public static String maskPhone(String number, String Prifixe, String Parenthese, Double NbrCara, Double Espace) { if(number == null || "".equals(number)) return ""; //number = number.replaceAll("\\s+",""); number = number.trim(); String interogation = ""; String mask = ""; for(int i=0;i<number.length();i++){ interogation += "?"; } String nbrcar = NbrCara+""; int nbrcarparenthese = NbrCara != null ? NbrCara.intValue() : 0; String interoParenthese = ""; if(Parenthese != null && Parenthese.equalsIgnoreCase("O")){ for(int i=0;i<nbrcarparenthese;i++){ interoParenthese += "?"; } if(Espace != null && Espace.equals(1.0)){ mask = ReplaceNullByEmpty(Prifixe)+"("+interoParenthese+") "+interogation; }else{ mask = ReplaceNullByEmpty(Prifixe)+"("+interoParenthese+")"+interogation; } }else{ if(Espace != null && Espace.equals(1.0)){ mask = ReplaceNullByEmpty(Prifixe)+" "+interogation; }else{ mask = ReplaceNullByEmpty(Prifixe)+interogation; } } return maskNumber(number, mask); } public static String TrieLocGuideMaury(String loc, String locRat) { String[] list = new String[2]; list[0] = loc ; list[1] = locRat; Arrays.sort(list); return list[0].equals(loc) ? "bottom" : "top"; } public static boolean resizeImage(String path_of_image){ BufferedImage originalImage = null; int type = 0; try { originalImage = ImageIO.read(new File("c:\\galaxie\\Report\\data-integration.jpg")); type = originalImage.getType() == 0 ? BufferedImage.TYPE_INT_ARGB : originalImage.getType(); BufferedImage resizeImageHintJpg = resizeImageWithHint(originalImage, type); ImageIO.write(resizeImageHintJpg, "jpg", new File("c:\\galaxie\\Report\\data-integration-100.jpg")); } catch (IOException e) { // TODO Auto-generated catch block //e.printStackTrace(); } return true; } public static BufferedImage resizeImageWithHint(BufferedImage originalImage, int type){ BufferedImage resizedImage = new BufferedImage(IMG_WIDTH, IMG_HEIGHT, type); Graphics2D g = resizedImage.createGraphics(); g.drawImage(originalImage, 0, 0, IMG_WIDTH, IMG_HEIGHT, null); g.dispose(); g.setComposite(AlphaComposite.Src); g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); return resizedImage; } public static boolean saveImageFromByte(String imageInByte, String direc, String name) throws IOException { byte[] btDataFile = new sun.misc.BASE64Decoder().decodeBuffer(imageInByte); InputStream in = new ByteArrayInputStream(btDataFile); BufferedImage bImageFromConvert = ImageIO.read(in); //ImageIO.write(bImageFromConvert, "png", new File("c:\\galaxie\\Report\\new-image.png")); int type = 0; type = bImageFromConvert.getType() == 0 ? BufferedImage.TYPE_INT_ARGB : bImageFromConvert.getType(); BufferedImage resizeImageHintJpg = resizeImageWithHint(bImageFromConvert, type); ImageIO.write(resizeImageHintJpg, "jpg", new File(direc+name)); return true; } public static String getSizeImageFromByte(String imageInByte) { byte[] btDataFile = null; DecimalFormat format = new DecimalFormat("0.##"); double ko = 0; try{ btDataFile = new sun.misc.BASE64Decoder().decodeBuffer(imageInByte); ko = (double)btDataFile.length/1024; }catch(IOException e){ } return format.format(ko); } public static String htmlspecialchars_decode_ENT_NOQUOTES(String s){ for (Map.Entry<String, String> entry : html_specialchars_table.entrySet()) { String key = entry.getKey(); String val = entry.getValue(); s = s.replaceAll(key, val); } return s; } public static String concatinationAdress(String sep, String... args){ String adress = ""; String tmp = ""; int i=0; for(String arg:args){ if(arg != null && !arg.isEmpty()){ if(i == 2){ String arg_tmp = args[i].toLowerCase(); tmp = args[0] != null && !args[0].isEmpty() ? args[i].replaceAll(args[0].toLowerCase(), "") : args[i]; args[2] = args[1] != null && !args[1].isEmpty() ? tmp.replaceAll(args[1].toLowerCase(), "") : tmp; args[2] = args[2].replaceAll(",", ""); } } i++; } for(String arg:args){ if(arg != null && !arg.isEmpty()){ adress = adress.isEmpty() ? arg : adress+sep+arg; } } return adress; } public static String trieDept(String s){ System.out.println(s); return s; } public static boolean CheackEq(String eqs, String... args){ String[] ArrayEq = eqs.split(";"); int index = 0; if(ArrayEq.length > 0){ for(String arg:args){ index = getIndexOfItemInArray(ArrayEq, arg); if(index == -1){ return false; } } } return true; } public static String getFileMaury(ArrayList <Maury> list){ String contentFile = ""; String loc03_current = ""; String loc03_next = ""; String loc13 = ""; String[] arrLoc13 = new String[1000]; Map<String,String> MapLoc13 = new Hashtable<String,String>(); Map<String,String> MapLoc13NotAPP = new Hashtable<String,String>(); int index = 0; for (Maury temp : list) { String getnamedept = getValCodeMauryByNum("02",temp.getRLine2()); String getnamedeptby13 = getValCodeMauryByNum("07",temp.getDLine1T()); if(temp.getDLine1T() != null && !temp.getDLine1T().isEmpty()){ if(!getnamedept.equalsIgnoreCase(getnamedeptby13) && !getnamedept.isEmpty() && !getnamedeptby13.isEmpty()){ MapLoc13NotAPP.put(temp.getLoc13(), temp.getDLine1T()); } } } for (Maury temp : list) { String Pays = temp.getPays(); String RLine1 = temp.getRLine1(); String RLine2 = temp.getRLine2(); if(!contentFile.contains(Pays)){ contentFile += Pays+"<br>"; } if(!contentFile.contains(RLine1)){ SortedSet<String> keys = new TreeSet<String>(MapLoc13.keySet()); for (String key : keys) { String value = MapLoc13.get(key); if(value != null && !value.isEmpty()){ if(!contentFile.contains(value)){ contentFile += value+"<br>"; } } } MapLoc13 = new Hashtable<String,String>(); contentFile += RLine1+"<br>"; } if(!contentFile.contains(RLine2)){ SortedSet<String> keys = new TreeSet<String>(MapLoc13.keySet()); for (String key : keys) { String value = MapLoc13.get(key); if(value != null && !value.isEmpty()){ if(!contentFile.contains(value)){ contentFile += value+"<br>"; } } } MapLoc13 = new Hashtable<String,String>(); contentFile += RLine2+"<br>"; } String DLine2 = temp.getDLine2(); String DescHotel = temp.getDesc(); String DLine1T = temp.getDLine1T(); String DLine1B = temp.getDLine1B(); String DLine3 = temp.getDLine3(); loc03_current = temp.getLoc03(); //if(temp.getLoc13() != null && !temp.getLoc13().isEmpty()){ //MapLoc13.put(temp.getLoc13(), DLine1T); //System.out.println("Add=> Loc13:"+temp.getLoc13()+" DLine1T:"+DLine1T); //} Maury mnext = list.size() > index + 1 ? (Maury)list.get(index+1) : null; loc03_next = mnext != null && mnext.getRLine2().equalsIgnoreCase(RLine2) ? mnext.getLoc03() : ""; if(MapLoc13.size() == 0){ Map<String,String> MapLoc13_tmp = new Hashtable<String,String>(); for(int j=index; list.size() > j ; j++){ Maury mnext_ = list.size() > j ? (Maury)list.get(j) : null; loc03_next = mnext_ != null ? mnext_.getLoc03() : ""; String RLine2_ = mnext_.getRLine2(); if(!contentFile.contains(RLine2_)){ break; }else{ String getnamedept = getValCodeMauryByNum("02",RLine2_); String getnamedeptby13 = getValCodeMauryByNum("07",mnext_.getDLine1T()); if(getnamedept.equalsIgnoreCase(getnamedeptby13) && !getnamedept.isEmpty() && !getnamedeptby13.isEmpty()){ MapLoc13_tmp.put(mnext_.getLoc13(), mnext_.getDLine1T()); } } } for (Map.Entry<String, String> entry : MapLoc13NotAPP.entrySet()) { String key = entry.getKey(); String val = entry.getValue(); if(!val.isEmpty()){ String getnamedept = getValCodeMauryByNum("02",RLine2); String getnamedeptby13 = getValCodeMauryByNum("07",val); if(getnamedept.equalsIgnoreCase(getnamedeptby13) && !getnamedept.isEmpty() && !getnamedeptby13.isEmpty()){ MapLoc13_tmp.put(key, val); MapLoc13NotAPP.put(key, ""); } } } SortedSet<String> keys = new TreeSet<String>(MapLoc13_tmp.keySet()); for (String key : keys) { String value = MapLoc13_tmp.get(key); if(value != null && !value.isEmpty()){ /*if(getValCodeMauryByNum("07",value).equalsIgnoreCase("Pyrénées Atlantiques")){ System.out.println(key+":"+value); }*/ MapLoc13.put(key, value); } } } //System.out.println("Début"); SortedSet<String> keysLoc13 = new TreeSet<String>(MapLoc13.keySet()); for (String key : keysLoc13) { String value = MapLoc13.get(key); if(value != null && !value.isEmpty()){ /*if(getValCodeMauryByNum("07",value).equalsIgnoreCase("Pyrénées Atlantiques")){ System.out.println(key+":"+value); }*/ if(TrieLoc0313GuideMaury(loc03_current,key, loc03_next)){ if(!value.isEmpty() && !contentFile.contains(value)){ /*if(value.equalsIgnoreCase("@13GEUS D'OLORON@04F-64400@07Pyrénées Atlantiques@14OLORON SAINTE MARIE (7 km)@99#")){ System.out.println("loc03_current:"+loc03_current+" loc03_next:"+loc03_next+ " key:"+key); } if(value.equalsIgnoreCase("@13GAN@04F-64290@07Pyrénées Atlantiques@14PAU (8 km)@99#")){ System.out.println("loc03_current:"+loc03_current+" loc03_next:"+loc03_next+ " key:"+key); }*/ contentFile += value+"<br>"; MapLoc13.put(key, ""); } } } } //System.out.println("Fin"); /*for (Map.Entry<String, String> entry : MapLoc13.entrySet()) { String key = entry.getKey(); String val = entry.getValue(); if(!val.isEmpty()){ if(getValCodeMauryByNum("07",val).equalsIgnoreCase("Pyrénées Atlantiques")){ System.out.println(key+":"+val); } if(TrieLoc0313GuideMaury(loc03_current,key, loc03_next)){ if(!val.isEmpty() && !contentFile.contains(val)){ if(val.equalsIgnoreCase("@13GEUS D'OLORON@04F-64400@07Pyrénées Atlantiques@14OLORON SAINTE MARIE (7 km)@99#")){ System.out.println("loc03_current:"+loc03_current+" loc03_next:"+loc03_next+ " key:"+key); } if(val.equalsIgnoreCase("@13GAN@04F-64290@07Pyrénées Atlantiques@14PAU (8 km)@99#")){ System.out.println("loc03_current:"+loc03_current+" loc03_next:"+loc03_next+ " key:"+key); } contentFile += val+"<br>"; MapLoc13.put(key, ""); } } } }*/ /*if(DLine1T != null && !DLine1T.isEmpty() && !contentFile.contains(DLine1T)){ contentFile += DLine1T+"<br>"; }*/ if(!contentFile.contains(DLine2)){ contentFile += DLine2+"<br>"; } if(DLine3 != null && !DLine3.isEmpty() && !contentFile.contains(DLine3)){ contentFile += DLine3+"<br>"; } contentFile += DescHotel+"<br>"; index++; /*if(DLine1B != null && !DLine1B.isEmpty() && contentFile.contains(DLine1B)){ contentFile = contentFile.replace(DLine1B+"<br>", ""); contentFile += DLine1B+"<br>"; }else if(DLine1B != null && !DLine1B.isEmpty() && !contentFile.contains(DLine1B)){ contentFile += DLine1B+"<br>"; }*/ //String[] ArrayHotel = DescHotel.split(";"); //String[] ArrayDLine1T = DLine1T != null && !DLine1T.equalsIgnoreCase("null") ? DLine1T.split(";") : null; //String[] ArrayDLine1B = DLine1B != null && !DLine1B.equalsIgnoreCase("null") ? DLine1B.split(";") : null; //String[] ArrayDLine3 = DLine3.split(";"); //int index = 0; //if(ArrayHotel.length > 1){ //for(int i=0;ArrayHotel.length >i; i++ ){ //index++; //} //} } //System.out.println(contentFile); return contentFile; } public static boolean TrieLoc0313GuideMaury(String loc03, String loc13, String loc03next) { String[] list = new String[3]; list[0] = loc13 ; list[1] = loc03; list[2] = loc03next !=null && !loc03next.isEmpty() ? loc03next : "_"; Arrays.sort(list); return list[0].equals(loc13) ? true : false; } public static String getValCodeMauryByNum(String code, String str){ Pattern pattern = Pattern.compile("(\\@"+code+")(.*?)(\\@)"); Matcher m = pattern.matcher(str); if (m.find()) { return m.group(2); } return ""; } public static String getAccesByLoc(String loc){ String acces =""; loc = loc != null ? loc.trim() : ""; if(loc.length() == 0) return acces; String pr = String.valueOf(loc.charAt(0)); if(!isInteger(pr)){ return acces; } acces = Utils.substrByLen(loc, 5) != null ? Utils.substrByLen(loc, 5) : ""; if(acces.toLowerCase().contains("km") || acces.toLowerCase().contains("m")){ return acces; }else{ return ""; } } public static String getNameFileOfPath(String file){ if(file == null) return ""; String filenameWithPath = file; String[] tokens = filenameWithPath.split("[/]"); String filename = tokens[tokens.length - 1]; return filename; } public static String getNameOfFile(String file){ if(file == null) return ""; File f = new File(file); return f.getName(); } }
Ms-Dos/Windows
Unix
Write backup
jsp File Browser version 1.2 by
www.vonloesch.de