/*
 * Created on 27-Oct-2009
 *
 * TODO 
 */
package uk.ac.roe.wfau;

import java.io.InputStream;
import java.util.Properties;

import org.apache.log4j.Logger;

/**
 * @author mar
 *
 */
public class LoadWSAProperties {
    private static LoadWSAProperties singletonObject;
    
    public static Logger logger = Logger.getLogger("wsa.simple");
    
	/** A private Constructor prevents any other class from instantiating. */
	private LoadWSAProperties() {
	    
        
        
		//	 Optional Code
	    try {
	    InputStream inProp = getClass().getClassLoader().getResourceAsStream("WSA.properties");
	    
	    Properties properties = new Properties();
	
	    logger.info("loading WSA.properites");
           properties.load(inProp);
           WSASchema.ALLUKIDSSRDB=FormatLines.commaSeparatedStringToStringArray(properties.getProperty("ALLUKIDSSRDB").trim());
           WSASchema.UKIDSSVERSIONS=FormatLines.commaSeparatedStringToIntArray(properties.getProperty("UKIDSSVERSIONS").trim());
           WSASchema.UKIDSSDB=FormatLines.commaSeparatedStringToStringArray(properties.getProperty("UKIDSSDB").trim());
           WSASchema.WORLDDB=FormatLines.commaSeparatedStringToStringArray(properties.getProperty("WORLDDB").trim());
           WSASchema.WORLDVERSIONS=FormatLines.commaSeparatedStringToIntArray(properties.getProperty("WORLDVERSIONS").trim());
           WSASchema.SCEHMAVALIDDATABASES=FormatLines.commaSeparatedStringToStringArray(properties.getProperty("SCEHMAVALIDDATABASES").trim());
           try {
           QueryRetrieverThread.ROWSWRITTEN_UPPERLIMIT=Integer.parseInt(properties.getProperty("ROWSWRITTEN_UPPERLIMIT").trim());
           }
           catch (Exception e) {
            // TODO: handle exception
        }
        } catch (Exception e) {
            // TODO Auto-generated catch block
            logger.info("error in loading WSA.properites "+e);
            e.printStackTrace();
        }
        
	}
	public static synchronized  void getSingletonObject() {
	  //  logger.info ("SO "+singletonObject);
		if (singletonObject == null) {
			singletonObject = new LoadWSAProperties();
		}
		logger.info ("SOEX "+singletonObject);
	//	return singletonObject;
	}
	public Object clone() throws CloneNotSupportedException {
		throw new CloneNotSupportedException();
	}
}
