tags:

views:

37

answers:

2

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?

A: 

You might already know about this, but JBoss RestEasy http://jboss.org/resteasy project handles such cases and should have classes to deal with such cases. I believe its open source and therefore you can see if its helpful

Fazal
A: 

By "evaluate", do you mean some kind of unification or pattern matching by which the url string is matched against the pattern string, mapping the placeholders in the pattern to the corresponding substrings in the URL?

If so, the Restlet library's Template class may suffice. In particular, look at Template#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.

seh
Thanks to your response, looking at the javadocs I did find the "URI Template Specification" term, which I didn't know. So I did search for "java uri template" on Google and I found some other useful options as well.
Charles Abreu