Subversion Repositories eFlore/Applications.del

Rev

Rev 1953 | Rev 2056 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1953 Rev 2050
1
package org.tela_botanica.del.client.utils;
1
package org.tela_botanica.del.client.utils;
-
 
2
 
-
 
3
import org.tela_botanica.del.client.i18n.I18n;
2
 
4
 
3
import com.google.gwt.i18n.client.NumberFormat;
5
import com.google.gwt.i18n.client.NumberFormat;
4
 
6
 
5
public class StringUtils {
7
public class StringUtils {
6
	
8
	
7
	public static boolean checkStringNotNull(String s){
9
	public static boolean checkStringNotNull(String s){
8
		if(s!=null&&!s.equals("")){
10
		if(s!=null&&!s.equals("")){
9
			return true;
11
			return true;
10
		}
12
		}
11
		return false;
13
		return false;
12
	}
14
	}
13
	
15
	
14
	public static String normaliser(String mot) {
16
	public static String normaliser(String mot) {
15
		
17
		
16
		mot = mot.toLowerCase().trim().replace(" ", "");
18
		mot = mot.toLowerCase().trim().replace(" ", "");
17
		
19
		
18
		// Le manque de support des librairies standard java
20
		// Le manque de support des librairies standard java
19
		// nous oblige à utiliser cette méthode un peu batarde
21
		// nous oblige à utiliser cette méthode un peu batarde
20
		char[] accents = {'à','á','â','ã','ä','ç','è','é','ê','ë','ì','í','î','ï','ñ','ò','ó','ô','õ','ö','ù','ú','û','ü','ý','ÿ','À','Á','Â','Ã','Ä','Ç','È','É','Ê','Ë', 'Ì','Í','Î','Ï','Ñ','Ò','Ó','Ô','Õ','Ö','Ù','Ú','Û','Ü','Ý'};
22
		char[] accents = {'à','á','â','ã','ä','ç','è','é','ê','ë','ì','í','î','ï','ñ','ò','ó','ô','õ','ö','ù','ú','û','ü','ý','ÿ','À','Á','Â','Ã','Ä','Ç','È','É','Ê','Ë', 'Ì','Í','Î','Ï','Ñ','Ò','Ó','Ô','Õ','Ö','Ù','Ú','Û','Ü','Ý'};
21
		char[] sansAccents = {'a','a','a','a','a','c', 'e','e','e','e','i','i','i','i','n','o','o','o','o','o','u','u','u','u', 'y','y','A','A','A','A','A','C','E','E','E','E','I','I','I','I','N','O','O','O','O','O','U','U','U','U','Y'};
23
		char[] sansAccents = {'a','a','a','a','a','c', 'e','e','e','e','i','i','i','i','n','o','o','o','o','o','u','u','u','u', 'y','y','A','A','A','A','A','C','E','E','E','E','I','I','I','I','N','O','O','O','O','O','U','U','U','U','Y'};
22
	
24
	
23
		for (int i = 0; i < accents.length; i++) {
25
		for (int i = 0; i < accents.length; i++) {
24
			mot = mot.replace(accents[i], sansAccents[i]);
26
			mot = mot.replace(accents[i], sansAccents[i]);
25
		}
27
		}
26
	
28
	
27
		return mot;
29
		return mot;
28
	}
30
	}
29
	
31
	
30
	public static native void logVersConsole(Object o) /*-{
32
	public static native void logVersConsole(Object o) /*-{
31
		if(!!($wnd.console && $wnd.console.log)) {
33
		if(!!($wnd.console && $wnd.console.log)) {
32
			$wnd.console.log(o);
34
			$wnd.console.log(o);
33
		}
35
		}
34
	}-*/;
36
	}-*/;
35
	
37
	
36
	public static String formaterNombre(double valeur, int decimales) {
38
	public static String formaterNombre(double valeur, int decimales) {
37
	    StringBuilder patternNb = new StringBuilder(
39
	    StringBuilder patternNb = new StringBuilder(
38
	            (decimales <= 0) ? "" : ".");
40
	            (decimales <= 0) ? "" : ".");
39
	    for (int i = 0; i < decimales; i++) {
41
	    for (int i = 0; i < decimales; i++) {
40
	    	patternNb.append('0');
42
	    	patternNb.append('0');
41
	    }
43
	    }
42
	    
44
	    
43
	    if(valeur == 0) {
45
	    if(valeur == 0) {
44
	    	patternNb.insert(0, 0);
46
	    	patternNb.insert(0, 0);
45
	    }
47
	    }
46
	    
48
	    
47
	    return NumberFormat.getFormat(patternNb.toString()).format(valeur);
49
	    return NumberFormat.getFormat(patternNb.toString()).format(valeur);
48
	}
50
	}
-
 
51
	
-
 
52
	public static String getCorrespondanceChaineEvenementObs(String evenement, int nb) {
-
 
53
		String trad = "";
-
 
54
		
-
 
55
		// Arghhhh pourquoi on ne peut pas faire de switch sur une string !!!!!!
-
 
56
		// arggh arrrghghhhhhh
-
 
57
		if(evenement.equals("nouveau_vote")) {
-
 
58
			trad = nb > 1 ? I18n.getMessages().nouveauxVotes(nb+"") : I18n.getVocabulary().nouveauVote();
-
 
59
		}
-
 
60
		
-
 
61
		if(evenement.equals("nouveau_commentaire")) {
-
 
62
			trad = nb > 1 ? I18n.getMessages().nouveauxCommentaires(nb+"") : I18n.getVocabulary().nouveauCommentaire();
-
 
63
		}
-
 
64
			
-
 
65
		if(evenement.equals("nouvelle_observation")) {
-
 
66
			trad = I18n.getVocabulary().nouvelleObservation();
-
 
67
		}
-
 
68
		
-
 
69
		if(evenement.equals("nouveau_commentaire_vous_a_obs_autre")) {
-
 
70
			trad = I18n.getVocabulary().nouveauCommentaireVousAObsAutre();
-
 
71
		}
-
 
72
		
-
 
73
		if(evenement.equals("nouveau_commentaire_autre_sur_obs_vous")) {
-
 
74
			trad = I18n.getVocabulary().nouveauCommentaireAutreSurObsVous();
-
 
75
		}
-
 
76
		
-
 
77
		if(evenement.equals("nouvelle_proposition_vous_a_obs_autre")) {
-
 
78
			trad = I18n.getVocabulary().nouvellePropositionVousAObsAutre();
-
 
79
		}
-
 
80
		
-
 
81
		if(evenement.equals("nouvelle_proposition_autre_sur_obs_vous")) {
-
 
82
			trad = I18n.getVocabulary().nouvellePropositionAutreSurObsVous();
-
 
83
		}
-
 
84
		
-
 
85
		if(evenement.equals("nouveau_vote_vous_a_com_autre")) {
-
 
86
			trad = I18n.getVocabulary().nouveauVoteVousAComAutre();
-
 
87
		}
-
 
88
		
-
 
89
		if(evenement.equals("nouveau_vote_autre_sur_com_vous")) {
-
 
90
			trad = I18n.getVocabulary().nouveauVoteAutreSurComVous();
-
 
91
		}
-
 
92
		
-
 
93
		if(evenement.equals("nouvelle_validation_vous_a_prop_autre")) {
-
 
94
			trad = I18n.getVocabulary().nouvelleValidationVousAPropAutre();
-
 
95
		}
-
 
96
		
-
 
97
		if(evenement.equals("nouvelle_validation_autre_sur_prop_vous")) {
-
 
98
			trad = I18n.getVocabulary().nouvelleValidationAutreAPropVous();
-
 
99
		}
-
 
100
		
-
 
101
		return trad;
-
 
102
	}
49
}
103
}