File tree Expand file tree Collapse file tree 1 file changed +22
-3
lines changed
src/main/java/fr/umontp/edt Expand file tree Collapse file tree 1 file changed +22
-3
lines changed Original file line number Diff line number Diff line change 11package fr .umontp .edt ;
22
3+ import java .text .Normalizer ;
34import java .util .Locale ;
5+ import java .util .regex .Pattern ;
46
57/**
68 * <b>Professeur est la classe représentant un professeur au sein de l'emploi du
1921 * @see RepertoireProfesseur
2022 *
2123 * @author MathieuSoysal
22- * @version 1.0.0
24+ * @version 1.0.1
2325 */
2426public class Professeur {
2527 private String denomination ;
@@ -39,12 +41,29 @@ public class Professeur {
3941 denomination = formater (nom , prenom );
4042 }
4143
44+ /**
45+ * @param nomPrenom
46+ *
47+ * @return la variable {@code nomPrenom} formaté.
48+ *
49+ * @see String#toUpperCase(Locale)
50+ * @see Professeur#supprimerAccent(String)
51+ *
52+ * @since 1.0.1
53+ */
54+ static String formater (String nomPrenom ) {
55+ nomPrenom = supprimerAccent (nomPrenom );
56+ return nomPrenom .toUpperCase (Locale .FRANCE ).replaceAll ("[^A-Z ]" , " " );
57+ }
58+
4259 static String formater (String nom , String prenom ) {
4360 return formater (nom + " " + prenom );
4461 }
4562
46- static String formater (String nomPrenom ) {
47- return nomPrenom .toUpperCase (Locale .FRANCE ).replaceAll ("[^A-Z ]" , " " );
63+ private static String supprimerAccent (String str ) {
64+ String nfdNormalizedString = Normalizer .normalize (str , Normalizer .Form .NFD );
65+ Pattern pattern = Pattern .compile ("\\ p{InCombiningDiacriticalMarks}+" );
66+ return pattern .matcher (nfdNormalizedString ).replaceAll ("" );
4867 }
4968
5069 /**
You can’t perform that action at this time.
0 commit comments