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


Java URIUtil.decode方法代码示例

本文整理汇总了Java中org.apache.commons.httpclient.util.URIUtil.decode方法的典型用法代码示例。如果您正苦于以下问题:Java URIUtil.decode方法的具体用法?Java URIUtil.decode怎么用?Java URIUtil.decode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.httpclient.util.URIUtil的用法示例。


在下文中一共展示了URIUtil.decode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDecodedPath

import org.apache.commons.httpclient.util.URIUtil; //导入方法依赖的package包/类
/**
 * Parse and decode the path component from the given request.
 * @param request Http request to parse
 * @param servletName the name of servlet that precedes the path
 * @return decoded path component, null if UTF-8 is not supported
 */
public static String getDecodedPath(final HttpServletRequest request, String servletName) {
  try {
    return URIUtil.decode(getRawPath(request, servletName), "UTF-8");
  } catch (URIException e) {
    throw new AssertionError("JVM does not support UTF-8"); // should never happen!
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:14,代码来源:ServletUtil.java

示例2: testEncodeWithinQuery

import org.apache.commons.httpclient.util.URIUtil; //导入方法依赖的package包/类
public void testEncodeWithinQuery() {
    //TODO: There was an unmappable character for encoding UTF8. YAGNI?
    String unescaped1=  "abc123+ %_?=&#.";
    try {
        String stringRet = URIUtil.encodeWithinQuery(unescaped1);
        assertEquals("abc123%2B%20%25_%3F%3D%26%23.%C3%A4", stringRet);
        stringRet = URIUtil.decode(stringRet);
        assertEquals(unescaped1, stringRet);
    } catch(Exception e) {
        System.err.println("Exception thrown:  "+e);
    }
}
 
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:13,代码来源:TestURIUtil2.java

示例3: convertUriToDecodedString

import org.apache.commons.httpclient.util.URIUtil; //导入方法依赖的package包/类
/**
 * Utility function used to convert a given URI to a decoded string
 * representation sent to the backing store. URIs coming as input
 * to this class will be encoded by the URI class, and we want
 * the underlying storage to store keys in their original UTF-8 form.
 */
private static String convertUriToDecodedString(URI uri) {
  try {
    String result = URIUtil.decode(uri.toString());
    return result;
  } catch (URIException e) {
    throw new AssertionError("Failed to decode URI: " + uri.toString());
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:15,代码来源:MockStorageInterface.java

示例4: testQueryParams

import org.apache.commons.httpclient.util.URIUtil; //导入方法依赖的package包/类
public void testQueryParams() throws Exception {

        GetMethod get = new GetMethod("/");

        String ru_msg = constructString(RUSSIAN_STUFF_UNICODE); 
        String ch_msg = constructString(SWISS_GERMAN_STUFF_UNICODE); 

        get.setQueryString(new NameValuePair[] {
            new NameValuePair("ru", ru_msg),
            new NameValuePair("ch", ch_msg) 
        });            

        Map params = new HashMap();
        StringTokenizer tokenizer = new StringTokenizer(
            get.getQueryString(), "&");
        while (tokenizer.hasMoreTokens()) {
            String s = tokenizer.nextToken();
            int i = s.indexOf('=');
            assertTrue("Invalid url-encoded parameters", i != -1);
            String name = s.substring(0, i).trim(); 
            String value = s.substring(i + 1, s.length()).trim(); 
            value = URIUtil.decode(value, CHARSET_UTF8);
            params.put(name, value);
        }
        assertEquals(ru_msg, params.get("ru"));
        assertEquals(ch_msg, params.get("ch"));
    }
 
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:28,代码来源:TestMethodCharEncoding.java

示例5: testUrlEncodedRequestBody

import org.apache.commons.httpclient.util.URIUtil; //导入方法依赖的package包/类
public void testUrlEncodedRequestBody() throws Exception {

        PostMethod httppost = new PostMethod("/");

        String ru_msg = constructString(RUSSIAN_STUFF_UNICODE); 
        String ch_msg = constructString(SWISS_GERMAN_STUFF_UNICODE); 

        httppost.setRequestBody(new NameValuePair[] {
            new NameValuePair("ru", ru_msg),
            new NameValuePair("ch", ch_msg) 
        });            

        httppost.setRequestHeader("Content-Type", PostMethod.FORM_URL_ENCODED_CONTENT_TYPE 
            + "; charset=" + CHARSET_UTF8);

        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        httppost.getRequestEntity().writeRequest(bos);
        
        Map params = new HashMap();
        StringTokenizer tokenizer = new StringTokenizer(
            new String(bos.toByteArray(), CHARSET_UTF8), "&");
        while (tokenizer.hasMoreTokens()) {
            String s = tokenizer.nextToken();
            int i = s.indexOf('=');
            assertTrue("Invalid url-encoded parameters", i != -1);
            String name = s.substring(0, i).trim(); 
            String value = s.substring(i + 1, s.length()).trim(); 
            value = URIUtil.decode(value, CHARSET_UTF8);
            params.put(name, value);
        }
        assertEquals(ru_msg, params.get("ru"));
        assertEquals(ch_msg, params.get("ch"));
    }
 
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:34,代码来源:TestMethodCharEncoding.java

示例6: decode

import org.apache.commons.httpclient.util.URIUtil; //导入方法依赖的package包/类
public static String decode(String encoded) {
    try {
        return URIUtil.decode(encoded, CharEncoding.UTF_8);
    } catch (URIException e) {
        throw RaptureExceptionFactory.create(String.format("Error decoding step name %s:", encoded), e);
    }
}
 
开发者ID:RapturePlatform,项目名称:Rapture,代码行数:8,代码来源:StepHelper.java

示例7: decodePath

import org.apache.commons.httpclient.util.URIUtil; //导入方法依赖的package包/类
public static String decodePath(String path) {
    try {
        return URIUtil.decode(path, "UTF-8");
    } catch (URIException ex) {
        throw new EsHadoopIllegalArgumentException("Cannot encode path" + path, ex);
    }
}
 
开发者ID:xushjie1987,项目名称:es-hadoop-v2.2.0,代码行数:8,代码来源:StringUtils.java

示例8: AuthenticatedWebdavResource

import org.apache.commons.httpclient.util.URIUtil; //导入方法依赖的package包/类
protected AuthenticatedWebdavResource(HttpURL url, String authCookieName,
                                      String authCookieValue)
        throws HttpException, IOException
{
    super (URIUtil.decode(url.getEscapedURI()),
           new TokenCredentials(authCookieName, authCookieValue),
           true);
}
 
开发者ID:josmas,项目名称:openwonderland,代码行数:9,代码来源:AuthenticatedWebdavResource.java

示例9: 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

示例10: testEncodeWithinQuery

import org.apache.commons.httpclient.util.URIUtil; //导入方法依赖的package包/类
public void testEncodeWithinQuery() {
    String unescaped1=  "abc123+ %_?=&#.�";
    try {
        String stringRet = URIUtil.encodeWithinQuery(unescaped1);
        assertEquals("abc123%2B%20%25_%3F%3D%26%23.%C3%A4", stringRet);
        stringRet = URIUtil.decode(stringRet);
        assertEquals(unescaped1, stringRet);
    } catch(Exception e) {
        System.err.println("Exception thrown:  "+e);
    }
}
 
开发者ID:magneticmoon,项目名称:httpclient3-ntml,代码行数:12,代码来源:TestURIUtil2.java

示例11: getHref

import org.apache.commons.httpclient.util.URIUtil; //导入方法依赖的package包/类
private String getHref(Response response) {
    String href = response.getHref();
    if (this.decodeResponseHrefs != null) {
        try {
            href = URIUtil.decode(href, this.decodeResponseHrefs);
        }
        catch (URIException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
    }
    return href;
}
 
开发者ID:integrated,项目名称:jakarta-slide-webdavclient,代码行数:14,代码来源:XMLResponseMethodBase.java

示例12: getName

import org.apache.commons.httpclient.util.URIUtil; //导入方法依赖的package包/类
public String getName() {
  if(relPath!=null)
    return relPath;
  String escapedPath = httpUrl.getEscapedPath();
  String escapedName =
      URIUtil.getName(escapedPath.endsWith("/")
                      ? escapedPath.substring(0, escapedPath.length() - 1)
                      : escapedPath);
  try {
      return URIUtil.decode(escapedName);
  } catch (URIException e) {
      return escapedName;
  }
}
 
开发者ID:integrated,项目名称:jakarta-slide-webdavclient,代码行数:15,代码来源:WebdavFile.java

示例13: getParent

import org.apache.commons.httpclient.util.URIUtil; //导入方法依赖的package包/类
public String getParent() {
  if(relPath!=null)
    return null;
  String escapedPath = httpUrl.getEscapedPath();
  String parent = escapedPath.substring(
      0, escapedPath.lastIndexOf('/', escapedPath.length() - 2) + 1);
  if (parent.length() <= 1)
    return null;
  try {
      return URIUtil.decode(parent);
  } catch (URIException e) {
      return parent;
  }
}
 
开发者ID:integrated,项目名称:jakarta-slide-webdavclient,代码行数:15,代码来源:WebdavFile.java

示例14: getName

import org.apache.commons.httpclient.util.URIUtil; //导入方法依赖的package包/类
private static String getName(String uri) {
    String escapedName = URIUtil.getName(
        uri.endsWith("/") ? uri.substring(0, uri.length() - 1): uri);
    try {
        return URIUtil.decode(escapedName);
    } catch (URIException e) {
        return escapedName;
    }
}
 
开发者ID:integrated,项目名称:jakarta-slide-webdavclient,代码行数:10,代码来源:WebdavResource.java

示例15: verifyURLSignature

import org.apache.commons.httpclient.util.URIUtil; //导入方法依赖的package包/类
/**
 * 校验一下URL上的签名信息,确认这个请求来自敏行的服务器
 * 
 * @param queryString
 *            url的query String部分,例如 http://g.com?abc=1&de=2 的url,query
 *            string 为abc=1&de=2
 * @param securet
 *            ocu或者app的 securet。
 * @return true 如果签名被认证。
 */
public boolean verifyURLSignature(String queryString, String secret) {

	String signed = null;
	String timestamp = null;
	String nonce = null;
	String mx_sso_token = null;
	String login_name = null;

	String qstring = queryString;
	if (queryString.startsWith("http://")
			|| queryString.startsWith("https://")) {

		qstring = URIUtil.getQuery(queryString);
	}

	ParameterParser pp = new ParameterParser();

	@SuppressWarnings("unchecked")
	List<NameValuePair> list = (List<NameValuePair>) pp.parse(qstring, '&');

	try {

		for (NameValuePair np : list) {

			if (np.getName().equals("timestamp")) {
				timestamp = URIUtil.decode(np.getValue());
				continue;
			}

			if (np.getName().equals("nonce")) {
				nonce = URIUtil.decode(np.getValue());
				continue;
			}

			if (np.getName().equals("login_name")) {
				login_name = URIUtil.decode(np.getValue());
				continue;
			}

			if (np.getName().equals("mx_sso_token")) {
				mx_sso_token = URIUtil.decode(np.getValue());
				continue;
			}

			if (np.getName().equals("signed")) {
				signed = URIUtil.decode(np.getValue());
				continue;
			}
		}

	} catch (URIException e) {
		throw new MxException("Query string not valid:" + queryString, e);
	}

	StringBuilder sb = new StringBuilder();
	sb.append(timestamp).append(":").append(nonce).append(":")
			.append(login_name).append(":").append(mx_sso_token);

	String t = HMACSHA1.getSignature(sb.toString(), secret);
	return t.equals(signed);

}
 
开发者ID:dehuinet,项目名称:minxing_java_sdk,代码行数:73,代码来源:AppAccount.java


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