1 | /* |
2 | * Copyright 2004-2014 H2 Group. Multiple-Licensed under the MPL 2.0, |
3 | * and the EPL 1.0 (http://h2database.com/html/license.html). |
4 | * Initial Developer: H2 Group |
5 | */ |
6 | package org.h2.value; |
7 | |
8 | import java.util.HashMap; |
9 | import org.h2.util.StringUtils; |
10 | |
11 | /** |
12 | * A hash map with a case-insensitive string key. |
13 | * |
14 | * @param <V> the value type |
15 | */ |
16 | public class CaseInsensitiveMap<V> extends HashMap<String, V> { |
17 | |
18 | private static final long serialVersionUID = 1L; |
19 | |
20 | @Override |
21 | public V get(Object key) { |
22 | return super.get(toUpper(key)); |
23 | } |
24 | |
25 | @Override |
26 | public V put(String key, V value) { |
27 | return super.put(toUpper(key), value); |
28 | } |
29 | |
30 | @Override |
31 | public boolean containsKey(Object key) { |
32 | return super.containsKey(toUpper(key)); |
33 | } |
34 | |
35 | @Override |
36 | public V remove(Object key) { |
37 | return super.remove(toUpper(key)); |
38 | } |
39 | |
40 | private static String toUpper(Object key) { |
41 | return key == null ? null : StringUtils.toUpperEnglish(key.toString()); |
42 | } |
43 | |
44 | } |