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


Java URIUtil.encodeWithinQuery方法代码示例

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


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

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

示例2: testPost

import org.apache.commons.httpclient.util.URIUtil; //导入方法依赖的package包/类
@Test
public void testPost()
        throws MalformedURLException, IOException, XMLStreamException {
    String guid = this.feeder.createGUID(event).toString();
    this.feeder.sendNotification(this.event);
    URL url = new URL(this.endpoint + "/GetRSS?id=" + URIUtil
                      .encodeWithinQuery(guid));
    String response;
    try (InputStream in = this.httpClient.get(url);
         Reader reader = new InputStreamReader(in, StandardCharsets.UTF_8)) {
        response = CharStreams.toString(reader);
    }
    assertThat(response, is(notNullValue()));
    errors.checkThat(response.length(), is(not(0)));
    errors.checkThat(response, is(not("guid " + guid +
                                      " does not exist in the data store.")));
}
 
开发者ID:52North,项目名称:imis-iot-eventing-process,代码行数:18,代码来源:RssFeederTest.java

示例3: encodeQueryValue

import org.apache.commons.httpclient.util.URIUtil; //导入方法依赖的package包/类
/**
 * Escape and encode a string regarded as within the query component of an URI.
 * @param value the value to encode
 * @return encoded query, null if the default charset is not supported
 */
public static String encodeQueryValue(final String value) {
  try {
    return URIUtil.encodeWithinQuery(value, "UTF-8");
  } catch (URIException e) {
    throw new AssertionError("JVM does not support UTF-8"); // should never happen!
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:13,代码来源:ServletUtil.java

示例4: encode

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

示例5: determineUrl

import org.apache.commons.httpclient.util.URIUtil; //导入方法依赖的package包/类
private String determineUrl(RowMetaInterface outputRowMeta, Object[] row) throws KettleValueException, KettleException
{
	try
	{
		if(meta.isUrlInField())
       {
			// get dynamic url
       	data.realUrl=outputRowMeta.getString(row,data.indexOfUrlField);
       }
     StringBuffer url = new StringBuffer(data.realUrl); // the base URL with variable substitution
     
     for (int i=0;i<data.argnrs.length;i++)
     {
     	if (i==0 && url.indexOf("?")<0)
         {
             url.append('?');
         }
         else
         {
             url.append('&');
         }
	
     	url.append(URIUtil.encodeWithinQuery(meta.getArgumentParameter()[i]));
     	url.append('=');
         String s = outputRowMeta.getString(row, data.argnrs[i]);
         if ( s != null )
         	s = URIUtil.encodeWithinQuery(s);
         url.append(s);
     }
     
     return url.toString();
 }
 catch(Exception e)
 {
     throw new KettleException(Messages.getString("HTTP.Log.UnableCreateUrl"), e);
 }
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:38,代码来源:HTTP.java

示例6: determineUrl

import org.apache.commons.httpclient.util.URIUtil; //导入方法依赖的package包/类
private String determineUrl(RowMetaInterface outputRowMeta, Object[] row) throws KettleValueException, KettleException
{
	try
	{
		if(meta.isUrlInField())
       {
			// get dynamic url
       	data.realUrl=outputRowMeta.getString(row,data.indexOfUrlField);
       }
     StringBuffer url = new StringBuffer(data.realUrl); // the base URL with variable substitution
     
     for (int i=0;i<data.argnrs.length;i++)
     {
     	if (i==0 && url.indexOf("?")<0)
         {
             url.append('?');
         }
         else
         {
             url.append('&');
         }
	
     	url.append(URIUtil.encodeWithinQuery(meta.getArgumentParameter()[i]));
     	url.append('=');
         String s = outputRowMeta.getString(row, data.argnrs[i]);
         if ( s != null )
         	s = URIUtil.encodeWithinQuery(s);
         url.append(s);
     }
     
     return url.toString();
 }
 catch(Exception e)
 {
     throw new KettleException(BaseMessages.getString(PKG, "HTTP.Log.UnableCreateUrl"), e);
 }
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:38,代码来源:HTTP.java

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


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