package org.josast.ModuleSoundModem;

import java.util.logging.Logger;

import org.josast.property.CONFIG;
import org.josast.property.ConfigObject;

/**
 * @author Christophe
 *
 */
public class SoundModemConfiguration extends ConfigObject {

	private Logger log = Logger.getLogger(getClass().getName());

	private String IPadress = "localhost";
	private int port = 8100;

	protected CONFIG ConfigFile = CONFIG.getInstance();

	public SoundModemConfiguration(String configFilename) {
		super(configFilename);
		// vérifie si la propriété est dans le fichier
		String temp = ConfigFile.GetProperty("IPadress");
		
		if (temp == null) {
			// config file not initialised
			ConfigFile.SetProperty("IPadress", IPadress);
			ConfigFile.SetProperty("port", "" + port);
			log.severe("properties file not initialised - a file is created with properties with defaults value");
			System.out.println("config file does not content required properties \n the file " + configFilename
					+ " has been set up with properties to configure");

		} else {
			IPadress = temp;
			String portString = ConfigFile.GetProperty("port");
			port = Integer.parseInt(portString);
		}

	}

	public String getIPadress() {
		return IPadress;
	}

	public void setIPadress(String iPadress) {
		IPadress = iPadress;
	}

	public int getPort() {
		return port;
	}

	public void setPort(int port) {
		this.port = port;
	}

	public String toString() {
		return IPadress + ":" + port;
	}

}
