Subversion Repositories eFlore/Applications.coel

Rev

Rev 306 | Rev 1415 | 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<String> deboguages = null;
        private ArrayList<Object> donnees = null;
        
        public Information() {
                donnees = new ArrayList<Object>();
                messages = new ArrayList<String>();
                deboguages = new ArrayList<String>();
        }

        public Information(String t) {
                donnees = new ArrayList<Object>();
                messages = new ArrayList<String>();
                deboguages = new ArrayList<String>();
                type = t;
        }
        
        public Information(String t, String m) {
                donnees = new ArrayList<Object>();
                messages = new ArrayList<String>();
                messages.add(m);
                deboguages = new ArrayList<String>();
                type = t;
        }
        
        public Information(String t, JSONArray jsonArray) {
                donnees = new ArrayList<Object>();
                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());
                        }
                }
                deboguages = new ArrayList<String>();
                type = t;
        }

        public Information(String t, Object o) {
                donnees = new ArrayList<Object>();
                donnees.add(o);
                messages = new ArrayList<String>();
                deboguages = new ArrayList<String>();
                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 setDeboguage(String messageDeboguage) {
                deboguages.add(messageDeboguage);
        }
        public void setDeboguages(JSONArray jsonArray) {
                for(int i = 0 ; i < jsonArray.size() ; i++) {
                        if (jsonArray.get(i).isString() != null) {
                                deboguages.add(jsonArray.get(i).isString().stringValue());
                        }
                }
        }
        public String getDeboguage(int index) {
                return deboguages.get(index);
        }
        public ArrayList<String> getDeboguages() {
                return deboguages;
        }
        
        public void setDonnee(Object objet) {
                donnees.add(objet);
        }
        public void setDonnee(int index, Object objet) {
                if (objet != null) {
                        donnees.add(index, objet);
                }
        }
        public Object getDonnee(int index) {
                try {
                        return donnees.get(index);
                } catch (Exception e) {
                        return null;
                }
        }
        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;
        }
}