1
2
3
4
5
6
7
8 package org.hardcode.juf.update;
9
10
11
12
13
14 import java.io.IOException;
15 import java.io.Reader;
16 import java.io.Serializable;
17 import java.io.Writer;
18 import java.util.Enumeration;
19 import java.util.Vector;
20 import org.exolab.castor.xml.MarshalException;
21 import org.exolab.castor.xml.Marshaller;
22 import org.exolab.castor.xml.Unmarshaller;
23 import org.exolab.castor.xml.ValidationException;
24 import org.xml.sax.ContentHandler;
25
26 /***
27 * Class Update.
28 *
29 * @version $Revision$ $Date$
30 */
31 public class Update implements java.io.Serializable {
32
33
34
35
36
37
38 /***
39 * Field _componentName
40 */
41 private java.lang.String _componentName;
42
43 /***
44 * Field _version
45 */
46 private int _version;
47
48 /***
49 * keeps track of state for field: _version
50 */
51 private boolean _has_version;
52
53 /***
54 * Field _installer
55 */
56 private org.hardcode.juf.update.Installer _installer;
57
58 /***
59 * Field _featureList
60 */
61 private java.util.Vector _featureList;
62
63
64
65
66
67
68 public Update() {
69 super();
70 _featureList = new Vector();
71 }
72
73
74
75
76
77
78 /***
79 * Method addFeature
80 *
81 * @param vFeature
82 */
83 public void addFeature(org.hardcode.juf.update.Feature vFeature)
84 throws java.lang.IndexOutOfBoundsException
85 {
86 _featureList.addElement(vFeature);
87 }
88
89 /***
90 * Method addFeature
91 *
92 * @param index
93 * @param vFeature
94 */
95 public void addFeature(int index, org.hardcode.juf.update.Feature vFeature)
96 throws java.lang.IndexOutOfBoundsException
97 {
98 _featureList.insertElementAt(vFeature, index);
99 }
100
101 /***
102 * Method deleteVersion
103 */
104 public void deleteVersion()
105 {
106 this._has_version= false;
107 }
108
109 /***
110 * Method enumerateFeature
111 */
112 public java.util.Enumeration enumerateFeature()
113 {
114 return _featureList.elements();
115 }
116
117 /***
118 * Returns the value of field 'componentName'.
119 *
120 * @return the value of field 'componentName'.
121 */
122 public java.lang.String getComponentName()
123 {
124 return this._componentName;
125 }
126
127 /***
128 * Method getFeature
129 *
130 * @param index
131 */
132 public org.hardcode.juf.update.Feature getFeature(int index)
133 throws java.lang.IndexOutOfBoundsException
134 {
135
136 if ((index < 0) || (index > _featureList.size())) {
137 throw new IndexOutOfBoundsException();
138 }
139
140 return (org.hardcode.juf.update.Feature) _featureList.elementAt(index);
141 }
142
143 /***
144 * Method getFeature
145 */
146 public org.hardcode.juf.update.Feature[] getFeature()
147 {
148 int size = _featureList.size();
149 org.hardcode.juf.update.Feature[] mArray = new org.hardcode.juf.update.Feature[size];
150 for (int index = 0; index < size; index++) {
151 mArray[index] = (org.hardcode.juf.update.Feature) _featureList.elementAt(index);
152 }
153 return mArray;
154 }
155
156 /***
157 * Method getFeatureCount
158 */
159 public int getFeatureCount()
160 {
161 return _featureList.size();
162 }
163
164 /***
165 * Returns the value of field 'installer'.
166 *
167 * @return the value of field 'installer'.
168 */
169 public org.hardcode.juf.update.Installer getInstaller()
170 {
171 return this._installer;
172 }
173
174 /***
175 * Returns the value of field 'version'.
176 *
177 * @return the value of field 'version'.
178 */
179 public int getVersion()
180 {
181 return this._version;
182 }
183
184 /***
185 * Method hasVersion
186 */
187 public boolean hasVersion()
188 {
189 return this._has_version;
190 }
191
192 /***
193 * Method isValid
194 */
195 public boolean isValid()
196 {
197 try {
198 validate();
199 }
200 catch (org.exolab.castor.xml.ValidationException vex) {
201 return false;
202 }
203 return true;
204 }
205
206 /***
207 * Method marshal
208 *
209 * @param out
210 */
211 public void marshal(java.io.Writer out)
212 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
213 {
214
215 Marshaller.marshal(this, out);
216 }
217
218 /***
219 * Method marshal
220 *
221 * @param handler
222 */
223 public void marshal(org.xml.sax.ContentHandler handler)
224 throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
225 {
226
227 Marshaller.marshal(this, handler);
228 }
229
230 /***
231 * Method removeAllFeature
232 */
233 public void removeAllFeature()
234 {
235 _featureList.removeAllElements();
236 }
237
238 /***
239 * Method removeFeature
240 *
241 * @param index
242 */
243 public org.hardcode.juf.update.Feature removeFeature(int index)
244 {
245 java.lang.Object obj = _featureList.elementAt(index);
246 _featureList.removeElementAt(index);
247 return (org.hardcode.juf.update.Feature) obj;
248 }
249
250 /***
251 * Sets the value of field 'componentName'.
252 *
253 * @param componentName the value of field 'componentName'.
254 */
255 public void setComponentName(java.lang.String componentName)
256 {
257 this._componentName = componentName;
258 }
259
260 /***
261 * Method setFeature
262 *
263 * @param index
264 * @param vFeature
265 */
266 public void setFeature(int index, org.hardcode.juf.update.Feature vFeature)
267 throws java.lang.IndexOutOfBoundsException
268 {
269
270 if ((index < 0) || (index > _featureList.size())) {
271 throw new IndexOutOfBoundsException();
272 }
273 _featureList.setElementAt(vFeature, index);
274 }
275
276 /***
277 * Method setFeature
278 *
279 * @param featureArray
280 */
281 public void setFeature(org.hardcode.juf.update.Feature[] featureArray)
282 {
283
284 _featureList.removeAllElements();
285 for (int i = 0; i < featureArray.length; i++) {
286 _featureList.addElement(featureArray[i]);
287 }
288 }
289
290 /***
291 * Sets the value of field 'installer'.
292 *
293 * @param installer the value of field 'installer'.
294 */
295 public void setInstaller(org.hardcode.juf.update.Installer installer)
296 {
297 this._installer = installer;
298 }
299
300 /***
301 * Sets the value of field 'version'.
302 *
303 * @param version the value of field 'version'.
304 */
305 public void setVersion(int version)
306 {
307 this._version = version;
308 this._has_version = true;
309 }
310
311 /***
312 * Method unmarshal
313 *
314 * @param reader
315 */
316 public static java.lang.Object unmarshal(java.io.Reader reader)
317 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
318 {
319 return (org.hardcode.juf.update.Update) Unmarshaller.unmarshal(org.hardcode.juf.update.Update.class, reader);
320 }
321
322 /***
323 * Method validate
324 */
325 public void validate()
326 throws org.exolab.castor.xml.ValidationException
327 {
328 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
329 validator.validate(this);
330 }
331
332 }