开发者

RESTful Strings matcher in Java

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:

Can anyone help, please?


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.


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


  • Jersey (JAX-RS) RI: (always maintained). http://jersey.java.net/nonav/apidocs/1.14/jersey/com/sun/jersey/api/uri/UriTemplate.html
  • Handy URI Templates: https://github.com/damnhandy/Handy-URI-Templates
  • wo-furi: A tool for URI pattern matching using the URI Templates notation. (last release: Feb 2010). http://code.google.com/p/wo-furi/
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜