Example usage for java.net URI getRawQuery

List of usage examples for java.net URI getRawQuery

Introduction

In this page you can find the example usage for java.net URI getRawQuery.

Prototype

public String getRawQuery() 

Source Link

Document

Returns the raw query component of this URI.

Usage

From source file:com.feilong.core.net.ParamExtensionUtil.java

/**
 * ?./*from ww  w  .  j a v  a  2 s  .  c o  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  <code>uri</code> null, {@link StringUtils#EMPTY}<br>
 *          <code>paramNameList</code> nullempty, <code>uri.toString()</code><br>
 */
public static String removeParameterList(URI uri, List<String> paramNameList, String charsetType) {
    return null == uri ? EMPTY
            : removeParameterList(uri.toString(), uri.getRawQuery(), paramNameList, charsetType);
}

From source file:com.igormaznitsa.mindmap.model.ModelUtils.java

@Nonnull
public static Properties extractQueryPropertiesFromURI(@Nonnull final URI uri) {
    final Properties result = new Properties();

    final String rawQuery = uri.getRawQuery();
    if (rawQuery != null) {
        final Matcher matcher = URI_QUERY_PARAMETERS.matcher(rawQuery);

        try {/*  w  w  w  .  ja  v  a  2  s.c  om*/
            while (matcher.find()) {
                final String key = URLDecoder.decode(matcher.group(1), "UTF-8"); //NOI18N
                final String value = URLDecoder.decode(matcher.group(2), "UTF-8"); //NOI18N
                result.put(key, value);
            }
        } catch (UnsupportedEncodingException ex) {
            LOGGER.error("Can't decode URI query", ex); //NOI18N
            throw new Error("Unexpected exception, can't find UTF-8 charset!"); //NOI18N
        }
    }

    return result;
}

From source file:org.fcrepo.apix.integration.StreamingIT.java

/**
 * Appends the path to the URI.  All other components of the URI are preserved.
 *
 * @param uri      the URI with the path being appended to
 * @param toAppend the path to be appended to the URI
 * @return a new URI with a path component ending with {@code toAppend}
 * @throws URISyntaxException/*  ww  w .j  a va  2  s  . c o m*/
 */
private static URI appendToPath(final URI uri, final String toAppend) throws URISyntaxException {
    return new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), uri.getPort(), uri.getPath() + toAppend,
            uri.getRawQuery(), uri.getRawFragment());
}

From source file:com.android.idtt.http.client.util.URLEncodedUtils.java

/**
 * Returns a list of {@link org.apache.http.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 ww w  .j  a  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) {
    final String query = uri.getRawQuery();
    if (!TextUtils.isEmpty(query)) {
        List<NameValuePair> result = new ArrayList<NameValuePair>();
        Scanner scanner = new Scanner(query);
        parse(result, scanner, encoding);
        return result;
    } else {
        return Collections.emptyList();
    }
}

From source file:com.feilong.core.net.ParamExtensionUtil.java

/**
 * ?./* ww  w.j av a 2s . c  om*/
 * 
 * <p>
 * uri????,?,?{@code a=1&a=2},a,[3,4],{@code 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  <code>uri</code> null, {@link StringUtils#EMPTY}<br>
 */
public static String addParameterArrayValueMap(URI uri, Map<String, String[]> arrayValueMap,
        String charsetType) {
    return null == uri ? EMPTY
            : ParamUtil.addParameterArrayValueMap(uri.toString(), uri.getRawQuery(), arrayValueMap,
                    charsetType);
}

From source file:com.lidroid.xutils.http.client.URLEncodedUtils.java

/**
 * Returns a list of {@link org.apache.http.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  .java2  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 Collections.emptyList();
    }
}

From source file:com.gistlabs.mechanize.util.apache.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 ww  w .j  a  va 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) {
    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 Collections.emptyList();
}

From source file:edu.internet2.middleware.openid.message.encoding.EncodingUtils.java

/**
 * Append the URL encoded OpenID message parameters to the query string of the provided URI.
 * /*from   ww  w .j  a v a 2  s .c o  m*/
 * @param uri URI to append OpenID message parameter to
 * @param message URL encoded OpenID message parameters
 * @return URI with message parameters appended
 */
public static URI appendMessageParameters(URI uri, String message) {
    if (uri == null || message == null) {
        return uri;
    }

    // build new query string
    StringBuffer queryBuffer = new StringBuffer();
    if (uri.getRawQuery() != null) {
        queryBuffer.append(uri.getRawQuery());
    }
    if (queryBuffer.length() > 0 && queryBuffer.charAt(queryBuffer.length() - 1) != '&') {
        queryBuffer.append('&');
    }
    queryBuffer.append(message);

    try {
        return URIUtils.createURI(uri.getScheme(), uri.getHost(), uri.getPort(), uri.getPath(),
                queryBuffer.toString(), uri.getFragment());
    } catch (URISyntaxException e) {
        log.error("Unable to append message parameters to URI: {}", e);
    }

    return null;
}

From source file:org.esigate.util.UriUtils.java

/**
 * Creates an {@link URI} after escaping some special characters in order to tolerate some incorrect URI types. If
 * the uri contains a server name but no path, the path is set to "/" as a browser would do.
 * // w  w w .ja v a  2s .  c  o  m
 * @param uri
 *            the URI as a {@link String}
 * @return the URI as a {@link URI} object
 */
public static URI createURI(String uri) {
    uri = encodeIllegalCharacters(uri);
    URI result = URI.create(uri);
    if (result.getHost() != null && StringUtils.isEmpty(result.getPath())) {
        result = URI.create(createURI(result.getScheme(), result.getHost(), result.getPort(), "/",
                result.getRawQuery(), result.getRawFragment()));
    }
    return result;
}

From source file:org.hippoecm.frontend.service.restproxy.RestProxyServicePlugin.java

static String createRestURI(String value, final HttpServletRequest request) {
    if (StringUtils.isEmpty(value)) {
        throw new IllegalStateException(
                "No REST service URI configured. Please set the plugin configuration property '"
                        + CONFIG_REST_URI + "'");
    }//from ww w  .ja va  2s .c o  m
    try {
        URI u = new URI(value);
        final int portNumber;
        if (u.getPort() == -1) {
            portNumber = request.getLocalPort();
        } else {
            portNumber = u.getPort();
        }
        return new URI(u.getScheme(), u.getUserInfo(), u.getHost(), portNumber, u.getRawPath(), u.getRawQuery(),
                u.getRawFragment()).toString();

    } catch (URISyntaxException e) {
        throw new IllegalStateException(
                "Invalid REST service URI configured. Please correct the plugin configuration property '"
                        + CONFIG_REST_URI + "'",
                e);
    }
}