Build a URI query string, from a list of Name/Value pairs. This version of the method is useful when the order of the parameters needs to be preserved. The resulting query will not be encoded, so it is suitable to be appended to a URI string. If the query will be passed to a multi-argument URI cons
(List<NameValuePair> parameters)
| 444 | * @return a #see {@link #encodeString(String)} |
| 445 | */ |
| 446 | public static String buildQuery(List<NameValuePair> parameters) { |
| 447 | StringBuffer query = new StringBuffer(); |
| 448 | Iterator<NameValuePair> i = parameters.iterator(); |
| 449 | while(i.hasNext()) { |
| 450 | NameValuePair nvp = i.next(); |
| 451 | query.append(encodeEntities(nvp.getName())); |
| 452 | if (nvp.getValue() != null) { |
| 453 | query.append(URI.PARAMETER_SEPARATOR); |
| 454 | query.append(encodeEntities(nvp.getValue())); |
| 455 | } |
| 456 | query.append(URI.QUERY_SEPARATOR); |
| 457 | } |
| 458 | query.deleteCharAt(query.length() - 1); |
| 459 | return query.toString(); |
| 460 | } |
| 461 | |
| 462 | /** |
| 463 | * Utility method to build a query string from a hashtable of parameters. |
nothing calls this directly
no test coverage detected