2009/05/20 - Apache Shale has been retired.
For more information, please explore the Attic.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.apache.shale.clay.config.beans;
22
23 import java.util.TreeMap;
24
25 /***
26 * <p>Normalize the case of a String key to lower case making
27 * the collection case insensitive.</p>
28 */
29 public class Attributes extends TreeMap {
30
31 /***
32 * <p>Unique serial id.</p>
33 */
34 private static final long serialVersionUID = 3905244515647173938L;
35
36 /***
37 * <p>Make the key case insensitive.</p>
38 *
39 * @param key attribute key
40 * @return <code>true</code> if key is contained
41 */
42 public boolean containsKey(Object key) {
43 Object normKey = null;
44
45 if (key != null && key instanceof String) {
46 normKey = ((String) key).toLowerCase();
47 } else {
48 normKey = key;
49 }
50
51 return super.containsKey(normKey);
52 }
53
54 /***
55 * <p>Make the key case insensitive.</p>
56 *
57 * @param key attribute name
58 * @return value
59 */
60 public Object get(Object key) {
61 Object normKey = null;
62 if (key != null && key instanceof String) {
63 normKey = ((String) key).toLowerCase();
64 } else {
65 normKey = key;
66 }
67
68 return super.get(normKey);
69 }
70
71 /***
72 * <p>Make the key case insensitive.</p>
73 *
74 * @param key attribute name
75 * @param value attribute value
76 *
77 * @return original value
78 */
79 public Object put(Object key, Object value) {
80 Object normKey = null;
81 if (key != null && key instanceof String) {
82 normKey = ((String) key).toLowerCase();
83 } else {
84 normKey = key;
85 }
86
87 return super.put(normKey, value);
88 }
89
90 }