public class URLBuilder {
private StringBuffer mBuffer;
private boolean mHasParameters;
public URLBuilder(String base) {
mBuffer = new StringBuffer(base);
mHasParameters = false;
}
public void addParameter(String name, String value) {
if (mHasParameters == false) {
mBuffer.append('?');
mHasParameters = true;
} else
mBuffer.append('&');
mBuffer.append(name);
mBuffer.append('=');
mBuffer.append(value);
}
public String toString() {
return mBuffer.toString();
}
}
|