1 package org.apache.torque.util;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.commons.collections.map.ListOrderedMap;
23
24 /***
25 * A subclass of the Apache Commons ListOrderedMap that has case insensitive
26 * String key methods. This is done by converting all String keys to
27 * lower case.
28 *
29 * @author <a href="mailto:greg.monroe@dukece.com">Greg Monroe</a>
30 * @version $Id$
31 */
32 public class ListOrderedMapCI extends ListOrderedMap
33 {
34 private static final long serialVersionUID = -4349246328751938554L;
35
36 /***
37 * Constructs a new empty ListOrderedMap.
38 */
39 public ListOrderedMapCI() {
40 super();
41 }
42
43 /***
44 * Get the object associated with this key.
45 *
46 * @param key A case insensitive String.
47 * @return The value for this key
48 */
49 public Object get( String key ) {
50 return super.get( key.toLowerCase() );
51 }
52 /***
53 * Adds a value to the end of the list with the specified key.
54 *
55 * @param key A case insensitive String.
56 * @param value The value to add
57 * @return The value for previously mapped to this key
58 */
59 public Object put( String key, Object value ) {
60 return super.put( key.toLowerCase(), value );
61 }
62 /***
63 * Puts a key-value mapping into the map at the specified index.
64 *
65 * @param index The index at which the mapping should be inserted.
66 * @param key A case insensitive String.
67 * @param value The value.
68 * @return The value for previously mapped to this key
69 */
70 public Object put( int index, String key, Object value ) {
71 return super.put(index, key.toLowerCase(), value );
72 }
73 /***
74 * Gets the index of the specified key.
75 *
76 * @param key A case insensitive String.
77 * @return the index, or -1 if not found
78 */
79 public int indexOf( String key ) {
80 return super.indexOf( key.toLowerCase() );
81 }
82 /***
83 * Removes the mapping for the specified key.
84 * @param key A case insensitive String.
85 * @return the removed value, or null if none existed
86 */
87 public Object remove ( String key ) {
88 return super.remove( key.toLowerCase() );
89 }
90 /***
91 * Test if the key exists in the mapping.
92 *
93 * @param key The case insensitive key to test for.
94 * @return True if the key exists.
95 */
96 public boolean containsKey( String key ) {
97 return super.containsKey( key.toLowerCase());
98 }
99 }