当前位置: 首页>>代码示例>>Java>>正文


Java URIUtil.encodeQuery方法代码示例

本文整理汇总了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);
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:17,代码来源:AccessTokenRequest.java

示例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);
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:27,代码来源:MeasurementRequest.java

示例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);
  }
}
 
开发者ID:apache,项目名称:incubator-gobblin,代码行数:29,代码来源:HttpUtils.java

示例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;
        }
	}
 
开发者ID:IUSISProyecto,项目名称:IUSIS,代码行数:21,代码来源:LocationLookupService.java

示例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);
    }
}
 
开发者ID:openhab,项目名称:openhab1-addons,代码行数:17,代码来源:AccessTokenRequest.java

示例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);
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:12,代码来源:DataModelRequest.java

示例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);
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:15,代码来源:TokenRequest.java

示例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);
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:15,代码来源:RefreshTokenRequest.java

示例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);
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:12,代码来源:ThermostatRequest.java

示例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);
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:12,代码来源:UpdateThermostatRequest.java

示例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);
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:15,代码来源:AuthorizeRequest.java

示例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;
 }
 
开发者ID:OHDSI,项目名称:WebAPI,代码行数:30,代码来源:SparqlService.java

示例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;
 }
 
开发者ID:OHDSI,项目名称:WebAPI,代码行数:41,代码来源:SparqlService.java

示例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);
	}
}
 
开发者ID:ImmobilienScout24,项目名称:restapi-java-sdk,代码行数:10,代码来源:IS24ApiImpl.java

示例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;
    }
}
 
开发者ID:atinfo,项目名称:at.info-knowledge-base,代码行数:8,代码来源:HarStorage.java


注:本文中的org.apache.commons.httpclient.util.URIUtil.encodeQuery方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。