Back to project page android-google-places.
The source code is released under:
Copyright (c) 2012 Greg Marzouka Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Soft...
If you think the Android project android-google-places listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package org.gmarz.googleplaces.query; // w w w . j av a 2s. co m import java.util.ArrayList; import java.util.List; import org.apache.http.NameValuePair; import org.apache.http.message.BasicNameValuePair; class QueryBuilder { private List<NameValuePair> mParameters = new ArrayList<NameValuePair>(); public void addParameter(String name, String value) { removeParameter(name); mParameters.add(new BasicNameValuePair(name,value)); } public void removeParameter(String name) { if (mParameters.contains(name)) { mParameters.remove(name); } } public void clearParameters() { mParameters.clear(); } public String toString() { StringBuilder query = new StringBuilder(); NameValuePair parameter = null; query.append("?"); for(int i = 0; i < mParameters.size(); i++) { parameter = mParameters.get(i); query.append(parameter.getName()); query.append("="); query.append(parameter.getValue()); query.append("&"); } return encode(query.toString()); } private String encode(String query) { String encodedQuery = query.replace("|", "%7C"); encodedQuery = encodedQuery.replace(' ', '+'); return encodedQuery; } }