I want to create function which will take URL string as a parameter and return
MultivaluedHashMap<String, String> as a output. I have format of url with me through which I can construct UriTemplate class.
So basically I want to create functionality similar to requestContext.getUriInfo().getPathParameters()
So my function will be
public MultivaluedHashMap<String, String> getPathParamtersFromUrl(string url)
{
}
I am not sure how to get this. Note : I don't want to extract query parameters. I want to extract path parameters.
I was able to figure out solution after closely looking at the UriTemplate class.
private MultivaluedMap<String, String> getPathParameters(String uri, String strUrlTemplate) {
UriTemplate template = new UriTemplate(strUrlTemplate);
Map<String, String> parameters = new HashMap<>();
Boolean value = template.match(uri, parameters);
return new MultivaluedHashMap(parameters);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With