/**
 * 
 */
package calabash.java;

import java.util.HashMap;
import java.util.Map;

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

/**
 * 
 *
 */
public final class Application {

	private final Http http;

	public Application() {
		this.http = new Http(Config.endPoint());
	}

	public UIElements query(String query) throws CalabashException {
		JSONObject jsonObject = new JSONObject();
		jsonObject.put("query", query);

		Map<String, Object> map = new HashMap<String, Object>();
		map.put("method_name", "query");
		map.put("arguments", new String[0]);
		jsonObject.put("operation", map);

		String result = http.post("map", jsonObject.toString());
		JSONArray results;
		try {
			results = new JSONObject(result).getJSONArray("results");
		} catch (JSONException e) {
			throw new CalabashException("Result is not in expected format.\n"
					+ result, e);
		}

		return new UIElements(results, query);
	}
}

@@ -172,16 +172,45 @@
 %0A/**%0A * 
+Represents an iOS application
 %0A *%0A */%0A
@@ -971,11 +971,150 @@
 ery);%0A%09%7D
+%0A%0A%09/**%0A%09 * Kills the application%0A%09 * %0A%09 */%0A%09public void exit() %7B%0A%09%09try %7B%0A%09%09%09http.post(%22exit%22, %22%22);%0A%09%09%7D catch (CalabashException e) %7B%0A%09%09%7D%0A%09%7D
 %0A%7D%0A

Exit method to Application