You could always try the built-in approach:

Map m = new TreeMap(String.CASE_INSENSITIVE_ORDER);

Obviously, you'll have to decide for yourself if it's efficient enough...

Quoting "Villalba Arias, Fredy [BILBOMATICA]" <[EMAIL PROTECTED]>:

> Navjot,
> 
> I believe this is exactly what Guillermo CLEARLY stated he had already tried
> (and is not efficient enough for him).
> 
> If you had taken a little bit longer and read carefully, then maybe you'd
> have noticed.
> 
> Regards,
> Freddy.
> 
> -----Mensaje original-----
> De: Navjot Singh [mailto:[EMAIL PROTECTED] 
> Enviado el: jueves, 12 de febrero de 2004 13:14
> Para: Struts Users Mailing List; [EMAIL PROTECTED]
> Asunto: RE: [OT] Case insensitive Map keys
> 
> yes. here it is.
> 
> public CIMap extends HashMap
> {
> 
>       public Object get(String key)
>       {
>               return super.get(key.toLowerCase());
>       }
> 
>       public Object put(String key, Object value)
>       {
>               super.put(key.toLowerCase(),value);
>       }
> }
> 
> This was simple implementation. By the time you ask the Q and wait for
> reply. you could have written on your own.
> 
> Navjot Singh
> 
> 
> >-----Original Message-----
> >From: Guillermo Meyer [mailto:[EMAIL PROTECTED]
> >Sent: Thursday, February 12, 2004 5:24 PM
> >To: 'Struts Users Mailing List'
> >Subject: [OT] Case insensitive Map keys
> >
> >
> >Hi:
> >Does anyone know an implementation of Map where keys are String and case
> >insensitive?
> >I want to do this:
> >
> >map.put("propertyName", "DATA");
> >
> >And then, I should be able to get the value like this:
> >Object obj = map.get("PROPERTYNAME");
> >
> >Or like this:
> >Object obj = map.get("propertyname"); //or whatever. case insensitive.
> >
> >We tried using toUppercase when putting and toUppercase when getting,
> >and using equalsIgnoreCase but this is not as efficient as we need.
> >May there be a way to calculate a hash for strings in upper or lower
> >case to result in the same value?
> >
> >Thanks in advance.
> >
> >Guillermo.

-- 
Kris Schneider <mailto:[EMAIL PROTECTED]>
D.O.Tech       <http://www.dotech.com/>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to