List of usage examples for java.net URI getRawQuery
public String getRawQuery()
From source file:com.pidoco.juri.JURI.java
public static Multimap<String, String> parseQueryParameters(URI uri) { return parseQueryParameters(StringUtils.defaultString(uri.getRawQuery())); }
From source file:org.mcxiaoke.commons.http.util.URIUtilsEx.java
/** * Returns a list of {@link NameValuePair NameValuePairs} as built from the * URI's query portion. For example, a URI of * http://example.org/path/to/file?a=1&b=2&c=3 would return a list of three * NameValuePairs, one for a=1, one for b=2, and one for c=3. * <p>//from w w w.ja v a2 s . c o m * This is typically useful while parsing an HTTP PUT. * * @param uri * uri to parse * @param encoding * encoding to use while parsing the query */ public static List<NameValuePair> parse(final URI uri, final String encoding) { final String query = uri.getRawQuery(); if (query != null && query.length() > 0) { List<NameValuePair> result = new ArrayList<NameValuePair>(); Scanner scanner = new Scanner(query); parse(result, scanner, encoding); return result; } else { return null; } }
From source file:org.mcxiaoke.commons.http.util.URIUtilsEx.java
/** * Returns a list of {@link NameValuePair NameValuePairs} as built from the * URI's query portion. For example, a URI of * http://example.org/path/to/file?a=1&b=2&c=3 would return a list of three * NameValuePairs, one for a=1, one for b=2, and one for c=3. * <p>//from w ww. ja v a 2 s . co m * This is typically useful while parsing an HTTP PUT. * * @param uri * uri to parse * @param encoding * encoding to use while parsing the query */ public static Map<String, String> parse2(final URI uri, final String encoding) { final String query = uri.getRawQuery(); if (query != null && query.length() > 0) { Map<String, String> result = new HashMap<String, String>(); Scanner scanner = new Scanner(query); parse2(result, scanner, encoding); return result; } else { return null; } }
From source file:com.sunchenbin.store.feilong.core.net.ParamUtil.java
/** * ?./*w w w .j a v a 2 s .c o m*/ * * <p> * uri????,?,?a=1&a=2,a,[3,4], a=3&a=4. * </p> * * @param uri * ? ?,?,??,<br> * ??, ? * @param arrayValueMap * singleValueMap request.getParameterMap * @param charsetType * ??, {@link CharsetType}<br> * <span style="color:green">null empty,?,?</span><br> * ??,??,ie?chrome? url ,? * @return ?,uri????,? */ public static String addParameterArrayValueMap(URI uri, Map<String, String[]> arrayValueMap, String charsetType) { if (null == uri) { return StringUtils.EMPTY; } String uriString = uri.toString(); if (Validator.isNullOrEmpty(arrayValueMap)) { return uriString; } String queryString = uri.getRawQuery(); return addParameterArrayValueMap(uriString, queryString, arrayValueMap, charsetType); }
From source file:com.sunchenbin.store.feilong.core.net.ParamUtil.java
/** * ?./* w w w . j a v a2 s. com*/ * * @param uri * the uri * @param paramNameList * the param name list * @param charsetType * ??, {@link CharsetType}<br> * <span style="color:green">null empty,?,?</span><br> * ??,??,ie?chrome? url ,? * @return the string */ public static String removeParameterList(URI uri, List<String> paramNameList, String charsetType) { if (null == uri) { return StringUtils.EMPTY; } String uriString = uri.toString(); if (Validator.isNullOrEmpty(paramNameList)) {// paramNameListnull return uriString; } String queryString = uri.getRawQuery();// URI? URI???? URI return removeParameterList(uriString, queryString, paramNameList, charsetType); }
From source file:org.echocat.jomon.resources.RotatingDomainResourceRequestUriGenerator.java
public void setBaseUri(URI baseUri) { if (baseUri != null && (!isEmpty(baseUri.getRawFragment()) || !isEmpty(baseUri.getRawQuery()))) { throw new IllegalArgumentException("Provided baseUri has a fragment and/or query."); }/*from w ww.j av a 2 s .c o m*/ _baseUri = baseUri; }
From source file:com.sunchenbin.store.feilong.core.net.ParamUtil.java
/** * url???.// w w w . j a v a 2 s . co m * * @param uri * the uri * @param paramNameList * ?????list * @param charsetType * ??, {@link CharsetType}<br> * <span style="color:green">null empty,?,?</span><br> * ??,??,ie?chrome? url ,? * @return the string * @see #toSafeArrayValueMap(String, String) */ public static String retentionParamList(URI uri, List<String> paramNameList, String charsetType) { if (null == uri) { return StringUtils.EMPTY; } String uriString = uri.toString(); if (Validator.isNullOrEmpty(paramNameList)) { // paramNameList null return uriString; } String queryString = uri.getRawQuery(); // URI? URI???? URI return retentionParamList(uriString, queryString, paramNameList, charsetType); }
From source file:org.mule.transport.http.transformers.HttpRequestBodyToParamMap.java
@Override public Object transformMessage(MuleMessage message, String outputEncoding) throws TransformerException { Map<String, Object> paramMap = new HashMap<String, Object>(); try {/*from w w w . ja v a 2s . c o m*/ String httpMethod = message.getInboundProperty("http.method"); String contentType = message.getInboundProperty("Content-Type"); boolean isGet = HttpConstants.METHOD_GET.equalsIgnoreCase(httpMethod); boolean isPost = HttpConstants.METHOD_POST.equalsIgnoreCase(httpMethod); boolean isUrlEncoded = false; if (contentType != null) { isUrlEncoded = contentType.startsWith("application/x-www-form-urlencoded"); } if (!(isGet || (isPost && isUrlEncoded))) { throw new Exception("The HTTP method or content type is unsupported!"); } String queryString = null; if (isGet) { URI uri = new URI(message.getPayloadAsString(outputEncoding)); queryString = uri.getRawQuery(); } else if (isPost) { queryString = new String(message.getPayloadAsBytes()); } if (StringUtils.isNotBlank(queryString)) { addQueryStringToParameterMap(queryString, paramMap, outputEncoding); } } catch (Exception e) { throw new TransformerException(this, e); } return paramMap; }
From source file:com.fatwire.dta.sscrawler.util.SSUriHelper.java
public Link createLink(final URI uri) { final String qs = uri.getRawQuery(); if (log.isDebugEnabled()) { log.debug(qs);/*w w w . j ava 2 s.c om*/ } final Link link = new Link(); if (qs == null) { return link; } final String[] val = qs.split("&"); for (final String v : val) { if (!v.startsWith(SSURI_PREFIX)) { // in case a link is inside a // link (for instance a // forwardpage=... case). final int t = v.indexOf('='); try { link.addParameter(decode(v.substring(0, t)), decode(v.substring(t + 1, v.length()))); } catch (DecoderException e) { log.warn(e + " for " + qs, e); return null; } } else { if (SSURI_BLOBSERVER.equals(v)) { link.clear(); break; } } } return link; }
From source file:org.apache.hadoop.hdfs.server.namenode.FileUploadHttpHandler.java
private void parseGetParameters(HttpExchange exchange) throws UnsupportedEncodingException { Map<String, Object> parameters = new HashMap<String, Object>(); URI requestedUri = exchange.getRequestURI(); String query = requestedUri.getRawQuery(); parseQuery(query, parameters);//from w w w . ja v a 2s . c o m exchange.setAttribute("parameters", parameters); }