Hi Tim,

I wish the Series class could implement both List<Parameter> and Map<String,
String> but some method conflicts prevent this (due to the remove() method
result param for example). 

As a compromise I've just added to SVN trunk a getValuesMap() method to the
Series class, returning a Map<String, String>. Internally it uses a
LinkedHashMap.

Having repeating parameters is not uncommon in Web forms or query strings.
For HTTP headers it is very common. I prefer to have a more complete backing
structure (List<Parameter>) even if it looks unfamiliar at first sight
rather than a simpler one (Map<String, String) because it allows me to
expose it in as many views I need (as array, as map, as encoded string,
etc.).

If you can convince me than another structure is better, I'd be happy to
reconsider the approach for Restlet API 2.0 for example! :)

Best regards,
Jerome  

> -----Message d'origine-----
> De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] De la 
> part de Tim Peierls
> Envoyé : jeudi 27 mars 2008 19:51
> À : [email protected]
> Objet : Re: Series.getValues()
> 
> List<Parameter> doesn't seem like the right abstraction, even 
> when provided as Series. Parameters seem more akin to a 
> multimap than to a sequence of key-value pairs. And for the 
> (many?) users who don't take advantage of the multiplicity 
> they are closer to regular maps. If sequence of keys is 
> important, one could use a LinkedHashMap.
> 
> But maybe this would be too much upheaval to contemplate.
> 
> --tim
> 
> 
> 
> On Tue, Mar 25, 2008 at 6:08 AM, Jerome Louvel 
> <[EMAIL PROTECTED]> wrote:
> 
> 
> 
>       Hi Paul,
>       
> 
>       > You can use List<Parameter> if you write more generic 
> utility classes:
>       >
>       
>       [...]
>       
>       >
>       > The bonuses are:
>       >
>       > 1. The "Series" class doesn't "leak" into places that
>       > shouldn't have a
>       > dependency on it since you're using an ordinary List.
>       >
>       > 2. The solution above is completely generic and can 
> be used for lots
>       > of other stuff.
>       >
>       > If you want, you can add other "Util" methods that 
> are convenience
>       > methods to lessen typing.
>       
>       
>       You filter approach is nice and very flexible. However, 
> if you call the
>       subList() method, I don't see how the Series class 
> leaks, you can do this:
>       
>       List<Parameter> fooParams = in.sublist("foo");
>       
>       You still have the Restlet Parameter class dependency 
> so you might still
>       prefer the new getValuesArray("foo") method anyway.
>       
>       Best regards,
>       Jerome
>       
>       
> 
> 
> 

Reply via email to