Example usage for java.net URI getQuery

List of usage examples for java.net URI getQuery

Introduction

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

Prototype

public String getQuery() 

Source Link

Document

Returns the decoded query component of this URI.

Usage

From source file:Main.java

public static void printURIDetails(URI uri) {
    System.out.println("URI:" + uri);
    System.out.println("Normalized:" + uri.normalize());
    String parts = "[Scheme=" + uri.getScheme() + ", Authority=" + uri.getAuthority() + ", Path="
            + uri.getPath() + ", Query:" + uri.getQuery() + ", Fragment:" + uri.getFragment() + "]";
    System.out.println(parts);//from  w  w w  .  j  a  v  a  2  s.  com
    System.out.println();
}

From source file:org.eclipse.buckminster.p2.remote.client.RemoteRepositoryFactory.java

protected static URI getServerURI(URI repoURI) {
    try {//  w  w w  . j  av a2 s.c  o m
        return new URI(repoURI.getScheme(), repoURI.getAuthority(), repoURI.getPath(), repoURI.getQuery(),
                null);
    } catch (URISyntaxException e) {
        return repoURI;
    }
}

From source file:org.attribyte.util.URIEncoder.java

/**
 * Recodes a URI.//  ww w .j  a  v a 2  s  .c o  m
 * @param uri The uri.
 * @return The recoded URI as a string.
 */
public static String recode(URI uri) {
    return encode(uri.getScheme(), uri.getAuthority(), uri.getPath(), uri.getQuery(), uri.getFragment());
}

From source file:org.eclipse.ecr.common.utils.URIUtils.java

public static String addParametersToURIQuery(String uriString, Map<String, String> parameters) {
    String res = uriString;//ww  w  .  java2 s .  c  o  m
    try {
        String uriPath = getURIPath(uriString);
        URI uri = URI.create(uriString);
        String query = uri.getQuery();
        Map<String, String> existingParams = getRequestParameters(query);
        if (existingParams == null) {
            existingParams = new LinkedHashMap<String, String>();
        }
        existingParams.putAll(parameters);
        if (!existingParams.isEmpty()) {
            String newQuery = getURIQuery(existingParams);
            res = uriPath + '?' + newQuery;
        } else {
            res = uriPath;
        }
    } catch (IllegalArgumentException e) {
        log.error("Failed to add new parameters to uri", e);
    }
    return res;
}

From source file:com.ibm.jaggr.core.util.PathUtil.java

public static URI appendToPath(URI uri, String append) throws URISyntaxException {
    return new URI(uri.getScheme(), uri.getAuthority(), uri.getPath() + append, uri.getQuery(),
            uri.getFragment());//from   w  w  w.  j a v  a2 s  .c  o  m
}

From source file:org.gradle.caching.http.internal.HttpBuildCache.java

/**
 * Create a safe URI from the given one by stripping out user info.
 *
 * @param uri Original URI//from   w  w w .  j  a va 2s .  c  om
 * @return a new URI with no user info
 */
private static URI safeUri(URI uri) {
    try {
        return new URI(uri.getScheme(), null, uri.getHost(), uri.getPort(), uri.getPath(), uri.getQuery(),
                uri.getFragment());
    } catch (URISyntaxException e) {
        throw UncheckedException.throwAsUncheckedException(e);
    }
}

From source file:com.microsoft.azure.hdinsight.jobs.JobViewDummyHttpServer.java

@Nullable
private static RequestDetail getRequestDetail(@NotNull URI myUrl) {
    String[] queries = myUrl.getQuery() == null ? null : myUrl.getQuery().split("&");
    String path = myUrl.getPath();
    Matcher matcher = clusterPattern.matcher(path);
    if (matcher.find()) {
        requestDetail = new RequestDetail(matcher.group(1), matcher.group(2), queries);
        return requestDetail;
    }//from   w w w  . j a  v  a  2s .  c  o m
    return null;
}

From source file:com.bazaarvoice.seo.sdk.util.BVUtilty.java

public static String getQueryString(String uri) {

    if (StringUtils.isBlank(uri)) {
        return "";
    }//from ww  w .  j av a  2 s .  c om

    URI _uri = null;
    try {
        _uri = new URI(uri);
    } catch (Exception ex) {
        ex.printStackTrace();
    }

    return _uri.getQuery();
}

From source file:com.log4ic.compressor.utils.HttpUtils.java

public static Map<String, String> getParameterMap(URI uri) {
    String qStr = uri.getQuery();
    Map<String, String> map = Maps.newHashMap();
    if (StringUtils.isNotBlank(qStr)) {
        String[] params = qStr.split("&");
        for (String param : params) {
            String[] p = param.split("=");
            map.put(p[0], p.length > 1 ? p[1] : null);
        }//from   ww w  .j a  v  a  2s .  co m
    }
    return map;
}

From source file:de.ii.xtraplatform.ogc.api.CSW.java

public static String cleanUrl(String url) {
    try {//from  w ww.j  a v  a  2s  .c o m
        URI inUri = new URI(url.trim());
        URIBuilder outUri = new URIBuilder(inUri).removeQuery();

        if (inUri.getQuery() != null && !inUri.getQuery().isEmpty()) {
            for (String inParam : inUri.getQuery().split("&")) {
                String[] param = inParam.split("=");
                if (!CSW.hasKVPKey(param[0].toUpperCase())) {
                    outUri.addParameter(param[0], param[1]);
                }
            }
        }

        return outUri.toString();
    } catch (URISyntaxException ex) {
        return url;
    }
}