1
2
3
4
5
6
7
8 package org.astrogrid.registry.beans.resource.votable;
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.ArrayList;
19 import java.util.Enumeration;
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 OPTION.
28 *
29 * @version $Revision: 1.14 $ $Date: 2007/01/04 16:26:13 $
30 */
31 public class OPTION extends org.astrogrid.common.bean.BaseBean
32 implements java.io.Serializable
33 {
34
35
36
37
38
39
40 /***
41 * Field _name
42 */
43 private java.lang.String _name;
44
45 /***
46 * Field _value
47 */
48 private java.lang.String _value;
49
50 /***
51 * Field _OPTIONList
52 */
53 private java.util.ArrayList _OPTIONList;
54
55
56
57
58
59
60 public OPTION() {
61 super();
62 _OPTIONList = new ArrayList();
63 }
64
65
66
67
68
69
70 /***
71 * Method addOPTION
72 *
73 * @param vOPTION
74 */
75 public void addOPTION(org.astrogrid.registry.beans.resource.votable.OPTION vOPTION)
76 throws java.lang.IndexOutOfBoundsException
77 {
78 _OPTIONList.add(vOPTION);
79 }
80
81 /***
82 * Method addOPTION
83 *
84 * @param index
85 * @param vOPTION
86 */
87 public void addOPTION(int index, org.astrogrid.registry.beans.resource.votable.OPTION vOPTION)
88 throws java.lang.IndexOutOfBoundsException
89 {
90 _OPTIONList.add(index, vOPTION);
91 }
92
93 /***
94 * Method clearOPTION
95 */
96 public void clearOPTION()
97 {
98 _OPTIONList.clear();
99 }
100
101 /***
102 * Method enumerateOPTION
103 */
104 public java.util.Enumeration enumerateOPTION()
105 {
106 return new org.exolab.castor.util.IteratorEnumeration(_OPTIONList.iterator());
107 }
108
109 /***
110 * Note: hashCode() has not been overriden
111 *
112 * @param obj
113 */
114 public boolean equals(java.lang.Object obj)
115 {
116 if ( this == obj )
117 return true;
118
119 if (super.equals(obj)==false)
120 return false;
121
122 if (obj instanceof OPTION) {
123
124 OPTION temp = (OPTION)obj;
125 if (this._name != null) {
126 if (temp._name == null) return false;
127 else if (!(this._name.equals(temp._name)))
128 return false;
129 }
130 else if (temp._name != null)
131 return false;
132 if (this._value != null) {
133 if (temp._value == null) return false;
134 else if (!(this._value.equals(temp._value)))
135 return false;
136 }
137 else if (temp._value != null)
138 return false;
139 if (this._OPTIONList != null) {
140 if (temp._OPTIONList == null) return false;
141 else if (!(this._OPTIONList.equals(temp._OPTIONList)))
142 return false;
143 }
144 else if (temp._OPTIONList != null)
145 return false;
146 return true;
147 }
148 return false;
149 }
150
151 /***
152 * Returns the value of field 'name'.
153 *
154 * @return the value of field 'name'.
155 */
156 public java.lang.String getName()
157 {
158 return this._name;
159 }
160
161 /***
162 * Method getOPTION
163 *
164 * @param index
165 */
166 public org.astrogrid.registry.beans.resource.votable.OPTION getOPTION(int index)
167 throws java.lang.IndexOutOfBoundsException
168 {
169
170 if ((index < 0) || (index > _OPTIONList.size())) {
171 throw new IndexOutOfBoundsException();
172 }
173
174 return (org.astrogrid.registry.beans.resource.votable.OPTION) _OPTIONList.get(index);
175 }
176
177 /***
178 * Method getOPTION
179 */
180 public org.astrogrid.registry.beans.resource.votable.OPTION[] getOPTION()
181 {
182 int size = _OPTIONList.size();
183 org.astrogrid.registry.beans.resource.votable.OPTION[] mArray = new org.astrogrid.registry.beans.resource.votable.OPTION[size];
184 for (int index = 0; index < size; index++) {
185 mArray[index] = (org.astrogrid.registry.beans.resource.votable.OPTION) _OPTIONList.get(index);
186 }
187 return mArray;
188 }
189
190 /***
191 * Method getOPTIONCount
192 */
193 public int getOPTIONCount()
194 {
195 return _OPTIONList.size();
196 }
197
198 /***
199 * Returns the value of field 'value'.
200 *
201 * @return the value of field 'value'.
202 */
203 public java.lang.String getValue()
204 {
205 return this._value;
206 }
207
208 /***
209 * Method isValid
210 */
211 public boolean isValid()
212 {
213 try {
214 validate();
215 }
216 catch (org.exolab.castor.xml.ValidationException vex) {
217 return false;
218 }
219 return true;
220 }
221
222 /***
223 * Method marshal
224 *
225 * @param out
226 */
227 public void marshal(java.io.Writer out)
228 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
229 {
230
231 Marshaller.marshal(this, out);
232 }
233
234 /***
235 * Method marshal
236 *
237 * @param handler
238 */
239 public void marshal(org.xml.sax.ContentHandler handler)
240 throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
241 {
242
243 Marshaller.marshal(this, handler);
244 }
245
246 /***
247 * Method removeOPTION
248 *
249 * @param vOPTION
250 */
251 public boolean removeOPTION(org.astrogrid.registry.beans.resource.votable.OPTION vOPTION)
252 {
253 boolean removed = _OPTIONList.remove(vOPTION);
254 return removed;
255 }
256
257 /***
258 * Sets the value of field 'name'.
259 *
260 * @param name the value of field 'name'.
261 */
262 public void setName(java.lang.String name)
263 {
264 this._name = name;
265 }
266
267 /***
268 * Method setOPTION
269 *
270 * @param index
271 * @param vOPTION
272 */
273 public void setOPTION(int index, org.astrogrid.registry.beans.resource.votable.OPTION vOPTION)
274 throws java.lang.IndexOutOfBoundsException
275 {
276
277 if ((index < 0) || (index > _OPTIONList.size())) {
278 throw new IndexOutOfBoundsException();
279 }
280 _OPTIONList.set(index, vOPTION);
281 }
282
283 /***
284 * Method setOPTION
285 *
286 * @param OPTIONArray
287 */
288 public void setOPTION(org.astrogrid.registry.beans.resource.votable.OPTION[] OPTIONArray)
289 {
290
291 _OPTIONList.clear();
292 for (int i = 0; i < OPTIONArray.length; i++) {
293 _OPTIONList.add(OPTIONArray[i]);
294 }
295 }
296
297 /***
298 * Sets the value of field 'value'.
299 *
300 * @param value the value of field 'value'.
301 */
302 public void setValue(java.lang.String value)
303 {
304 this._value = value;
305 }
306
307 /***
308 * Method unmarshalOPTION
309 *
310 * @param reader
311 */
312 public static org.astrogrid.registry.beans.resource.votable.OPTION unmarshalOPTION(java.io.Reader reader)
313 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
314 {
315 return (org.astrogrid.registry.beans.resource.votable.OPTION) Unmarshaller.unmarshal(org.astrogrid.registry.beans.resource.votable.OPTION.class, reader);
316 }
317
318 /***
319 * Method validate
320 */
321 public void validate()
322 throws org.exolab.castor.xml.ValidationException
323 {
324 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
325 validator.validate(this);
326 }
327
328 }