Request for comments: Bug 6306820
Richard Kennard
richard at kennardconsulting.com
Sun May 20 15:53:14 PDT 2007
Alan,
Thanks for your prompt reply! I appreciate you keeping this moving.
1. I would like to postpone the issues of method chaining and URI/URL
creation to another discussion, if that's okay.
2. So what we are debating between here is...
public UrlQueryString {
private UrlQueryString();
public static UrlQueryString create();
public static UrlQueryString parse(CharSequence query);
...
}
...versus...
public UrlQueryString {
public UrlQueryString()
public UrlQueryString(CharSequence query)
...
}
While both are roughly equivalent, I guess the latter seems more
'normal' to me, and more in keeping with the rest of the JDK?
Just so you know where I'm coming from - I am no longer thinking this
class should be any kind of builder or factory, rather I think it should
simply model a 'www-form-urlencoded' query string.
Regards,
Richard.
Alan Bateman wrote:
> Richard Kennard wrote:
>> :
>>
>> So, can we agree a regular class is better than a utility class?
> That seems reasonable to me. I just suggested thinking about a utility
> class given that this is mostly about manipulating a map of
> parameters. Some aspects of the builder pattern are probably useful
> here but if I were creating it then I would keep it very simple and
> probably suggest something like this:
>
> public class UrlQueryString {
> private UrlQueryString() { }
> public static UrlQueryString create()
> public static UrlQueryString parse(CharSequence query)
> public String get(String name)
> public List<String> getAll(String name)
> public UrlQueryString set(String name, String... value)
> public UrlQueryString set(String name, List<String> values)
> public UrlQueryString add(String name, String... value)
> public UrlQueryString add(String name, List<String> values)
> public UrlQueryString add(UrlQueryString other)
>
> public UrlQueryString add(CharSequence other)
> public UrlQueryString remove(String name)
> public String toString()
> public Map<String,List<String>> toMap() }
>
> This isn't too different from what you have except that the object is
> created with static factory methods rather than public constructors,
> it allows for method chaining, and it doesn't do the URL/URI creation.
> For the latter I would suggest looking into adding static methods to
> java.net.URI to allow URIs be created from various URI and component
> combinations. Does that seem reasonable?
>
> -Alan.
>
>
>
More information about the net-dev
mailing list