Subversion Repositories eFlore/Applications.coel

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

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