Class URIUtils


  • public final class URIUtils
    extends java.lang.Object
    Utility methods for editing and analyzing uris.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void addParamOverride​(com.google.common.collect.Multimap<java.lang.String,​java.lang.String> params, java.lang.String key, java.lang.String value)
      Add a parameter to the query params (the params map) replacing any parameter that might be there.
      static java.lang.String addParams​(java.lang.String url, com.google.common.collect.Multimap<java.lang.String,​java.lang.String> params, java.util.Set<java.lang.String> overrideParams)
      Add the given params to the query.
      static java.net.URI addParams​(java.net.URI uri, com.google.common.collect.Multimap<java.lang.String,​java.lang.String> params, java.util.Set<java.lang.String> overrideParams)
      Add the given params to the query.
      static com.google.common.collect.Multimap<java.lang.String,​java.lang.String> getParameters​(java.lang.String rawQuery)
      Parse the URI and get all the parameters in map form.
      static com.google.common.collect.Multimap<java.lang.String,​java.lang.String> getParameters​(java.net.URI uri)
      Parse the URI and get all the parameters in map form.
      static void setParamDefault​(com.google.common.collect.Multimap<java.lang.String,​java.lang.String> params, java.lang.String key, java.lang.String value)
      Add a parameter to the query params (the params map) if there is not existing value for that key.
      static java.net.URI setPath​(java.net.URI initialUri, java.lang.String path)
      Set the replace of the uri and return the new URI.
      static java.net.URI setQueryParams​(java.net.URI initialUri, com.google.common.collect.Multimap<java.lang.String,​java.lang.String> queryParams)
      Construct a new uri by replacing query parameters in initialUri with the query parameters provided.
      static java.lang.String toString​(MfClientHttpRequestFactory requestFactory, java.net.URI uri)
      Read all the data from the provided URI and return the data as a string.
      static java.lang.String toString​(MfClientHttpRequestFactory requestFactory, java.net.URL url)
      Read all the data from the provided URI and return the data as a string.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getParameters

        public static com.google.common.collect.Multimap<java.lang.String,​java.lang.String> getParameters​(java.net.URI uri)
        Parse the URI and get all the parameters in map form. Query name -> List of Query values.
        Parameters:
        uri - uri to analyze
      • getParameters

        public static com.google.common.collect.Multimap<java.lang.String,​java.lang.String> getParameters​(java.lang.String rawQuery)
        Parse the URI and get all the parameters in map form. Query name -> List of Query values.
        Parameters:
        rawQuery - query portion of the uri to analyze.
      • addParams

        public static java.lang.String addParams​(java.lang.String url,
                                                 com.google.common.collect.Multimap<java.lang.String,​java.lang.String> params,
                                                 java.util.Set<java.lang.String> overrideParams)
                                          throws java.net.URISyntaxException
        Add the given params to the query.
        Parameters:
        url - The query
        params - The params to add
        overrideParams - A set of parameter names that must be overridden and not added
        Returns:
        The new query
        Throws:
        java.net.URISyntaxException
      • addParams

        public static java.net.URI addParams​(java.net.URI uri,
                                             com.google.common.collect.Multimap<java.lang.String,​java.lang.String> params,
                                             java.util.Set<java.lang.String> overrideParams)
        Add the given params to the query.
        Parameters:
        uri - The query
        params - The params to add
        overrideParams - A set of parameter names that must be overridden and not added
        Returns:
        The new query
      • addParamOverride

        public static void addParamOverride​(com.google.common.collect.Multimap<java.lang.String,​java.lang.String> params,
                                            java.lang.String key,
                                            java.lang.String value)
        Add a parameter to the query params (the params map) replacing any parameter that might be there.
        Parameters:
        params - the query parameters
        key - the key/param name
        value - the value to insert
      • setParamDefault

        public static void setParamDefault​(com.google.common.collect.Multimap<java.lang.String,​java.lang.String> params,
                                           java.lang.String key,
                                           java.lang.String value)
        Add a parameter to the query params (the params map) if there is not existing value for that key.
        Parameters:
        params - the query parameters
        key - the key/param name
        value - the value to insert
      • setQueryParams

        public static java.net.URI setQueryParams​(java.net.URI initialUri,
                                                  com.google.common.collect.Multimap<java.lang.String,​java.lang.String> queryParams)
        Construct a new uri by replacing query parameters in initialUri with the query parameters provided.
        Parameters:
        initialUri - the initial/template URI
        queryParams - the new query parameters.
      • toString

        public static java.lang.String toString​(MfClientHttpRequestFactory requestFactory,
                                                java.net.URI uri)
                                         throws java.io.IOException
        Read all the data from the provided URI and return the data as a string.
        Parameters:
        requestFactory - Request factory for making the request.
        uri - the uri to load data from.
        Returns:
        the data in string form.
        Throws:
        java.io.IOException
      • toString

        public static java.lang.String toString​(MfClientHttpRequestFactory requestFactory,
                                                java.net.URL url)
                                         throws java.io.IOException
        Read all the data from the provided URI and return the data as a string.
        Parameters:
        requestFactory - Request factory for making the request.
        url - the uri to load data from.
        Returns:
        the data in string form.
        Throws:
        java.io.IOException
      • setPath

        public static java.net.URI setPath​(java.net.URI initialUri,
                                           java.lang.String path)
        Set the replace of the uri and return the new URI.
        Parameters:
        initialUri - the starting URI, the URI to update
        path - the path to set on the baeURI