Subversion Repositories eFlore/Applications.coel

Rev

Rev 153 | Rev 188 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

package org.tela_botanica.client.modeles;

import java.util.ArrayList;

import com.google.gwt.json.client.JSONArray;

public class Information {
        
        private String type = null;
        private ArrayList<String> messages = null;
        private ArrayList<Object> donnees = null;
        
        public Information() {
                messages = new ArrayList<String>();
        }

        public Information(String t) {
                type = t;
        }
        
        public Information(String t, String m) {
                messages = new ArrayList<String>();
                messages.add(m);
                type = t;
        }
        
        public Information(String t, JSONArray jsonArray) {
                messages = new ArrayList<String>();
                for(int i = 0 ; i < jsonArray.size() ; i++) {
                        if (jsonArray.get(i).isString() != null) {
                                messages.add(jsonArray.get(i).isString().stringValue());
                        }
                }
                type = t;
        }

        public Information(String t, Object o) {
                donnees = new ArrayList<Object>();
                donnees.add(o);
                type = t;
        }
        

        public void setType(String t) {
                type = t;
        }
        public String getType() {
                return type;
        }
        
        public void setMessage(String message) {
                messages.add(message);
        }
        public String getMessage(int index) {
                return messages.get(index);
        }
        
        public ArrayList<String> getMessages() {
                return messages;
        }
        
        public void setDonnee(Object objet) {
                donnees.add(objet);
        }
        public Object getDonnee(int index) {
                return donnees.get(index);
        }
        
        public ArrayList<Object> getDonnees() {
                return donnees;
        }

        public String toString() {
                String chaine = new String();
                if (messages != null) {
                        for(int i = 0 ; i < messages.size() ; i++) {
                                // GXT ne prend pas en compte /n ou /r/n...
                                chaine += getMessage(i)+"\n";
                        }
                }
                return chaine;
        }
}