You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by sebb <se...@gmail.com> on 2010/12/14 23:25:51 UTC
HttpParams read-only access as Set
I've now committed a version of the HttpParams hierarchy using the new
HttpParamsSet interface.
I chose to stay with entrySet(), rather than iterator(), as that gives
a bit more flexibility.
The key question is: do we actually want to keep this new interface?
[If not, it's easy enough to remove]
If so, is the current API OK?
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org
Re: HttpParams read-only access as Set
Posted by Oleg Kalnichevski <ol...@apache.org>.
On Wed, 2010-12-15 at 19:12 +0000, sebb wrote:
> On 15 December 2010 15:26, Oleg Kalnichevski <ol...@apache.org> wrote:
> > ...
> >
> >> In the case of DefaultedHttpParams, I think the local names should
> >> also be made available, e.g. through a method such as getLocalNames().
> >> But the default getNames() should include all names.
> >>
>
> It's easy create a new Set with the current set of names - much harder
> to create a read-only Set that tracks subsequent changes to both local
> and default sets - so I propose to create a new Set in each case, i.e.
> the Sets will be a snapshot of the current names.
>
> This also completely decouples the output from the implementation.
>
> I've updated SVN accordingly.
>
Looks ok to me.
Oleg
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org
Re: HttpParams read-only access as Set
Posted by sebb <se...@gmail.com>.
On 15 December 2010 15:26, Oleg Kalnichevski <ol...@apache.org> wrote:
> ...
>
>> In the case of DefaultedHttpParams, I think the local names should
>> also be made available, e.g. through a method such as getLocalNames().
>> But the default getNames() should include all names.
>>
It's easy create a new Set with the current set of names - much harder
to create a read-only Set that tracks subsequent changes to both local
and default sets - so I propose to create a new Set in each case, i.e.
the Sets will be a snapshot of the current names.
This also completely decouples the output from the implementation.
I've updated SVN accordingly.
>> The default names can be easily extracted using getDefaults().getNames().
>>
>> Though I do wonder why the getDefaults() method is present: given that
>> defaults are supposed to be immutable, it seems odd to expose the
>> field and thus permit updates to it.
>>
>> Perhaps the method should be deprecated?
>> Or maybe the method should return an immutable view of the defaults?
>>
>
> Agreed. Feel free to deprecate it.
OK, done.
> Oleg
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
> For additional commands, e-mail: dev-help@hc.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org
Re: HttpParams read-only access as Set
Posted by Oleg Kalnichevski <ol...@apache.org>.
...
> In the case of DefaultedHttpParams, I think the local names should
> also be made available, e.g. through a method such as getLocalNames().
> But the default getNames() should include all names.
>
> The default names can be easily extracted using getDefaults().getNames().
>
> Though I do wonder why the getDefaults() method is present: given that
> defaults are supposed to be immutable, it seems odd to expose the
> field and thus permit updates to it.
>
> Perhaps the method should be deprecated?
> Or maybe the method should return an immutable view of the defaults?
>
Agreed. Feel free to deprecate it.
Oleg
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org
Re: HttpParams read-only access as Set
Posted by sebb <se...@gmail.com>.
On 15 December 2010 09:34, Oleg Kalnichevski <ol...@apache.org> wrote:
> On Tue, 2010-12-14 at 22:25 +0000, sebb wrote:
>> I've now committed a version of the HttpParams hierarchy using the new
>> HttpParamsSet interface.
>> I chose to stay with entrySet(), rather than iterator(), as that gives
>> a bit more flexibility.
>>
>> The key question is: do we actually want to keep this new interface?
>> [If not, it's easy enough to remove]
>>
>> If so, is the current API OK?
>>
>
> I personally would prefer to have an interface that returns a set of
> parameter names instead of a set of Map.Entry-s.
Which could be done by returning keySet() instead of entrySet() in the
case of BasicHttpParams.
The public method could be called getNames().
> The existing interface
> exposes too much of implementation details to my liking.
HttpParams is defined in terms of name-value pairs.
The normal way to model that is a Map, and the entrySet() follows
naturally from that.
So I don't see how it exposes implementation details.
> Another benefit
> of using a set of parameter names would be that stacked HttpParams
> implementations (such as DefaultedHttpParams) could return a joint set
> of all parameters present in the hierarchy.
That is a good point.
It would be harder to do this using entrySet().
Given that retrieving all the values is not performance critical, I
would be happy with names only, i.e. add a getNames() method instead
of entrySet()
In the case of DefaultedHttpParams, I think the local names should
also be made available, e.g. through a method such as getLocalNames().
But the default getNames() should include all names.
The default names can be easily extracted using getDefaults().getNames().
Though I do wonder why the getDefaults() method is present: given that
defaults are supposed to be immutable, it seems odd to expose the
field and thus permit updates to it.
Perhaps the method should be deprecated?
Or maybe the method should return an immutable view of the defaults?
> I can live with the interface in its present form, though, if you prefer
> it this way.
>
> One kind request, though. Could you please remove reference to
> AbstractHttpParams from DefaultedHttpParams#entrySet() javadocs?
Oops - fixed.
> Cheers
>
> Oleg
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
> For additional commands, e-mail: dev-help@hc.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org
Re: HttpParams read-only access as Set
Posted by Oleg Kalnichevski <ol...@apache.org>.
On Tue, 2010-12-14 at 22:25 +0000, sebb wrote:
> I've now committed a version of the HttpParams hierarchy using the new
> HttpParamsSet interface.
> I chose to stay with entrySet(), rather than iterator(), as that gives
> a bit more flexibility.
>
> The key question is: do we actually want to keep this new interface?
> [If not, it's easy enough to remove]
>
> If so, is the current API OK?
>
I personally would prefer to have an interface that returns a set of
parameter names instead of a set of Map.Entry-s. The existing interface
exposes too much of implementation details to my liking. Another benefit
of using a set of parameter names would be that stacked HttpParams
implementations (such as DefaultedHttpParams) could return a joint set
of all parameters present in the hierarchy.
I can live with the interface in its present form, though, if you prefer
it this way.
One kind request, though. Could you please remove reference to
AbstractHttpParams from DefaultedHttpParams#entrySet() javadocs?
Cheers
Oleg
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org