List of usage examples for java.net URI getRawQuery
public String getRawQuery()
From source file:org.dkpro.lab.engine.impl.ImportUtil.java
public static Map<String, String> extractConstraints(URI aUri) { @SuppressWarnings("unchecked") UriInfoImpl uriInfo = new UriInfoImpl(aUri, null, "", aUri.getRawQuery(), Collections.EMPTY_LIST); MultivaluedMap<String, String> parameters = uriInfo.getQueryParameters(true); Map<String, String> constraints = new HashMap<String, String>(); for (String key : parameters.keySet()) { for (String value : parameters.get(key)) { constraints.put(key, value); }/*from w w w . ja v a 2s . c o m*/ } return constraints; }
From source file:org.opendatakit.dwc.server.HtmlUtil.java
public static final String createLinkWithProperties(String url, Map<String, String> properties) { StringBuilder urlBuilder = new StringBuilder(); try {/*w w w. j ava 2 s. com*/ URI uri = new URI(url); String embeddedQuery = uri.getRawQuery(); if (embeddedQuery != null && embeddedQuery.length() != 0) { int i = url.indexOf(embeddedQuery); String path = url.substring(0, i - 1); urlBuilder.append(path); String[] pairs = embeddedQuery.split(HtmlConsts.PARAM_DELIMITER); for (String p : pairs) { String[] kv = p.split(BasicConsts.EQUALS); String v = URLDecoder.decode(kv[1], "UTF-8"); properties.put(kv[0], v); } } else { urlBuilder.append(url); } } catch (URISyntaxException e1) { e1.printStackTrace(); throw new IllegalArgumentException(e1); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } if (properties != null) { Set<Map.Entry<String, String>> propSet = properties.entrySet(); if (!propSet.isEmpty()) { urlBuilder.append(HtmlConsts.BEGIN_PARAM); boolean firstParam = true; for (Map.Entry<String, String> property : propSet) { if (firstParam) { firstParam = false; } else { urlBuilder.append(HtmlConsts.PARAM_DELIMITER); } String value = property.getValue(); if (value == null) { value = BasicConsts.NULL; } String valueEncoded; try { valueEncoded = URLEncoder.encode(value, HtmlConsts.UTF8_ENCODE); } catch (UnsupportedEncodingException e) { valueEncoded = BasicConsts.EMPTY_STRING; } urlBuilder.append(property.getKey() + BasicConsts.EQUALS + valueEncoded); } } } return urlBuilder.toString(); }
From source file:com.alibaba.openapi.client.util.URLEncodedUtils.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 a 2 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) { List<NameValuePair> result = Collections.emptyList(); final String query = uri.getRawQuery(); if (query != null && query.length() > 0) { result = new ArrayList<NameValuePair>(); parse(result, new Scanner(query), encoding); } return result; }
From source file:com.kolich.aws.services.AbstractAwsService.java
/** * Given a {@link URI} returns the query string component of that * {@link URI}. The query of a URI is the piece after the "?". If the * URI is null, an "" empty string is returned. If the URI is not null, * but the query is empty, an "" empty string is returned. * @param uri the URI to extract the query from * @return/*from w w w . ja v a2 s . c o m*/ */ private static final String getQuery(final URI uri) { if (uri == null) { return EMPTY_STRING; } else { final String query = uri.getRawQuery(); return (query == null) ? EMPTY_STRING : QUERY_STRING + query; } }
From source file:com.yoavst.quickapps.URLEncodedUtils.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/>/* w w w . j a v a 2 s. c om*/ * 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) { List<NameValuePair> result = Collections.emptyList(); final String query = uri.getRawQuery(); if (query != null && query.length() > 0) { result = new ArrayList<>(); parse(result, new Scanner(query), encoding); } return result; }
From source file:com.bagdemir.eboda.utils.HttpUtils.java
public static void parseGetParameters(HttpExchange exchange) throws UnsupportedEncodingException { final URI requestedUri = exchange.getRequestURI(); final String query = requestedUri.getRawQuery(); parseQuery(query, exchange);//from www . j av a2s.co m }
From source file:com.bazaarvoice.seo.sdk.util.BVUtility.java
public static String getQueryString(String uri) { if (StringUtils.isBlank(uri)) { return ""; }//from ww w . j av a 2 s . c o m URI _uri = null; try { _uri = new URI(uri); } catch (Exception ex) { ex.printStackTrace(); } return (_uri.getRawQuery() == null) ? "" : _uri.getRawQuery(); }
From source file:com.netflix.iep.http.ClientConfig.java
/** Create relative uri string with the path and query. */ static String relative(URI uri) { String r = uri.getRawPath();/*ww w .j a v a 2s. c om*/ if (r == null) { r = "/"; } else if (r.startsWith("//")) { r = r.substring(1); } if (uri.getRawQuery() != null) { r += "?" + uri.getRawQuery(); } return r; }
From source file:org.apache.olingo.client.core.uri.URIUtils.java
public static URI buildFunctionInvokeURI(final URI uri, final Map<String, ClientValue> parameters) { final String rawQuery = uri.getRawQuery(); String baseURI = StringUtils.substringBefore(uri.toASCIIString(), "?" + rawQuery); if (baseURI.endsWith("()")) { baseURI = baseURI.substring(0, baseURI.length() - 2); }/*from ww w . ja v a 2s . co m*/ final StringBuilder inlineParams = new StringBuilder(); for (Map.Entry<String, ClientValue> param : parameters.entrySet()) { inlineParams.append(param.getKey()).append("="); Object value = null; if (param.getValue().isPrimitive()) { value = param.getValue().asPrimitive().toValue(); } else if (param.getValue().isComplex()) { value = param.getValue().asComplex().asJavaMap(); } else if (param.getValue().isCollection()) { value = param.getValue().asCollection().asJavaCollection(); } else if (param.getValue().isEnum()) { value = param.getValue().asEnum().toString(); } inlineParams.append(URIUtils.escape(value)).append(','); } if (inlineParams.length() > 0) { inlineParams.deleteCharAt(inlineParams.length() - 1); } try { return URI.create(baseURI + "(" + URLEncoder.encode(inlineParams.toString(), Constants.UTF8) + ")" + (StringUtils.isNotBlank(rawQuery) ? "?" + rawQuery : StringUtils.EMPTY)); } catch (UnsupportedEncodingException e) { throw new IllegalArgumentException("While adding GET parameters", e); } }
From source file:com.feilong.core.net.ParamExtensionUtil.java
/** * url???.//from w ww. j av a2 s. com * * @param uri * the uri * @param paramNameList * ?????list * @param charsetType * ??, {@link CharsetType}<br> * <span style="color:green">null empty,?,?</span><br> * ??,??,ie?chrome? url ,? * @return <code>uri</code> null, {@link StringUtils#EMPTY}<br> * ? {@link #retentionParamList(String, String, List, String)} * @see #retentionParamList(String, String, List, String) */ public static String retentionParamList(URI uri, List<String> paramNameList, String charsetType) { return null == uri ? EMPTY : retentionParamList(uri.toString(), uri.getRawQuery(), paramNameList, charsetType); }