Subversion Repositories eFlore/Applications.coel

Rev

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