本文整理汇总了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);
}
}
示例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.")));
}
示例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!
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}