01: /* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
02: * This code is licensed under the GPL 2.0 license, availible at the root
03: * application directory.
04: */
05: package org.geoserver.ows.util;
06:
07: import java.util.Collection;
08: import java.util.Map;
09: import java.util.Set;
10:
11: /**
12: * Map decorator which makes String keys case-insensitive.
13: *
14: * @author Justin Deoliveira, The Open Planning Project, jdeolive@openplans.org
15: *
16: */
17: public class CaseInsensitiveMap implements Map {
18: Map delegate;
19:
20: public CaseInsensitiveMap(Map delegate) {
21: this .delegate = delegate;
22: }
23:
24: public void clear() {
25: delegate.clear();
26: }
27:
28: public boolean containsKey(Object key) {
29: return delegate.containsKey(upper(key));
30: }
31:
32: public boolean containsValue(Object value) {
33: return delegate.containsValue(value);
34: }
35:
36: public Set entrySet() {
37: return delegate.entrySet();
38: }
39:
40: public boolean equals(Object o) {
41: return delegate.equals(o);
42: }
43:
44: public Object get(Object key) {
45: return delegate.get(upper(key));
46: }
47:
48: public int hashCode() {
49: return delegate.hashCode();
50: }
51:
52: public boolean isEmpty() {
53: return delegate.isEmpty();
54: }
55:
56: public Set keySet() {
57: return delegate.keySet();
58: }
59:
60: public Object put(Object key, Object value) {
61: return delegate.put(upper(key), value);
62: }
63:
64: public void putAll(Map t) {
65: delegate.putAll(t);
66: }
67:
68: public Object remove(Object key) {
69: return delegate.remove(upper(key));
70: }
71:
72: public int size() {
73: return delegate.size();
74: }
75:
76: public Collection values() {
77: return delegate.values();
78: }
79:
80: Object upper(Object key) {
81: if ((key != null) && key instanceof String) {
82: return ((String) key).toUpperCase();
83: }
84:
85: return key;
86: }
87: }
|