1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.jelly;
18
19 import java.util.HashMap;
20
21 import java.util.Map;
22
23 /***
24 * <p><code>MapTag</code> is a DynaTag implementation which uses a Map
25 * to store its attribute values in. Derived tags can then process this
26 * Map, change values, add or remove attributes or perform some other form
27 * of processsing pretty easily.
28 * </p>
29 *
30 * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
31 * @version $Revision: 155420 $
32 */
33
34 public abstract class MapTagSupport extends DynaTagSupport {
35
36 private Map map;
37
38 /*** Sets an attribute value of this tag before the tag is invoked
39 */
40 public void setAttribute(String name, Object value) {
41 getAttributes().put(name, value);
42 }
43
44 /***
45 * Helper method which allows derived tags to access the attributes
46 * associated with this tag
47 */
48 protected Map getAttributes() {
49 if (map == null) {
50 map = createAttributes();
51 }
52 return map;
53 }
54 /***
55 * A Factory Method which allows derived tags to overload the Map
56 * implementation used by this tag
57 */
58
59 protected Map createAttributes() {
60 return new HashMap();
61 }
62
63 }