本文整理了Java中com.github.kevinsawicki.http.HttpRequest.addParam()
方法的一些代码示例,展示了HttpRequest.addParam()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpRequest.addParam()
方法的具体详情如下:
包路径:com.github.kevinsawicki.http.HttpRequest
类名称:HttpRequest
方法名:addParam
暂无
代码示例来源:origin: com.github.kevinsawicki/http-request
/**
* Append given name/value pairs as query parameters to the base URL
* <p>
* The params argument is interpreted as a sequence of name/value pairs so the
* given number of params must be divisible by 2.
*
* @param url
* @param params
* name/value pairs
* @return URL with appended query params
*/
public static String append(final CharSequence url, final Object... params) {
final String baseUrl = url.toString();
if (params == null || params.length == 0)
return baseUrl;
if (params.length % 2 != 0)
throw new IllegalArgumentException(
"Must specify an even number of parameter names/values");
final StringBuilder result = new StringBuilder(baseUrl);
addPathSeparator(baseUrl, result);
addParamPrefix(baseUrl, result);
addParam(params[0], params[1], result);
for (int i = 2; i < params.length; i += 2) {
result.append('&');
addParam(params[i], params[i + 1], result);
}
return result.toString();
}
代码示例来源:origin: tcking/GiraffePlayer2
/**
* Append given name/value pairs as query parameters to the base URL
* <p>
* The params argument is interpreted as a sequence of name/value pairs so the
* given number of params must be divisible by 2.
*
* @param url
* @param params
* name/value pairs
* @return URL with appended query params
*/
public static String append(final CharSequence url, final Object... params) {
final String baseUrl = url.toString();
if (params == null || params.length == 0)
return baseUrl;
if (params.length % 2 != 0)
throw new IllegalArgumentException(
"Must specify an even number of parameter names/values");
final StringBuilder result = new StringBuilder(baseUrl);
addPathSeparator(baseUrl, result);
addParamPrefix(baseUrl, result);
addParam(params[0], params[1], result);
for (int i = 2; i < params.length; i += 2) {
result.append('&');
addParam(params[i], params[i + 1], result);
}
return result.toString();
}
代码示例来源:origin: com.github.kevinsawicki/http-request
/**
* Append given map as query parameters to the base URL
* <p>
* Each map entry's key will be a parameter name and the value's
* {@link Object#toString()} will be the parameter value.
*
* @param url
* @param params
* @return URL with appended query params
*/
public static String append(final CharSequence url, final Map<?, ?> params) {
final String baseUrl = url.toString();
if (params == null || params.isEmpty())
return baseUrl;
final StringBuilder result = new StringBuilder(baseUrl);
addPathSeparator(baseUrl, result);
addParamPrefix(baseUrl, result);
Entry<?, ?> entry;
Iterator<?> iterator = params.entrySet().iterator();
entry = (Entry<?, ?>) iterator.next();
addParam(entry.getKey().toString(), entry.getValue(), result);
while (iterator.hasNext()) {
result.append('&');
entry = (Entry<?, ?>) iterator.next();
addParam(entry.getKey().toString(), entry.getValue(), result);
}
return result.toString();
}
代码示例来源:origin: tcking/GiraffePlayer2
/**
* Append given map as query parameters to the base URL
* <p>
* Each map entry's key will be a parameter name and the value's
* {@link Object#toString()} will be the parameter value.
*
* @param url
* @param params
* @return URL with appended query params
*/
public static String append(final CharSequence url, final Map<?, ?> params) {
final String baseUrl = url.toString();
if (params == null || params.isEmpty())
return baseUrl;
final StringBuilder result = new StringBuilder(baseUrl);
addPathSeparator(baseUrl, result);
addParamPrefix(baseUrl, result);
Entry<?, ?> entry;
Iterator<?> iterator = params.entrySet().iterator();
entry = (Entry<?, ?>) iterator.next();
addParam(entry.getKey().toString(), entry.getValue(), result);
while (iterator.hasNext()) {
result.append('&');
entry = (Entry<?, ?>) iterator.next();
addParam(entry.getKey().toString(), entry.getValue(), result);
}
return result.toString();
}
内容来源于网络,如有侵权,请联系作者删除!