Request for comments: Bug 6306820

Alan Bateman Alan.Bateman at Sun.COM
Fri May 18 03:07:07 PDT 2007


Richard Kennard wrote:
> Dear All,
>
> Following the advice of my OpenJDK sponsor, I am submitting my patch 
> to this mailing list to ask for comments and suggestions. The patch 
> targets the following RFE:
>
>    http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6306820
>
> ...and the latest version of the code can be found here...
>
>    
> https://jdk-collaboration.dev.java.net/servlets/ProjectForumMessageView?forumID=1463&messageID=10348 
>
>
> In short, the RFE aims to provide tools to easily and safely 
> manipulate 'www-form-urlencoded' query strings within Java SE.
>
> Regards,
>
> Richard.
I know you've been talking with Michael about this one for a while but 
I'm curious to know if you've considered adding a simple utility class 
instead. That is, instead of introducing a mutual object to encapsulate 
a parameter map that you would instead just provide a few simply utility 
methods to parse and convert a map to a form encoded query string - 
maybe something like:

public final class UrlQueryStrings {
  private UrlQueryStrings() { }

  public static Map<String,List<String>> parse(String query) { .. }

  public static String toString(Map<String,List<String>> params) { .. }
}

It's just a suggestion to think about but the benefit is that the 
collection APIs can be used to manipulate the parameter map. If this 
were fleshed out then you might have variants to allow the separator be 
specified and maybe a few utility methods to combine parameter maps.

For the equivalent of your apply method then it may be worth thinking 
about adding a method to URI instead - it would be a variant of the 
resolve method that constructs a URI with the given query string - 
essentially a resolve method that deviates from the RFC in the way that 
the fragment component is preserved (which is what I think you are 
looking for here).

-Alan.









More information about the net-dev mailing list