Package com.ibm.fhir.core.util
Class URLSupport
- java.lang.Object
-
- com.ibm.fhir.core.util.URLSupport
-
public class URLSupport extends java.lang.Object
A utility class for working with URLs
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String
decode(java.lang.String s)
URL decode the input stringstatic java.lang.String
getFirst(java.util.Map<java.lang.String,java.util.List<java.lang.String>> map, java.lang.String key)
Get the first value of the list for the specified key from the provided multivalued mapstatic java.lang.String
getPath(java.lang.String url)
Get the path part of the provided URLstatic java.util.List<java.lang.String>
getPathSegments(java.lang.String url)
Get a list containing the path segments from the provided URLstatic java.util.List<java.lang.String>
getPathSegments(java.lang.String url, boolean decode)
Get a list containing the path segments from the provided URLstatic java.lang.String
getQuery(java.lang.String url)
Get the query part of the provided URLstatic java.util.Map<java.lang.String,java.util.List<java.lang.String>>
getQueryParameters(java.lang.String url)
Get a multivalued map containing the query parameters for the provided URLstatic java.util.Map<java.lang.String,java.util.List<java.lang.String>>
getQueryParameters(java.lang.String url, boolean decode)
Get a multivalued map containing the query parameters for the provided URLstatic java.net.URL
getURL(java.lang.String url)
Get aURL
instance that represents the specified parameterstatic java.util.List<java.lang.String>
parsePath(java.lang.String path)
Parse the provided path part into a List of path segmentsstatic java.util.List<java.lang.String>
parsePath(java.lang.String path, boolean decode)
Parse the provided path part into a list of path segmentsstatic java.util.Map<java.lang.String,java.util.List<java.lang.String>>
parseQuery(java.lang.String query)
Parse the provided query part into a multivalued map of query parametersstatic java.util.Map<java.lang.String,java.util.List<java.lang.String>>
parseQuery(java.lang.String query, boolean decode)
Parse the provided query part into a multivalued map of query parameters
-
-
-
Method Detail
-
decode
public static java.lang.String decode(java.lang.String s)
URL decode the input string- Parameters:
s
- the string to URL decode- Returns:
- the URL decoded string
-
getFirst
public static java.lang.String getFirst(java.util.Map<java.lang.String,java.util.List<java.lang.String>> map, java.lang.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 java.lang.String getPath(java.lang.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 java.util.List<java.lang.String> getPathSegments(java.lang.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 java.util.List<java.lang.String> getPathSegments(java.lang.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 java.lang.String getQuery(java.lang.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 java.util.Map<java.lang.String,java.util.List<java.lang.String>> getQueryParameters(java.lang.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 java.util.Map<java.lang.String,java.util.List<java.lang.String>> getQueryParameters(java.lang.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 java.net.URL getURL(java.lang.String url)
Get aURL
instance that represents the specified parameter- Parameters:
url
- the url- Returns:
- a
URL
instance that represents the specified parameter - See Also:
URL
-
parsePath
public static java.util.List<java.lang.String> parsePath(java.lang.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 java.util.List<java.lang.String> parsePath(java.lang.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 java.util.Map<java.lang.String,java.util.List<java.lang.String>> parseQuery(java.lang.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 java.util.Map<java.lang.String,java.util.List<java.lang.String>> parseQuery(java.lang.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
-
-