users@jersey.java.net

[Jersey] UriTemplate to include query string and consider order of its parameters?

From: Martynas Jusevi?ius <martynas_at_graphity.org>
Date: Fri, 5 Apr 2013 20:06:47 +0300

Hey all,

I am using UriTemplate class (mostly the match() method) with URI
templates that not only include path, but also query string, like this
one:

  /internal/basic_types?limit={limit: [0-9]+}&offset={offset:
[0-9]+}&accept={mediaType: .+}

It works and does the matching. One problem though: not suprisingly,
UriTemplate does not consider that the ordering of the query string
parameters can be arbitrary, and not necessarily exactly the same as
in the template. For example, the following URI should also match the
template above:

  /internal/basic_types?accept=application%2Fxml&offset=10&limit=20

Is there any code in Jersey (I'm currently using 1.16) that helps to
solve this issue?
UriTemplate in .NET seems to handle this case:
"The query expression, if present, specifies a series of unordered
name/value pairs delimited by '&'."
http://msdn.microsoft.com/en-us/library/bb675245.aspx

Martynas
graphity.org