HttpQueryParamspublic 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.
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 void | clear()
names.removeAllElements();
params.clear();
| public java.lang.String | generateQueryUrl(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.String | getParamValue(java.lang.String param)
return (String) params.get(param);
| public void | setParamValue(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);
}
}
|
|