1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.struts.tiles.xmlDefinition;
21
22 import java.util.ArrayList;
23 import java.util.List;
24
25
26 /***
27 * An attribute as a <code>List</code>.
28 * This attribute associates a name with a list. The list can be found by the
29 * property name.
30 * Elements in list are retrieved using List methods.
31 * This class is used to read configuration files.
32 */
33 public class XmlListAttribute extends XmlAttribute
34 {
35 /*** List.
36 * We declare a List to avoid cast.
37 * Parent "value" property points to the same list.
38 */
39 private List list;
40
41 /***
42 * Constructor.
43 */
44 public XmlListAttribute()
45 {
46 list = new ArrayList();
47 setValue(list);
48 }
49
50 /***
51 * Constructor.
52 * @param name Name.
53 * @param value List.
54 */
55 public XmlListAttribute( String name, List value)
56 {
57 super( name, value );
58 list = value;
59 }
60
61 /***
62 * Add an element in list.
63 * We use a property to avoid rewriting a new class.
64 * @param element XmlAttribute to add.
65 */
66 public void add( XmlAttribute element )
67 {
68 list.add( element.getValue() );
69 }
70
71 /***
72 * Add an element in list.
73 * @param value Object to add.
74 */
75 public void add( Object value )
76 {
77
78
79
80 if(value instanceof XmlAttribute)
81 {
82 add((XmlAttribute)value);
83 return;
84 }
85 else
86 list.add( value );
87 }
88
89 /***
90 * Add an element in list.
91 * @param value Object to add.
92 */
93 public void addObject( Object value )
94 {
95 list.add( value );
96 }
97
98
99
100 }