commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Phil Steitz" <p...@steitz.com>
Subject Re: [collections] CaseInsensitiveHashMap
Date Fri, 02 Jan 2004 16:41:16 GMT
scolebourne@btopenworld.com wrote:
>> from:    Phil Steitz <phil@steitz.com>
>>1. I made no attempt to handle or mask nulls -- puts with null keys will 
>>throw NPEs.
> 
> This seems harsh. I would prefer to support nulls if possible.

OK.  No problem.
> 
> 
>>2. I made no attempt at allowing the locale to be set or otherwise 
>>changing the default behavior of toLower() in convert().
> 
> I'm wondering how your implementation works. I was expecting the isEqualKey() method
to be overridden, rather than converting the key on add. (Note that the same code also has
to go in a MapEntry)
> 
Could be I was being too lazy.  Since toLower() is "idempotent" (calling 
it repeatedly has same effect as calling it just once) it "works" to just 
override convert(), since in AbstractHashedMap, get, put, remove, 
containsKey, all start by converting the key (nice!).  All I did was to 
extend HashedMap and override convert to return 
key.toString().toLowerCase().  The effect is that you actually store all 
lower case strings as keys (or null, once I fix this). The behavior should 
be the same as the impl that David Graham posted with PR #24537 (unless I 
am missing something -- quite possible).
> 
>>3. I need the secret recipe for making the "canonical serialized object 
>>file" so that I don't have to dummy out the "compatability" tests (or not 
>>:)  Is this documented somewhere?
> 
> Its commented out in the bottom of some of the tests. (HashedMap?)

Ah...I was wondering what that cruft was about ;)
Thanks.

Phil
> 
> Stephen
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message