Subversion Repositories eFlore/Applications.cel

Rev

Rev 1542 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1542 Rev 1549
Line 1... Line 1...
1
package org.tela_botanica.client.util;
1
package org.tela_botanica.client.util;
Line 2... Line 2...
2
 
2
 
-
 
3
import java.util.HashMap;
3
import java.util.HashMap;
4
import java.util.Iterator;
Line 4... Line -...
4
import java.util.Map;
-
 
5
 
5
import java.util.Map;
Line 6... Line 6...
6
import org.tela_botanica.client.modeles.objets.ListeObservation;
6
 
7
import org.tela_botanica.client.modeles.objets.Observation;
7
import org.tela_botanica.client.modeles.objets.Observation;
8
 
8
 
Line 9... Line 9...
9
import com.google.gwt.json.client.JSONArray;
9
import com.google.gwt.http.client.URL;
Line 17... Line 17...
17
	
17
	
18
	public static String getValeurJsonOuVide(JSONObject jo, String index) {
18
	public static String getValeurJsonOuVide(JSONObject jo, String index) {
19
		return jsonNonNull(jo, index) ? ((JSONString)jo.get(index)).stringValue() : "";
19
		return jsonNonNull(jo, index) ? ((JSONString)jo.get(index)).stringValue() : "";
Line 20... Line 20...
20
	}
20
	}
21
	
21
	
22
	public static Map<String, String> getMapValeursOuVide(JSONArray jo, String index) {
22
	public static Map<String, String> getMapValeursOuVide(JSONObject jo, String index) {
23
		Map<String, String> mapValeurs = new HashMap<String, String>();
23
		Map<String, String> mapValeurs = new HashMap<String, String>();
24
		final int taillemax = jo.size();	
24
		if(jo.get(index) != null && jo.get(index).isObject() != null) {	
25
		JSONObject temp = null;
25
			JSONObject mapJo = jo.get(index).isObject();
26
		for (int i = 0; i < taillemax; i++) {
26
			for (Iterator<String> it = mapJo.keySet().iterator(); it.hasNext();) {
27
			if ((temp = jo.get(i).isObject()) != null) {
27
				String cle = it.next();
28
				mapValeurs.put(temp.get("cle").isString().stringValue(), temp.get("valeur").isString().stringValue());
28
				mapValeurs.put(cle, mapJo.get(cle).isString().stringValue());
29
			}
29
			}
30
		}
30
		}
Line -... Line 31...
-
 
31
		return mapValeurs;
-
 
32
	}
-
 
33
	
-
 
34
	public static String convertirMapEnChaineRequete(Map<String, String> map, String cleUrl) {
-
 
35
		String chaineChamps = "";
-
 
36
		for (Iterator<String> it = map.keySet().iterator(); it.hasNext();) {
-
 
37
			String cle = it.next();
-
 
38
			String valeur = map.get(cle);
-
 
39
			chaineChamps += URL.encode(cleUrl+"["+cle+"]")+"="+URL.encode(valeur)+"&";
-
 
40
		}
31
		return mapValeurs;
41
		return chaineChamps;
32
	}
42
	}
33
	
43
	
34
	public static boolean jsonNonNull(JSONObject jo, String index) {
44
	public static boolean jsonNonNull(JSONObject jo, String index) {
35
		return (jo != null && 
45
		return (jo != null &&