net.netheos.pcsapi.utils
Class URIUtil

java.lang.Object
  extended by net.netheos.pcsapi.utils.URIUtil

public class URIUtil
extends Object

This class contains methods forked from org.apache.catalina.servlets.DefaultServlet.


Method Summary
static String encodePath(String path)
          Encode a path as required by the URL specification ( RFC 1738).
static String getQueryParameter(URI uri, String name)
          Retrieves a query param in a URL according to a key.
static Map<String,String> parseQueryParameters(String rawQuery)
          Parse a query param string into a map of parameters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

encodePath

public static String encodePath(String path)
Encode a path as required by the URL specification ( RFC 1738). This differs from java.net.URLEncoder.encode() which encodes according to the x-www-form-urlencoded MIME format.

Parameters:
path - the path to encode
Returns:
the encoded path

getQueryParameter

public static String getQueryParameter(URI uri,
                                       String name)
Retrieves a query param in a URL according to a key. If several parameters are to be retrieved from the same URI, better use parseQueryString( uri.getRawQuery() ).

Parameters:
uri -
name -
Returns:
parameter value (if found) ; null if not found or no = after name.

parseQueryParameters

public static Map<String,String> parseQueryParameters(String rawQuery)
Parse a query param string into a map of parameters. Duplicated parameters cannot be handled by this method. Parameters names not followed by '=' sign are only keys but have null value. Parameters names followed by '=' sign have an empty string value.

Parameters:
rawQuery - The query param string, as returned by URI.getRawQuery() (UTF-8 charset)
Returns:
a (mutable) map of parameters (empty map if rawQuery is null or empty). Order of parameters is kept.


Copyright © 2014. All Rights Reserved.