Subversion Repositories eFlore/Applications.coel

Rev

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

Rev 156 Rev 188
1
package org.tela_botanica.client.modeles;
1
package org.tela_botanica.client.modeles;
2
 
2
 
3
import java.util.ArrayList;
3
import java.util.ArrayList;
4
 
4
 
5
import com.google.gwt.json.client.JSONArray;
5
import com.google.gwt.json.client.JSONArray;
6
 
6
 
7
public class Information {
7
public class Information {
8
	
8
	
9
	private String type = null;
9
	private String type = null;
10
	private ArrayList<String> messages = null;
10
	private ArrayList<String> messages = null;
11
	private ArrayList<Object> donnees = null;
11
	private ArrayList<Object> donnees = null;
12
	
12
	
13
	public Information() {
13
	public Information() {
14
		messages = new ArrayList<String>();
14
		messages = new ArrayList<String>();
-
 
15
		donnees = new ArrayList<Object>();
15
	}
16
	}
16
 
17
 
17
	public Information(String t) {
18
	public Information(String t) {
-
 
19
		donnees = new ArrayList<Object>();
-
 
20
		messages = new ArrayList<String>();
18
		type = t;
21
		type = t;
19
	}
22
	}
20
	
23
	
21
	public Information(String t, String m) {
24
	public Information(String t, String m) {
-
 
25
		donnees = new ArrayList<Object>();
22
		messages = new ArrayList<String>();
26
		messages = new ArrayList<String>();
23
		messages.add(m);
27
		messages.add(m);
24
		type = t;
28
		type = t;
25
	}
29
	}
26
	
30
	
27
	public Information(String t, JSONArray jsonArray) {
31
	public Information(String t, JSONArray jsonArray) {
-
 
32
		donnees = new ArrayList<Object>();
28
		messages = new ArrayList<String>();
33
		messages = new ArrayList<String>();
29
		for(int i = 0 ; i < jsonArray.size() ; i++) {
34
		for(int i = 0 ; i < jsonArray.size() ; i++) {
30
			if (jsonArray.get(i).isString() != null) {
35
			if (jsonArray.get(i).isString() != null) {
31
				messages.add(jsonArray.get(i).isString().stringValue());
36
				messages.add(jsonArray.get(i).isString().stringValue());
32
			}
37
			}
33
		}
38
		}
34
		type = t;
39
		type = t;
35
	}
40
	}
36
 
41
 
37
	public Information(String t, Object o) {
42
	public Information(String t, Object o) {
-
 
43
		messages = new ArrayList<String>();
38
		donnees = new ArrayList<Object>();
44
		donnees = new ArrayList<Object>();
39
		donnees.add(o);
45
		donnees.add(o);
40
		type = t;
46
		type = t;
41
	}
47
	}
42
	
48
	
43
 
49
 
44
	public void setType(String t) {
50
	public void setType(String t) {
45
		type = t;
51
		type = t;
46
	}
52
	}
47
	public String getType() {
53
	public String getType() {
48
		return type;
54
		return type;
49
	}
55
	}
50
	
56
	
51
	public void setMessage(String message) {
57
	public void setMessage(String message) {
52
		messages.add(message);
58
		messages.add(message);
53
	}
59
	}
54
	public String getMessage(int index) {
60
	public String getMessage(int index) {
55
		return messages.get(index);
61
		return messages.get(index);
56
	}
62
	}
57
	
63
	
58
	public ArrayList<String> getMessages() {
64
	public ArrayList<String> getMessages() {
59
		return messages;
65
		return messages;
60
	}
66
	}
61
	
67
	
62
	public void setDonnee(Object objet) {
68
	public void setDonnee(Object objet) {
63
		donnees.add(objet);
69
		donnees.add(objet);
64
	}
70
	}
-
 
71
	public void setDonnee(int index, Object objet) {
-
 
72
		if (objet != null) {
-
 
73
			donnees.add(index, objet);
-
 
74
		}
-
 
75
	}
65
	public Object getDonnee(int index) {
76
	public Object getDonnee(int index) {
-
 
77
		try {
66
		return donnees.get(index);
78
			return donnees.get(index);
-
 
79
		} catch (Exception e) {
-
 
80
			return null;
-
 
81
		}
67
	}
82
	}
68
	
83
	
69
	public ArrayList<Object> getDonnees() {
84
	public ArrayList<Object> getDonnees() {
70
		return donnees;
85
		return donnees;
71
	}
86
	}
72
 
87
 
73
	public String toString() {
88
	public String toString() {
74
		String chaine = new String();
89
		String chaine = new String();
75
		if (messages != null) {
90
		if (messages != null) {
76
			for(int i = 0 ; i < messages.size() ; i++) {
91
			for(int i = 0 ; i < messages.size() ; i++) {
77
				// GXT ne prend pas en compte /n ou /r/n...
92
				// GXT ne prend pas en compte /n ou /r/n...
78
				chaine += getMessage(i)+"\n";
93
				chaine += getMessage(i)+"\n";
79
			}
94
			}
80
		}
95
		}
81
		return chaine;
96
		return chaine;
82
	}
97
	}
83
}
98
}