<commit_before>package org.gmarz.googleplaces;

import java.util.AbstractSet;
import java.util.HashSet;

import org.apache.http.client.HttpClient;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;

import org.gmarz.googleplaces.models.DetailsResult;
import org.gmarz.googleplaces.models.PlacesResult;
import org.gmarz.googleplaces.query.Query;
import org.json.JSONException;
import org.json.JSONObject;

public class GooglePlaces {

	private String mApiKey = "";
	private AbstractSet<String> mSupportedPlaces;
	
	public GooglePlaces(String apiKey) {
		mApiKey = apiKey;
		loadSupportedPlaces();
	}
	
	public PlacesResult getPlaces(Query query) {
		JSONObject response = executeRequest(query.toString());
		PlacesResult result = null;
		
		try {
			result = new PlacesResult(response);
		} catch (JSONException e) {
			e.printStackTrace();
		}

		return result;
	}
	
	public DetailsResult getPlaceDetails(Query query) {
		JSONObject response = executeRequest(query.toString());
		DetailsResult result = null;
		
		try {
			result = new DetailsResult(response);
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return result;
	}

	public boolean isSupportedPlace(String placeType) {
		return (mSupportedPlaces.contains(placeType));
	}
	
	private JSONObject executeRequest(String query) {
		query += "key=" + mApiKey;
		
		HttpClient client = new DefaultHttpClient();
		HttpGet request = new HttpGet(query);

		ResponseHandler<String> handler = new BasicResponseHandler();<commit_msg>added parameter based methods for executing search queries<commit_after>package org.gmarz.googleplaces;

import java.util.AbstractSet;
import java.util.HashSet;
import java.util.List;

import org.apache.http.client.HttpClient;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;

import org.gmarz.googleplaces.models.DetailsResult;
import org.gmarz.googleplaces.models.PlacesResult;
import org.gmarz.googleplaces.query.DetailsQuery;
import org.gmarz.googleplaces.query.NearbySearchQuery;
import org.gmarz.googleplaces.query.Query;
import org.gmarz.googleplaces.query.SearchQuery;
import org.gmarz.googleplaces.query.TextSearchQuery;
import org.json.JSONException;
import org.json.JSONObject;

public class GooglePlaces {

	private String mApiKey = "";
	private AbstractSet<String> mSupportedPlaces;
	
	public GooglePlaces(String apiKey) {
		mApiKey = apiKey;
		loadSupportedPlaces();
	}
	
	public PlacesResult getPlaces(String keyword, int radius, double lat, double lon, List<String> types) {
		SearchQuery query = null;
		
		if (isSupportedPlace(keyword)) {
			query = new NearbySearchQuery(lat, lon);
		} else {
			query = new TextSearchQuery(keyword);
			query.setLocation(lat, lon);
		}
		
		if (types != null) {
			for(String type : types){
				query.addType(type);
			}
		}
		
		query.setRadius(radius);
		
		PlacesResult result = getPlaces(query);
		return result;
	}
	
	public PlacesResult getPlaces(String keyword, int radius, double lat, double lon) {
		return getPlaces(keyword, radius, lat, lon, null);
	}
	
	public PlacesResult getPlaces(Query query) {
		JSONObject response = executeRequest(query.toString());
		PlacesResult result = null;
		
		try {
			result = new PlacesResult(response);
		} catch (JSONException e) {
			e.printStackTrace();
		}

		return result;
	}
	
	public DetailsResult getPlaceDetails(String reference) {
		DetailsQuery query = new DetailsQuery(reference);
		DetailsResult result = getPlaceDetails(query);
		
		return result;
	}
	
	public DetailsResult getPlaceDetails(Query query) {
		JSONObject response = executeRequest(query.toString());
		DetailsResult result = null;
		
		try {
			result = new DetailsResult(response);
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return result;
	}

	public boolean isSupportedPlace(String placeType) {
		return (mSupportedPlaces.contains(placeType));
	}
	
	private JSONObject executeRequest(String query) {
		query += "key=" + mApiKey;
		
		HttpClient client = new DefaultHttpClient();
		HttpGet request = new HttpGet(query);

		ResponseHandler<String> handler = new BasicResponseHandler();
{'fraction_non_alphanumeric': 0.10130047912388775, 'fraction_numerical': 0.0, 'mean_word_length': 4.822045152722444, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5991416', 'n_tokens_mistral': 1453, 'n_tokens_neox': 1283, 'n_words': 297}