package com.acme.util; 

import java.lang.*;
import java.util.*;
import java.io.*;

/**
 * @author Selvan V. Rajan
 * @version 1.0 
 * 
 */

public class Parameters {

    private static String propertiesFilename = "com/acme/resources/acme.properties"; 

    protected static Properties properties = new Properties();

    static {
        getParameters();
    }
    
    private static void getParameters() {
        InputStream in = null;

        try {
            //in = new FileInputStream(propertiesFilename);
            in = Parameters.class.getClassLoader().
              getResourceAsStream(propertiesFilename);
            properties.load(in);
            System.out.println(propertiesFilename+" is loaded.");
                
    //            properties.list(System.out);
        } catch (java.io.FileNotFoundException e) {
            in = null;
            System.err.println("Can't find properties file. " + propertiesFilename +
                    "Using defaults.");
        } catch (java.io.IOException e) {
            System.err.println("Can't read properties file. " +
                    "Using defaults.");
        } finally {
            if (in != null) {
            try { in.close(); } catch (java.io.IOException e) { }
            in = null;
            }
        }
    }
    public static boolean getProperty(String key) {
        boolean retValue=false;
        String strValue=null;
        strValue = properties.getProperty(key);
        if (strValue != null && strValue.equalsIgnoreCase("true"))
            retValue = true;
        else
            retValue = false;
        return retValue;
    }
   public static String getSProperty(String key) {
        
        String retValue=null;
        retValue = properties.getProperty(key);
        return retValue;
    }
} 
