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