本文整理汇总了Java中org.apache.commons.httpclient.util.URIUtil.encodeQuery方法的典型用法代码示例。如果您正苦于以下问题:Java URIUtil.encodeQuery方法的具体用法?Java URIUtil.encodeQuery怎么用?Java URIUtil.encodeQuery使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.httpclient.util.URIUtil
的用法示例。
在下文中一共展示了URIUtil.encodeQuery方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildQueryString
import org.apache.commons.httpclient.util.URIUtil; //导入方法依赖的package包/类
private String buildQueryString() {
final StringBuilder urlBuilder = new StringBuilder(RESOURCE_URL);
try {
urlBuilder.append("?code=");
urlBuilder.append(this.pinCode);
urlBuilder.append("&client_id=");
urlBuilder.append(this.clientId);
urlBuilder.append("&client_secret=");
urlBuilder.append(this.clientSecret);
urlBuilder.append("&grant_type=authorization_code");
return URIUtil.encodeQuery(urlBuilder.toString());
} catch (final Exception e) {
throw new NestException(e);
}
}
示例2: buildQueryString
import org.apache.commons.httpclient.util.URIUtil; //导入方法依赖的package包/类
private String buildQueryString() {
final StringBuilder urlBuilder = new StringBuilder(RESOURCE_URL);
urlBuilder.append("?access_token=");
urlBuilder.append(this.accessToken);
urlBuilder.append("&scale=max");
urlBuilder.append("&date_end=last");
urlBuilder.append("&device_id=");
urlBuilder.append(this.deviceId);
if (this.moduleId != null) {
urlBuilder.append("&module_id=");
urlBuilder.append(this.moduleId);
}
urlBuilder.append("&type=");
for (final Iterator<String> i = this.measures.iterator(); i.hasNext();) {
urlBuilder.append(i.next());
if (i.hasNext()) {
urlBuilder.append(",");
}
}
try {
return URIUtil.encodeQuery(urlBuilder.toString());
} catch (final URIException e) {
throw new NetatmoException(e);
}
}
示例3: createR2ClientLimiterKey
import org.apache.commons.httpclient.util.URIUtil; //导入方法依赖的package包/类
/**
* Convert D2 URL template into a string used for throttling limiter
*
* Valid:
* d2://host/${resource-id}
*
* Invalid:
* d2://host${resource-id}, because we cannot differentiate the host
*/
public static String createR2ClientLimiterKey(Config config) {
String urlTemplate = config.getString(HttpConstants.URL_TEMPLATE);
try {
String escaped = URIUtil.encodeQuery(urlTemplate);
URI uri = new URI(escaped);
if (uri.getHost() == null)
throw new RuntimeException("Cannot get host part from uri" + urlTemplate);
String key = uri.getScheme() + "/" + uri.getHost();
if (uri.getPort() > 0) {
key = key + "/" + uri.getPort();
}
log.info("Get limiter key [" + key + "]");
return key;
} catch (Exception e) {
throw new RuntimeException("Cannot create R2 limiter key", e);
}
}
示例4: lookup
import org.apache.commons.httpclient.util.URIUtil; //导入方法依赖的package包/类
public Location lookup(@Named("Description") String description) {
final GetMethod get = new GetMethod(BASEURL + MODE);
try {
final String query = URIUtil.encodeQuery("?address=" + description + "&sensor=false");
get.setQueryString(query);
httpclient.executeMethod(get);
final String xml = get.getResponseBodyAsString();
final SAXBuilder builder = new SAXBuilder();
Document doc = builder.build(new StringReader(xml));
Element root = doc.getRootElement();
String lat = root.getChild("result").getChild("geometry").getChild("location").getChildTextTrim("lat");
String lon = root.getChild("result").getChild("geometry").getChild("location").getChildTextTrim("lng");
return Location.fromString(lat + ";" + lon);
} catch (Exception ex) {
return null;
}
}
示例5: buildQueryString
import org.apache.commons.httpclient.util.URIUtil; //导入方法依赖的package包/类
private String buildQueryString() {
final StringBuilder urlBuilder = new StringBuilder(RESOURCE_URL);
try {
urlBuilder.append("?code=");
urlBuilder.append(this.pinCode);
urlBuilder.append("&client_id=");
urlBuilder.append(this.clientId);
urlBuilder.append("&client_secret=");
urlBuilder.append(this.clientSecret);
urlBuilder.append("&grant_type=authorization_code");
return URIUtil.encodeQuery(urlBuilder.toString());
} catch (final Exception e) {
throw new NestException(e);
}
}
示例6: buildQueryString
import org.apache.commons.httpclient.util.URIUtil; //导入方法依赖的package包/类
private String buildQueryString() {
final StringBuilder urlBuilder = new StringBuilder(RESOURCE_URL);
try {
urlBuilder.append("?auth=");
urlBuilder.append(this.accessToken);
return URIUtil.encodeQuery(urlBuilder.toString());
} catch (final Exception e) {
throw new NestException(e);
}
}
示例7: buildQueryString
import org.apache.commons.httpclient.util.URIUtil; //导入方法依赖的package包/类
private String buildQueryString() {
final StringBuilder urlBuilder = new StringBuilder(RESOURCE_URL);
try {
urlBuilder.append("?grant_type=ecobeePin");
urlBuilder.append("&code=");
urlBuilder.append(authToken);
urlBuilder.append("&client_id=");
urlBuilder.append(appKey);
return URIUtil.encodeQuery(urlBuilder.toString());
} catch (final Exception e) {
throw new EcobeeException(e);
}
}
示例8: buildQueryString
import org.apache.commons.httpclient.util.URIUtil; //导入方法依赖的package包/类
private String buildQueryString() {
final StringBuilder urlBuilder = new StringBuilder(RESOURCE_URL);
try {
urlBuilder.append("?grant_type=refresh_token");
urlBuilder.append("&code=");
urlBuilder.append(refreshToken);
urlBuilder.append("&client_id=");
urlBuilder.append(appKey);
return URIUtil.encodeQuery(urlBuilder.toString());
} catch (final Exception e) {
throw new EcobeeException(e);
}
}
示例9: buildQueryString
import org.apache.commons.httpclient.util.URIUtil; //导入方法依赖的package包/类
private String buildQueryString() {
final StringBuilder urlBuilder = new StringBuilder(RESOURCE_URL);
try {
urlBuilder.append("?json=");
urlBuilder.append(JSON.writeValueAsString(this));
return URIUtil.encodeQuery(urlBuilder.toString());
} catch (final Exception e) {
throw new EcobeeException(e);
}
}
示例10: buildQueryString
import org.apache.commons.httpclient.util.URIUtil; //导入方法依赖的package包/类
private String buildQueryString() {
final StringBuilder urlBuilder = new StringBuilder(RESOURCE_URL);
try {
urlBuilder.append("?json=true&token=");
urlBuilder.append(this.accessToken);
return URIUtil.encodeQuery(urlBuilder.toString());
} catch (final Exception e) {
throw new EcobeeException(e);
}
}
示例11: buildQueryString
import org.apache.commons.httpclient.util.URIUtil; //导入方法依赖的package包/类
private String buildQueryString() {
final StringBuilder urlBuilder = new StringBuilder(RESOURCE_URL);
try {
urlBuilder.append("?response_type=ecobeePin");
urlBuilder.append("&client_id=");
urlBuilder.append(appKey);
urlBuilder.append("&scope=");
urlBuilder.append(scope);
return URIUtil.encodeQuery(urlBuilder.toString());
} catch (final Exception e) {
throw new EcobeeException(e);
}
}
示例12: getInfo
import org.apache.commons.httpclient.util.URIUtil; //导入方法依赖的package包/类
@GET
@Path("rdfinfo")
@Produces(MediaType.APPLICATION_JSON)
public Collection<RdfInfo> getInfo() throws JSONException {
String query = ResourceHelper.GetResourceAsString("/resources/evidence/sparql/info.sparql");
String uriQuery = null;
String sparqlEndpoint = this.env.getRequiredProperty("sparql.endpoint");
query = sparqlEndpoint + query;
try {
uriQuery = URIUtil.encodeQuery(query);
} catch (URIException e) {
// TODO Auto-generated catch block
log.error(whitelist(e));
}
uriQuery = uriQuery + "&format=application%2Fsparql-results%2Bjson";
List<RdfInfo> infoOnSources = new ArrayList<RdfInfo>();
JSONArray lineItems = readJSONFeed(uriQuery);
for (int i = 0; i < lineItems.length(); ++i) {
JSONObject tempItem = lineItems.getJSONObject(i);
JSONObject tempSource = tempItem.getJSONObject("sourceDocument");
String source = tempSource.getString("value");
RdfInfo info = new RdfInfo();
info.sourceDocument = source;
infoOnSources.add(info);
}
return infoOnSources;
}
示例13: getLinkout
import org.apache.commons.httpclient.util.URIUtil; //导入方法依赖的package包/类
@GET
@Path("linkoutdata/{linkout}")
@Produces(MediaType.APPLICATION_JSON)
public Collection<LinkoutData> getLinkout(@PathParam("linkout") String linkout) throws JSONException, IOException {
String expandedURL = URIUtil.decode(linkout);
expandedURL = expandUrl(expandedURL);
expandedURL = URIUtil.decode(expandedURL);;
expandedURL = URIUtil.encodeQuery(expandedURL);
List<LinkoutData> infoOnLinkout = new ArrayList<LinkoutData>();
JSONArray lineItems = readJSONFeed(expandedURL);
for (int i = 0; i < lineItems.length(); ++i) {
JSONObject tempItem = lineItems.getJSONObject(i);
JSONObject tempSource = tempItem.getJSONObject("an");
String source = tempSource.getString("value");
LinkoutData info = new LinkoutData();
info.an = source;
tempSource = tempItem.getJSONObject("body");
source = tempSource.getString("value");
info.body = source;
tempSource = tempItem.getJSONObject("target");
source = tempSource.getString("value");
info.target = source;
tempSource = tempItem.getJSONObject("sourceURL");
source = tempSource.getString("value");
info.sourceURL = source;
tempSource = tempItem.getJSONObject("selector");
source = tempSource.getString("value");
info.selector = source;
tempSource = tempItem.getJSONObject("spl");
source = tempSource.getString("value");
info.spl = source;
tempSource = tempItem.getJSONObject("text");
source = tempSource.getString("value");
info.text = source;
infoOnLinkout.add(info);
}
return infoOnLinkout;
}
示例14: encodeUserName
import org.apache.commons.httpclient.util.URIUtil; //导入方法依赖的package包/类
private String encodeUserName(String username) {
try {
return URIUtil.encodeQuery(username, "UTF-8");
// return URIUtil.encodeQuery(username, "ISO-8859-1");
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例15: getHarDetailsURL
import org.apache.commons.httpclient.util.URIUtil; //导入方法依赖的package包/类
public String getHarDetailsURL(final String harName) {
try {
return URIUtil.encodeQuery(targetURL + "/details?label=" + harName);
} catch (URIException e) {
return null;
}
}