Subversion Repositories eFlore/Applications.coel

Rev

Rev 1881 | Details | Compare with Previous | 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;
306 jp_milcent 11
	private ArrayList<String> deboguages = null;
156 jp_milcent 12
	private ArrayList<Object> donnees = null;
13
 
133 jpm 14
	public Information() {
306 jp_milcent 15
		donnees = new ArrayList<Object>();
133 jpm 16
		messages = new ArrayList<String>();
306 jp_milcent 17
		deboguages = new ArrayList<String>();
133 jpm 18
	}
156 jp_milcent 19
 
20
	public Information(String t) {
188 jp_milcent 21
		donnees = new ArrayList<Object>();
22
		messages = new ArrayList<String>();
306 jp_milcent 23
		deboguages = new ArrayList<String>();
156 jp_milcent 24
		type = t;
25
	}
133 jpm 26
 
27
	public Information(String t, String m) {
188 jp_milcent 28
		donnees = new ArrayList<Object>();
133 jpm 29
		messages = new ArrayList<String>();
30
		messages.add(m);
306 jp_milcent 31
		deboguages = new ArrayList<String>();
133 jpm 32
		type = t;
33
	}
153 jpm 34
 
35
	public Information(String t, JSONArray jsonArray) {
188 jp_milcent 36
		donnees = new ArrayList<Object>();
153 jpm 37
		messages = new ArrayList<String>();
38
		for(int i = 0 ; i < jsonArray.size() ; i++) {
39
			if (jsonArray.get(i).isString() != null) {
40
				messages.add(jsonArray.get(i).isString().stringValue());
41
			}
42
		}
306 jp_milcent 43
		deboguages = new ArrayList<String>();
153 jpm 44
		type = t;
45
	}
133 jpm 46
 
156 jp_milcent 47
	public Information(String t, Object o) {
48
		donnees = new ArrayList<Object>();
49
		donnees.add(o);
306 jp_milcent 50
		messages = new ArrayList<String>();
51
		deboguages = new ArrayList<String>();
156 jp_milcent 52
		type = t;
53
	}
54
 
55
 
133 jpm 56
	public void setType(String t) {
57
		type = t;
58
	}
59
	public String getType() {
60
		return type;
61
	}
62
 
63
	public void setMessage(String message) {
64
		messages.add(message);
65
	}
66
	public String getMessage(int index) {
67
		return messages.get(index);
68
	}
69
	public ArrayList<String> getMessages() {
70
		return messages;
71
	}
156 jp_milcent 72
 
306 jp_milcent 73
	public void setDeboguage(String messageDeboguage) {
74
		deboguages.add(messageDeboguage);
75
	}
76
	public void setDeboguages(JSONArray jsonArray) {
77
		for(int i = 0 ; i < jsonArray.size() ; i++) {
78
			if (jsonArray.get(i).isString() != null) {
79
				deboguages.add(jsonArray.get(i).isString().stringValue());
80
			}
81
		}
82
	}
83
	public String getDeboguage(int index) {
84
		return deboguages.get(index);
85
	}
86
	public ArrayList<String> getDeboguages() {
87
		return deboguages;
88
	}
89
 
156 jp_milcent 90
	public void setDonnee(Object objet) {
91
		donnees.add(objet);
92
	}
188 jp_milcent 93
	public void setDonnee(int index, Object objet) {
94
		if (objet != null) {
95
			donnees.add(index, objet);
96
		}
97
	}
156 jp_milcent 98
	public Object getDonnee(int index) {
188 jp_milcent 99
		try {
100
			return donnees.get(index);
101
		} catch (Exception e) {
102
			return null;
103
		}
156 jp_milcent 104
	}
105
	public ArrayList<Object> getDonnees() {
106
		return donnees;
107
	}
133 jpm 108
 
109
	public String toString() {
110
		String chaine = new String();
156 jp_milcent 111
		if (messages != null) {
930 jpm 112
			for (int i = 0 ; i < messages.size() ; i++) {
156 jp_milcent 113
				// GXT ne prend pas en compte /n ou /r/n...
114
				chaine += getMessage(i)+"\n";
115
			}
133 jpm 116
		}
117
		return chaine;
118
	}
119
}