1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.jetspeed.om.profile.psml;
18
19 import java.util.Vector;
20 import java.util.Iterator;
21
22 import org.apache.jetspeed.om.profile.*;
23
24 /***
25 * Base simple bean-like implementation of the ConfigElement interface
26 * suitable for Castor XML serialization.
27 *
28 * @author <a href="mailto:raphael@apache.org">Raphaël Luta</a>
29 * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
30 * @version $Id: PsmlConfigElement.java,v 1.6 2004/02/23 03:02:54 jford Exp $
31 */
32 public
33 {
34
35 private String name = null;
36
37 private Vector parameters = new Vector();
38
39
40 public PsmlConfigElement()
41 {}
42
43 /*** @see org.apache.jetspeed.om.registry.RegistryEntry#getName */
44 public String getName()
45 {
46 return this.name;
47 }
48
49 /*** @see org.apache.jetspeed.om.registry.RegistryEntry#setName */
50 public void setName( String name )
51 {
52 this.name = name;
53 }
54
55 /*** @return the parameters */
56 public Vector getParameters()
57 {
58 return this.parameters;
59 }
60
61 /*** Sets the parameters for this element
62 * @param parameters
63 */
64 public void setParameters(Vector parameters)
65 {
66 this.parameters = parameters;
67 }
68
69 public String getParameterValue(String name)
70 {
71 if (parameters == null)
72 return null;
73
74 for (int ix=0; ix < parameters.size(); ix++)
75 {
76 Parameter param = (Parameter)parameters.elementAt(ix);
77 if (param.getName().equals(name))
78 return param.getValue();
79 }
80 return null;
81 }
82
83 public Parameter getParameter(String name)
84 {
85 if (parameters == null)
86 return null;
87
88 for (int ix=0; ix < parameters.size(); ix++)
89 {
90 Parameter param = (Parameter)parameters.elementAt(ix);
91 if (param.getName().equals(name))
92 return param;
93 }
94 return null;
95 }
96
97 public Iterator getParameterIterator()
98 {
99 return parameters.iterator();
100 }
101
102 public Parameter getParameter(int index)
103 throws java.lang.IndexOutOfBoundsException
104 {
105
106 if ((index < 0) || (index > parameters.size())) {
107 throw new IndexOutOfBoundsException();
108 }
109
110 return (Parameter) parameters.elementAt(index);
111 }
112
113 public int getParameterCount()
114 {
115 return parameters.size();
116 }
117
118 public void removeAllParameter()
119 {
120 parameters.removeAllElements();
121 }
122
123 public Parameter removeParameter(int index)
124 {
125 Object obj = parameters.elementAt(index);
126 parameters.removeElementAt(index);
127 return (Parameter) obj;
128 }
129
130 public void setParameter(int index, Parameter vParameter)
131 throws java.lang.IndexOutOfBoundsException
132 {
133
134 if ((index < 0) || (index > parameters.size())) {
135 throw new IndexOutOfBoundsException();
136 }
137 parameters.setElementAt(vParameter, index);
138 }
139
140 public Parameter[] getParameter()
141 {
142 int size = parameters.size();
143 Parameter[] mArray = new Parameter[size];
144 for (int index = 0; index < size; index++) {
145 mArray[index] = (Parameter) parameters.elementAt(index);
146 }
147 return mArray;
148 }
149
150 public void addParameter(Parameter vParameter)
151 throws java.lang.IndexOutOfBoundsException
152 {
153 parameters.addElement(vParameter);
154 }
155
156 /***
157 * Create a clone of this object
158 */
159 public Object clone()
160 throws java.lang.CloneNotSupportedException
161 {
162 Object cloned = super.clone();
163
164
165 if (this.parameters != null)
166 {
167 ((PsmlConfigElement)cloned).parameters = new Vector(this.parameters.size());
168 Iterator it = this.parameters.iterator();
169 while (it.hasNext())
170 {
171 ((PsmlConfigElement)cloned).parameters.add((Parameter) ((Parameter)it.next()).clone());
172 }
173 }
174
175 return cloned;
176
177 }
178
179 }