Subversion Repositories eFlore/Applications.cel

Compare Revisions

Ignore whitespace Rev 1541 → Rev 1542

/trunk/src/org/tela_botanica/client/util/Util.java
1,7 → 1,12
package org.tela_botanica.client.util;
 
import java.util.HashMap;
import java.util.Map;
 
import org.tela_botanica.client.modeles.objets.ListeObservation;
import org.tela_botanica.client.modeles.objets.Observation;
 
import com.google.gwt.json.client.JSONArray;
import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONString;
 
14,6 → 19,18
return jsonNonNull(jo, index) ? ((JSONString)jo.get(index)).stringValue() : "";
}
public static Map<String, String> getMapValeursOuVide(JSONArray jo, String index) {
Map<String, String> mapValeurs = new HashMap<String, String>();
final int taillemax = jo.size();
JSONObject temp = null;
for (int i = 0; i < taillemax; i++) {
if ((temp = jo.get(i).isObject()) != null) {
mapValeurs.put(temp.get("cle").isString().stringValue(), temp.get("valeur").isString().stringValue());
}
}
return mapValeurs;
}
public static boolean jsonNonNull(JSONObject jo, String index) {
return (jo != null &&
jo.get(index) != null &&
74,6 → 91,52
return lieuModele;
}
public static String obtenirDepartementAPartirChaineCommune(String departement, String commune) {
String dep = "";
if(departement == null) {
departement = "";
}
if(departement.equals("000null") || departement.equals("")) {
String[] depCom = commune.split(" ");
if(depCom.length > 1) {
dep = depCom[1].replace('(', ' ');
} else {
dep = "";
}
} else {
dep = departement;
}
dep = dep.replace(')', ' ');
dep = dep.trim();
dep = dep.replace('\\',' ');
dep = dep.trim();
try
{
int nDep = Integer.parseInt(dep);
if(nDep > 0 && nDep < 110) {
departement = dep ;
}
if(departement.length() == 4) {
departement = "0"+departement;
}
departement = departement.substring(0,2);
}
catch(NumberFormatException e)
{
departement = "" ;
}
return departement;
}
public static String supprimerNumDepartementChaineLocalite(String chaineLocaliteComplete) {
return chaineLocaliteComplete.replaceAll(" \\([0-9]*\\)", "");
}