List of usage examples for org.apache.commons.httpclient.util URIUtil encodeWithinQuery
public static String encodeWithinQuery(String unescaped, String charset) throws URIException
From source file:de.innovationgate.wgpublisher.bi.BiBase.java
public static String encode(String sourceText, String encoding) throws URIException { String result = URIUtil.encodeWithinQuery(sourceText, encoding); return result; }
From source file:de.innovationgate.utils.URLBuilder.java
private String rebuildQuery() { Map<String, Object> rebuildParameters = getRebuildParameters(); Iterator<String> paramKeys = rebuildParameters.keySet().iterator(); String paramSeparator = "&"; StringBuffer paramString = new StringBuffer(); String key;//w ww. j a v a 2 s .c o m Object value; // may be a List while (paramKeys.hasNext()) { key = paramKeys.next().toString(); value = rebuildParameters.get(key); List<Object> values = new ArrayList<Object>(); if (value instanceof List) values.addAll((List) value); // add all values else values.add(value); // add single value try { if (_encoding != null) key = URIUtil.encodeWithinQuery(key, _encoding); for (Object o : values) { if (paramString.length() > 0) { paramString.append(paramSeparator); } paramString.append(key); if (o == null) continue; // special handling of INT values: if (o instanceof Double) { Double _o = (Double) o; if (_o == _o.intValue()) { // is Integer? o = _o.intValue(); } } String v = o.toString(); if (_encoding != null) v = URIUtil.encodeWithinQuery(v, _encoding); if (v != null && !v.trim().equals("")) { paramString.append("="); paramString.append(v); } } } catch (Exception e) { throw new RuntimeException(e); } } if (paramString.length() > 0) { return "?" + paramString.toString(); } else { return ""; } }
From source file:org.apache.hadoop.util.ServletUtil.java
/** * Escape and encode a string regarded as within the query component of an URI. * @param value the value to encode/*www .jav a2 s . c o m*/ * @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! } }
From source file:rapture.common.dp.StepHelper.java
public static String encode(String rawName) { try {//from w ww . ja va2 s . c om return URIUtil.encodeWithinQuery(rawName, CharEncoding.UTF_8); } catch (URIException e) { throw RaptureExceptionFactory.create(String.format("Error encoding step %s", rawName), e); } }