You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Guillermo Meyer <gm...@interbanking.com.ar> on 2004/02/12 12:54:26 UTC

[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.


NOTA DE CONFIDENCIALIDAD
Este mensaje (y sus anexos) es confidencial, esta dirigido exclusivamente a las personas direccionadas en el mail y puede contener informacion (i)de propiedad exclusiva de Interbanking S.A. o (ii) amparada por el secreto profesional. Cualquier opinion en el contenido, es exclusiva de su autor y no representa necesariamente la opinion de Interbanking S.A. El acceso no autorizado, uso, reproduccion, o divulgacion esta prohibido. Interbanking S.A no asumira responsabilidad ni obligacion legal alguna por cualquier informacion incorrecta o alterada contenida en este mensaje. Si usted ha recibido este mensaje por error, le rogamos tenga la amabilidad de destruirlo inmediatamente junto con todas las copias del mismo, notificando al remitente. No debera utilizar, revelar, distribuir, imprimir o copiar este mensaje ni ninguna de sus partes si usted no es el destinatario. Muchas gracias.

RE: [OT] Case insensitive Map keys

Posted by Navjot Singh <na...@net4india.net>.
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:gmeyer@interbanking.com.ar]
>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.
>
>
>NOTA DE CONFIDENCIALIDAD
>Este mensaje (y sus anexos) es confidencial, esta dirigido
>exclusivamente a las personas direccionadas en el mail y puede
>contener informacion (i)de propiedad exclusiva de Interbanking
>S.A. o (ii) amparada por el secreto profesional. Cualquier opinion
>en el contenido, es exclusiva de su autor y no representa
>necesariamente la opinion de Interbanking S.A. El acceso no
>autorizado, uso, reproduccion, o divulgacion esta prohibido.
>Interbanking S.A no asumira responsabilidad ni obligacion legal
>alguna por cualquier informacion incorrecta o alterada contenida
>en este mensaje. Si usted ha recibido este mensaje por error, le
>rogamos tenga la amabilidad de destruirlo inmediatamente junto con
>todas las copias del mismo, notificando al remitente. No debera
>utilizar, revelar, distribuir, imprimir o copiar este mensaje ni
>ninguna de sus partes si usted no es el destinatario. Muchas gracias.
>


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