/**
 * 
 * <b>Description : used for demonstration to the config package.
 * 	see main to understand how to used the AbstactDataBinding. </b>
 * <br> 
 * 
 * 
 * <p>Projet : JOSAST <BR>
 * 
 * <br>
 * <b>JOSAST</b> : Java Open Source Amateur Satellite  Toolbox 
 * <br>The aim of the project is to create a set of tools for amateur satellite purpose. All this tools could be used together to create specific software.
 * <b>JOSAST</b> project is managed by AVMDTI (<A HREF="http://www.avmdti.org">http://www.avmdti.org </a> )
 * <br> This software is an open source software. Please read the <b><i>JOSAST licence</b></i><BR>(<A HREF="http://www.avmdti.org">http://www.avmdti.org </a> )
 * <p>for more information contact <a href="mailto:josast@avmdti.org">josast@avmdti.org</a></p>
 * @author  <a href="mailto:mercier.josast@avmdti.org">mercier</a>
 * @version 1.0
 * <p><b><i> Source Update </b></i></p>
 * <br> Version : date 		: name 		: comments 
 * <br> V1      : 3 mars 2004	: C. Mercier 	: create file
 * <p>
 */
package org.josast.config.databinding;

import java.io.File;
import java.util.Vector;

/**
 * 
 * <b>Description : </b> 
 * 
 * 
 * <p>Projet : JOSAST <BR>
 * 
 * <br>
 * <b>JOSAST</b> : Java Open Source Amateur Satellite  Toolbox 
 * <br>The aim of the project is to create a set of tools for amateur satellite purpose. All this tools could be used together to create specific software.
 * <b>JOSAST</b> project is managed by AVMDTI (<A HREF="http://www.avmdti.org">http://www.avmdti.org </a> )
 * <br> This software is an open source software. Please read the <b><i>JOSAST licence</b></i><BR>(<A HREF="http://www.avmdti.org">http://www.avmdti.org </a> )
 * <p>for more information contact <a href="mailto:josast@avmdti.org">josast@avmdti.org</a></p>
 * @author  <a href="mailto:mercier.josast@avmdti.org">mercier</a>
 * @version 1.0
 * <p><b><i> Source Update </b></i></p>
 * <br> Version : date 		: name 		: comments 
 * <br> V1      : 3 mars 2004	: C. Mercier 	: create file
 * <br> V2 		: 01 mai 2019   :	C. Mercier 	: Change log system
 * <p>

 */

public class ConfigurationdataBindingDemo extends AbstractDataBinding {

	private static final long serialVersionUID = -9045143058463814039L;
	private double version = 1.0;
	private String name = null;
	private Vector<String> V = new Vector<String>();
	private String directory = new String("C:\\temp");
	
	
	private ConfigurationdataBindingDemo()
	{
		
	}
	
/**
 * This method return an instance of the class. 
 * If the configuration file exist, the function return an object from the configuration file
 * else the function return a default object.
 * @return an instance of the class.
 */
public static ConfigurationdataBindingDemo getInstance()
	{
		// create a default object
		ConfigurationdataBindingDemo t = new ConfigurationdataBindingDemo();
		// test if the file exist
		// TODO : A REVOIR
		File f = new File(t.getDirectory());
	
		if (!f.exists())
		{
			f.mkdir();
		}
		t.setFolder(t.getDirectory());
		if (t.isExist())
			{
				// load the object
				 t = (ConfigurationdataBindingDemo) t.load();
			}
		// return the object	
		return t;
		}
	
	
	/** 
	 * display Vector data and also name of the class and version. <br>
	 * 
	 * @see java.lang.Object#toString()
	 */
	public String toString()
	{
		return this.V.toString()+name+version;
	}

	
	/**
	 * @return field name.
	 */
	public String getName() {
		return name;
	}

	/**
	 * @return field vector
	 */
	public Vector<String> getV() {
		return V;
	}

	/**
	 * @return field version
	 */
	public double getVersion() {
		return version;
	}

	/**
	 * set field name.
	 * 
	 * @param string 
	 */
	public void setName(String string) {
		name = string;
	}

	/**
	 * set a vector
	 * 
	 * @param vector
	 */
	public void setV(Vector<String> vector) {
		V = vector;
	}

	/**
	 * set version.
	 * 
	 * @param d
	 */
	public void setVersion(double d) {
		version = d;
	}
	
	


	public void setDirectory(String directory) {
		this.directory = directory;
	}


	public String getDirectory() {
		return directory;
	}
	
	/**
	 * D�monstration :
	 * 	- cr�ation d'un objet
	 * 	- modification des param�tres de l'objet
	 *  - sauvegarde
	 *  - lecture
	 * 
	 * 
	 * @param Strings non utilis�
	 */
	public static void main(String[] Strings)
		{
			Vector<String> v = new Vector<String>();
			v.add("�lement 1");
			v.add("�l�ment 2");
			v.add("�l�ment 3");
			ConfigurationdataBindingDemo t = getInstance();
			
			System.out.println("First Load"+t);
			t.setName("d�monstration du fichier");
			t.setVersion(1.3);
			t.setV(v);
			System.out.println("avant sauvegarde"+t);
			t.save();
			t=new ConfigurationdataBindingDemo();
			System.out.println("a la cr�ation"+t);
			t = (ConfigurationdataBindingDemo)t.load();	
			System.out.println("apr�s sauvegarde"+t);

		}

}
