01: //========================================================================
02: //$Id: AttributesMap.java,v 1.3 2005/11/14 17:45:52 gregwilkins Exp $
03: //Copyright 2004-2005 Mort Bay Consulting Pty. Ltd.
04: //------------------------------------------------------------------------
05: //Licensed under the Apache License, Version 2.0 (the "License");
06: //you may not use this file except in compliance with the License.
07: //You may obtain a copy of the License at
08: //http://www.apache.org/licenses/LICENSE-2.0
09: //Unless required by applicable law or agreed to in writing, software
10: //distributed under the License is distributed on an "AS IS" BASIS,
11: //WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: //See the License for the specific language governing permissions and
13: //limitations under the License.
14: //========================================================================
15:
16: package org.mortbay.util;
17:
18: import java.util.Collections;
19: import java.util.Enumeration;
20: import java.util.HashMap;
21: import java.util.Map;
22:
23: /* ------------------------------------------------------------ */
24: /** AttributesMap.
25: * @author gregw
26: *
27: */
28: public class AttributesMap implements Attributes {
29: Map _map;
30:
31: /* ------------------------------------------------------------ */
32: public AttributesMap() {
33: _map = new HashMap();
34: }
35:
36: /* ------------------------------------------------------------ */
37: public AttributesMap(Map map) {
38: _map = map;
39: }
40:
41: /* ------------------------------------------------------------ */
42: /*
43: * @see org.mortbay.util.Attributes#removeAttribute(java.lang.String)
44: */
45: public void removeAttribute(String name) {
46: _map.remove(name);
47: }
48:
49: /* ------------------------------------------------------------ */
50: /*
51: * @see org.mortbay.util.Attributes#setAttribute(java.lang.String, java.lang.Object)
52: */
53: public void setAttribute(String name, Object attribute) {
54: if (attribute == null)
55: _map.remove(name);
56: else
57: _map.put(name, attribute);
58: }
59:
60: /* ------------------------------------------------------------ */
61: /*
62: * @see org.mortbay.util.Attributes#getAttribute(java.lang.String)
63: */
64: public Object getAttribute(String name) {
65: return _map.get(name);
66: }
67:
68: /* ------------------------------------------------------------ */
69: /*
70: * @see org.mortbay.util.Attributes#getAttributeNames()
71: */
72: public Enumeration getAttributeNames() {
73: return Collections.enumeration(_map.keySet());
74: }
75:
76: /* ------------------------------------------------------------ */
77: /*
78: * @see org.mortbay.util.Attributes#clear()
79: */
80: public void clearAttributes() {
81: _map.clear();
82: }
83:
84: /* ------------------------------------------------------------ */
85: public String toString() {
86: return _map.toString();
87: }
88:
89: }
|