/**
 * 
 */
package ch.ice.controller;

import java.io.File;
import java.io.IOException;

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

import ch.ice.controller.parser.ExcelParser;
import ch.ice.controller.interf.Parser;

/**
 * @author Oliver
 *
 */
public class MainController {

	
	public static void startMainController()
	{
		
		//startSearch();
		startExcelParser();
	}
	
	
	public static void startParser()
	{
		
	}
	
	public static void startSearch(){
		System.out.println("start test bing");
	
		String query = "emmi ";
		try {
		
			JSONArray results = BingSearchEngine.Search(query);
	 
			final int resultsLength = results.length();

			for (int i = 0; i < resultsLength; i++) {
				JSONObject   aResult = results.getJSONObject(i);
				System.out.println(aResult.get("Url"));
    
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	// Test purpose
	public static void startExcelParser(){
		Parser excelParser = new ExcelParser();
		
		try {
			excelParser.readFile(new File("posTest.xlsx"));
		} catch (IOException e) {
			System.out.println("File not found");
			e.printStackTrace();
		}
	}
	
	public static void startWriter()
	{
		
	}
	
	public static void startCrawler()
	{
		
	}
}

@@ -454,32 +454,35 @@
 %0A%09%7B%0D%0A%09%09%0D%0A%09%7D%0D%0A%09%0D%0A
+%09%0D%0A
 %09public static v
@@ -476,28 +476,30 @@
 blic static 
-void
+String
  startSearch
@@ -499,16 +499,28 @@
 tSearch(
+String query
 )%7B%0D%0A%09%09Sy
@@ -557,19 +557,16 @@
 ing%22);%0D%0A
-%09%0D%0A
 %09%09String
@@ -570,26 +570,25 @@
 ing 
-query = %22emmi %22
+url = null
 ;%0D%0A
+%09%09%0D%0A
 %09%09tr
@@ -594,21 +594,22 @@
 ry %7B%0D%0A%09%09
+%09
 %0D%0A%09%09
-%09
+ 
 JSONArra
@@ -657,15 +657,21 @@
 );%0D%0A
+%09/*
 %09 %0D%0A%09
-%09%09
+     
 fina
@@ -715,17 +715,19 @@
 );%0D%0A%0D%0A%09%09
-%09
+   
 for (int
@@ -762,19 +762,24 @@
 ++) %7B%0D%0A%09
-%09%09%09
+    %09   
 JSONObje
@@ -821,19 +821,24 @@
 t(i);%0D%0A%09
-%09%09%09
+        
 System.o
@@ -874,18 +874,158 @@
 );%0D%0A
+%09
     
+%7D
 %0D%0A%09
+      */ %0D%0A%09        JSONObject   JsonObj = results.getJSONObject(0); %0D%0A%09        %0D%0A%09         url = (String) JsonObj.get(%22Url%22);%0D%0A%09      %09%0D%0A%09
 %09%09
-%7D
 %0D%0A%09%09
@@ -1115,25 +1115,46 @@
 e();%0D%0A%09%09%7D%0D%0A%09
-%7D
+%09  return url;%0D%0A%09%09%7D%0D%0A%09
 %0D%0A%09%0D%0A%09// Tes

change in startsearch