FileDocCategorySizeDatePackage
HttpQueryParams.javaAPI DocAndroid 1.5 API1984Wed May 06 22:41:16 BST 2009com.google.wireless.gdata.client

HttpQueryParams

public class HttpQueryParams extends QueryParams
A concrete implementation of QueryParams that uses the encodeUri method of a GDataClient (passed in at construction time) to URL encode parameters. This implementation maintains the order of parameters, which is useful for testing. Instances of this class are not thread safe.

Fields Summary
private GDataClient
client
private Hashtable
params
private Vector
names
Constructors Summary
public HttpQueryParams(GDataClient client)
Constructs a new, empty HttpQueryParams.

param
client GDataClient whose encodeUri method is used for URL encoding.

    this.client = client;
    // We expect most queries to have a relatively small number of parameters.
    names = new Vector(4);
    params = new Hashtable(7);
  
Methods Summary
public voidclear()

    names.removeAllElements();
    params.clear();
  
public java.lang.StringgenerateQueryUrl(java.lang.String feedUrl)

    StringBuffer url = new StringBuffer(feedUrl);
    url.append(feedUrl.indexOf('?") >= 0 ? '&" : '?");

    for (int i = 0; i < names.size(); i++) {
      if (i > 0) {
        url.append('&");
      }
      String name = (String) names.elementAt(i);
      url.append(client.encodeUri(name)).append('=");
      url.append(client.encodeUri(getParamValue(name)));
    }
    return url.toString();
  
public java.lang.StringgetParamValue(java.lang.String param)

    return (String) params.get(param);
  
public voidsetParamValue(java.lang.String param, java.lang.String value)

    if (value != null) {
      if (!params.containsKey(param)) {
        names.addElement(param);
      }
      params.put(param, value);
    } else {
      if (params.remove(param) != null) {
        names.removeElement(param);
      }
    }