/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package fr.gouv.finances.cp.xemelios.data;

import java.util.Vector;

/**
 *
 * @author chm
 */
public class ExportableData {
		public static final int LVL_DOC = 1;
		public static final int LVL_COL = 2;
		public static final int LVL_BUD = 3;
                public static final int TYPE_PERSO1 = 4;
                public static final int TYPE_PERSO2 = 5;
		public static final int LVL_FIC = 6; // 4 et 5 sont pris par les specialkey1 et specialKey2
		private String key;
		private String libelle;
		private int level;
		private boolean selected = false;
		private boolean deleted = false;
		private Vector<ExportableData> childs;
		
		public ExportableData () {			
			childs = new Vector<ExportableData>();
		}
		public ExportableData (String k, String li, int lv, boolean s, Vector<ExportableData> c) {
			setKey(k);
			setLibelle(li);
			setLevel(lv);
			setSelected(s);
			childs.addAll(c);
		}
		public String getKey() {
			return key;
		}
		public void setKey(String key) {
			this.key = key;
		}
		public int getLevel() {
			return level;
		}
		public void setLevel(int level) {
			this.level = level;
		}
		public String getLibelle() {
			return libelle;
		}
		public void setLibelle(String libelle) {
			this.libelle = libelle;
		}
		public boolean isSelected() {
			return selected;
		}
		public void setSelected(boolean selected) {
			this.selected = selected;
		}
		public Vector<ExportableData> getChilds() {
			return childs;
		}
		public void setChilds(Vector<ExportableData> childs) {
			this.childs = childs;
		}
		public void addChild (ExportableData d) {
			this.childs.add(d);
		}
		public ExportableData getChild(int i) {
			if (i<childs.size()) return childs.get(i);
			else return null;
		}
		public ExportableData getChild(String k) {
			for (ExportableData c:childs) {
				if (c.getKey().equals(k)) return c;
			}
			return null;
		}
		public String toString () { return libelle; }
/*		public String toString () {
			String ret = "";
			for (int i=0; i<level; i++) ret+= "\t";
			ret += libelle+(selected?" selected ":" none ")+"\n";
			for (Data dd:childs) {
				ret += dd.toString();
			}
			return ret;
		}
*/		public boolean isDeleted() {
			return deleted;
		}
		public void setDeleted(boolean deleted) {
			this.deleted = deleted;
		}

}
