I’m looking for a Java library that evaluates REST-style URLs. Something like:
public Result evaluate(String url, String pattern);
The pattern would be something like:
/users/{userId}/photos/{photoId}.html
The result must include:
- indication if the url matches pattern
- the actual values of the url variables {userId} and {photoId}
Can anyone help, please?
By “evaluate”, do you mean some kind of unification or pattern matching by which the
urlstring is matched against thepatternstring, mapping the placeholders in the pattern to the corresponding substrings in the URL?If so, the Restlet library‘s
Templateclass may suffice. In particular, look atTemplate#parse(String, Map<String, Object>). That looks close to fitting your needs, though the documentation is a little vague as to what constitutes the input and output.