/**
 * 
 */
package com.ibm.vista.sqltrigger;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

import org.json.JSONArray;
import org.json.JSONObject;
import org.json.JSONException;

/**
 * @author Gerry Broennimann
 *
 */
public class ConfigMulti {

	public JSONObject[] db2configs = null;
	
	public ConfigMulti() {
		String string = "";
		
		try {
			// step 1: Load the configMulti.json file
			InputStream configStream = new FileInputStream("./config/configMulti.json");
			InputStreamReader configReader = new InputStreamReader(configStream);
			BufferedReader br = new BufferedReader(configReader);
			String line;
			while ((line = br.readLine()) != null) {
			    string += line + "\n";
			}
			JSONArray jsonArray = new JSONArray(string);
			
			// step 2: Read the configuration details
			this.db2configs = new JSONObject[jsonArray.length()];
			for (int i=0; i<jsonArray.length(); i++) {
				this.db2configs[i] = jsonArray.getJSONObject(i);
				//System.out.println(this.db2configs[i]);
			}
			br.close();			
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} catch (JSONException e) {
			e.printStackTrace();
		}
	}
}
