本文整理汇总了Java中org.xutils.http.RequestParams.getUri方法的典型用法代码示例。如果您正苦于以下问题:Java RequestParams.getUri方法的具体用法?Java RequestParams.getUri怎么用?Java RequestParams.getUri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.xutils.http.RequestParams
的用法示例。
在下文中一共展示了RequestParams.getUri方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildCacheKey
import org.xutils.http.RequestParams; //导入方法依赖的package包/类
/**
* 根据注解的cacheKeys构建缓存的自定义key,
* 如果返回null, 默认使用 url 和整个 query string 组成.
*
* @param params
* @param cacheKeys
* @return
*/
@Override
public String buildCacheKey(RequestParams params, String[] cacheKeys) {
String cacheKey = null;
if (cacheKeys != null && cacheKeys.length > 0) {
cacheKey = params.getUri() + "?";
// 添加cacheKeys对应的参数
for (String key : cacheKeys) {
String value = params.getStringParameter(key);
if (value != null) {
cacheKey += key + "=" + value + "&";
}
}
}
return cacheKey;
}
示例2: getUriRequest
import org.xutils.http.RequestParams; //导入方法依赖的package包/类
public static UriRequest getUriRequest(RequestParams params, Type loadType) throws Throwable {
// get scheme
String scheme = null;
String uri = params.getUri();
int index = uri.indexOf(":");
if (index > 0) {
scheme = uri.substring(0, index);
} else if (uri.startsWith("/")) {
scheme = "file";
}
// get UriRequest
if (!TextUtils.isEmpty(scheme)) {
Class<? extends UriRequest> cls = SCHEME_CLS_MAP.get(scheme);
if (cls != null) {
Constructor<? extends UriRequest> constructor
= cls.getConstructor(RequestParams.class, Class.class);
return constructor.newInstance(params, loadType);
} else {
if (scheme.startsWith("http")) {
return new HttpRequest(params, loadType);
} else if (scheme.equals("assets")) {
return new AssetsRequest(params, loadType);
} else if (scheme.equals("file")) {
return new LocalFileRequest(params, loadType);
} else {
throw new IllegalArgumentException("The url not be support: " + uri);
}
}
} else {
throw new IllegalArgumentException("The url not be support: " + uri);
}
}
示例3: buildQueryUrl
import org.xutils.http.RequestParams; //导入方法依赖的package包/类
@Override
protected String buildQueryUrl(RequestParams params) {
String uri = params.getUri();
StringBuilder queryBuilder = new StringBuilder(uri);
if (!uri.contains("?")) {
queryBuilder.append("?");
} else if (!uri.endsWith("?")) {
queryBuilder.append("&");
}
List<KeyValue> queryParams = params.getQueryStringParams();
if (queryParams != null) {
for (KeyValue kv : queryParams) {
String name = kv.key;
String value = kv.getValueStr();
if (!TextUtils.isEmpty(name) && value != null) {
queryBuilder.append(
Uri.encode(name, params.getCharset()))
.append("=")
.append(Uri.encode(value, params.getCharset()))
.append("&");
}
}
}
if (queryBuilder.charAt(queryBuilder.length() - 1) == '&') {
queryBuilder.deleteCharAt(queryBuilder.length() - 1);
}
if (queryBuilder.charAt(queryBuilder.length() - 1) == '?') {
queryBuilder.deleteCharAt(queryBuilder.length() - 1);
}
return queryBuilder.toString();
}
示例4: buildQueryUrl
import org.xutils.http.RequestParams; //导入方法依赖的package包/类
protected String buildQueryUrl(RequestParams params) {
return params.getUri();
}