Package com.ibm.fhir.core.util
Class URLSupport
- java.lang.Object
-
- com.ibm.fhir.core.util.URLSupport
-
public class URLSupport extends Object
A utility class for working with URLs
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
decode(String s)
URL decode the input stringstatic String
getFirst(Map<String,List<String>> map, String key)
Get the first value of the list for the specified key from the provided multivalued mapstatic String
getPath(String url)
Get the path part of the provided URLstatic List<String>
getPathSegments(String url)
Get a list containing the path segments from the provided URLstatic List<String>
getPathSegments(String url, boolean decode)
Get a list containing the path segments from the provided URLstatic String
getQuery(String url)
Get the query part of the provided URLstatic Map<String,List<String>>
getQueryParameters(String url)
Get a multivalued map containing the query parameters for the provided URLstatic Map<String,List<String>>
getQueryParameters(String url, boolean decode)
Get a multivalued map containing the query parameters for the provided URLstatic URL
getURL(String url)
Get aURL
instance that represents the specified parameterstatic List<String>
parsePath(String path)
Parse the provided path part into a List of path segmentsstatic List<String>
parsePath(String path, boolean decode)
Parse the provided path part into a list of path segmentsstatic Map<String,List<String>>
parseQuery(String query)
Parse the provided query part into a multivalued map of query parametersstatic Map<String,List<String>>
parseQuery(String query, boolean decode)
Parse the provided query part into a multivalued map of query parameters
-
-
-
Method Detail
-
decode
public static String decode(String s)
URL decode the input string- Parameters:
s
- the string to URL decode- Returns:
- the URL decoded string
-
getFirst
public static String getFirst(Map<String,List<String>> map, String key)
Get the first value of the list for the specified key from the provided multivalued map- Parameters:
map
- the multivalued mapkey
- the key- Returns:
- the first value of the list for the specified key from the provided multivalued map or null if not exists
-
getPath
public static String getPath(String url)
Get the path part of the provided URL- Parameters:
url
- the url- Returns:
- the path part or empty if not exists
- See Also:
URL.getPath()
-
getPathSegments
public static List<String> getPathSegments(String url)
Get a list containing the path segments from the provided URLThe path segments are URL decoded
- Parameters:
url
- the url- Returns:
- a list containing the path segments from the provided URL
-
getPathSegments
public static List<String> getPathSegments(String url, boolean decode)
Get a list containing the path segments from the provided URLThe path segments are URL decoded according to the specified parameter
- Parameters:
url
- the urldecode
- indicates whether to decode the path segments- Returns:
- a list containing the path segments from the provided URL
-
getQuery
public static String getQuery(String url)
Get the query part of the provided URL- Parameters:
url
- the URL- Returns:
- the query part of the provided URL or empty if not exists
- See Also:
URL.getQuery()
-
getQueryParameters
public static Map<String,List<String>> getQueryParameters(String url)
Get a multivalued map containing the query parameters for the provided URLThe keys and values of the multivalued map are URL decoded
- Parameters:
url
- the URL- Returns:
- a multivalued map containing the query parameters for the provided URL
-
getQueryParameters
public static Map<String,List<String>> getQueryParameters(String url, boolean decode)
Get a multivalued map containing the query parameters for the provided URLThe keys and values of the multivalued map are URL decoded according the specified parameter
- Parameters:
url
- the URLdecode
- indicates whether to decode the keys and values of the multivalued map should be decoded- Returns:
- a multivalued map containing the query parameters for the provided URL
-
getURL
public static URL getURL(String url)
Get aURL
instance that represents the specified parameter
-
parsePath
public static List<String> parsePath(String path)
Parse the provided path part into a List of path segmentsThe path segments are URL decoded
- Parameters:
path
- the path part- Returns:
- a list of path segments
-
parsePath
public static List<String> parsePath(String path, boolean decode)
Parse the provided path part into a list of path segmentsThe path segments are decoded according to the specified parameter
- Parameters:
path
- the path partdecode
- indicates whether the path segments should be URL decoded- Returns:
- a list of path segments
-
parseQuery
public static Map<String,List<String>> parseQuery(String query)
Parse the provided query part into a multivalued map of query parametersThe keys and values of the multivalued map are URL decoded
- Parameters:
query
- the query part- Returns:
- a multivalued map containing the query parameters for the provided URL
-
parseQuery
public static Map<String,List<String>> parseQuery(String query, boolean decode)
Parse the provided query part into a multivalued map of query parametersThe keys and values of the multivalued map are URL decoded according to the specified parameter
- Parameters:
query
- the query partdecode
- indicates whether to decode the keys and values of the multivalued map should be decoded- Returns:
- a multivalued map containing the query parameters for the provided URL
-
-