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.astrogrid.registry.beans.resource.votable.types.DataType;
21 import org.astrogrid.registry.beans.resource.votable.types.FIELDItemTypeType;
22 import org.exolab.castor.xml.MarshalException;
23 import org.exolab.castor.xml.Marshaller;
24 import org.exolab.castor.xml.Unmarshaller;
25 import org.exolab.castor.xml.ValidationException;
26 import org.xml.sax.ContentHandler;
27
28 /***
29 * Class FIELD.
30 *
31 * @version $Revision: 1.14 $ $Date: 2007/01/04 16:26:13 $
32 */
33 public class FIELD extends org.astrogrid.common.bean.BaseBean
34 implements java.io.Serializable
35 {
36
37
38
39
40
41
42 /***
43 * Field _ID
44 */
45 private java.lang.String _ID;
46
47 /***
48 * Field _unit
49 */
50 private java.lang.String _unit;
51
52 /***
53 * Field _datatype
54 */
55 private org.astrogrid.registry.beans.resource.votable.types.DataType _datatype;
56
57 /***
58 * Field _precision
59 */
60 private java.lang.String _precision;
61
62 /***
63 * Field _width
64 */
65 private int _width;
66
67 /***
68 * keeps track of state for field: _width
69 */
70 private boolean _has_width;
71
72 /***
73 * Field _ref
74 */
75 private java.lang.Object _ref;
76
77 /***
78 * Field _name
79 */
80 private java.lang.String _name;
81
82 /***
83 * Field _ucd
84 */
85 private java.lang.String _ucd;
86
87 /***
88 * Field _arraysize
89 */
90 private java.lang.String _arraysize;
91
92 /***
93 * Field _type
94 */
95 private org.astrogrid.registry.beans.resource.votable.types.FIELDItemTypeType _type;
96
97 /***
98 * Field _items
99 */
100 private java.util.ArrayList _items;
101
102
103
104
105
106
107 public FIELD() {
108 super();
109 _items = new ArrayList();
110 }
111
112
113
114
115
116
117 /***
118 * Method addFIELDItem
119 *
120 * @param vFIELDItem
121 */
122 public void addFIELDItem(org.astrogrid.registry.beans.resource.votable.FIELDItem vFIELDItem)
123 throws java.lang.IndexOutOfBoundsException
124 {
125 _items.add(vFIELDItem);
126 }
127
128 /***
129 * Method addFIELDItem
130 *
131 * @param index
132 * @param vFIELDItem
133 */
134 public void addFIELDItem(int index, org.astrogrid.registry.beans.resource.votable.FIELDItem vFIELDItem)
135 throws java.lang.IndexOutOfBoundsException
136 {
137 _items.add(index, vFIELDItem);
138 }
139
140 /***
141 * Method clearFIELDItem
142 */
143 public void clearFIELDItem()
144 {
145 _items.clear();
146 }
147
148 /***
149 * Method deleteWidth
150 */
151 public void deleteWidth()
152 {
153 this._has_width= false;
154 }
155
156 /***
157 * Method enumerateFIELDItem
158 */
159 public java.util.Enumeration enumerateFIELDItem()
160 {
161 return new org.exolab.castor.util.IteratorEnumeration(_items.iterator());
162 }
163
164 /***
165 * Note: hashCode() has not been overriden
166 *
167 * @param obj
168 */
169 public boolean equals(java.lang.Object obj)
170 {
171 if ( this == obj )
172 return true;
173
174 if (super.equals(obj)==false)
175 return false;
176
177 if (obj instanceof FIELD) {
178
179 FIELD temp = (FIELD)obj;
180 if (this._ID != null) {
181 if (temp._ID == null) return false;
182 else if (!(this._ID.equals(temp._ID)))
183 return false;
184 }
185 else if (temp._ID != null)
186 return false;
187 if (this._unit != null) {
188 if (temp._unit == null) return false;
189 else if (!(this._unit.equals(temp._unit)))
190 return false;
191 }
192 else if (temp._unit != null)
193 return false;
194 if (this._datatype != null) {
195 if (temp._datatype == null) return false;
196 else if (!(this._datatype.equals(temp._datatype)))
197 return false;
198 }
199 else if (temp._datatype != null)
200 return false;
201 if (this._precision != null) {
202 if (temp._precision == null) return false;
203 else if (!(this._precision.equals(temp._precision)))
204 return false;
205 }
206 else if (temp._precision != null)
207 return false;
208 if (this._width != temp._width)
209 return false;
210 if (this._has_width != temp._has_width)
211 return false;
212 if (this._ref != null) {
213 if (temp._ref == null) return false;
214 else if (!(this._ref.equals(temp._ref)))
215 return false;
216 }
217 else if (temp._ref != null)
218 return false;
219 if (this._name != null) {
220 if (temp._name == null) return false;
221 else if (!(this._name.equals(temp._name)))
222 return false;
223 }
224 else if (temp._name != null)
225 return false;
226 if (this._ucd != null) {
227 if (temp._ucd == null) return false;
228 else if (!(this._ucd.equals(temp._ucd)))
229 return false;
230 }
231 else if (temp._ucd != null)
232 return false;
233 if (this._arraysize != null) {
234 if (temp._arraysize == null) return false;
235 else if (!(this._arraysize.equals(temp._arraysize)))
236 return false;
237 }
238 else if (temp._arraysize != null)
239 return false;
240 if (this._type != null) {
241 if (temp._type == null) return false;
242 else if (!(this._type.equals(temp._type)))
243 return false;
244 }
245 else if (temp._type != null)
246 return false;
247 if (this._items != null) {
248 if (temp._items == null) return false;
249 else if (!(this._items.equals(temp._items)))
250 return false;
251 }
252 else if (temp._items != null)
253 return false;
254 return true;
255 }
256 return false;
257 }
258
259 /***
260 * Returns the value of field 'arraysize'.
261 *
262 * @return the value of field 'arraysize'.
263 */
264 public java.lang.String getArraysize()
265 {
266 return this._arraysize;
267 }
268
269 /***
270 * Returns the value of field 'datatype'.
271 *
272 * @return the value of field 'datatype'.
273 */
274 public org.astrogrid.registry.beans.resource.votable.types.DataType getDatatype()
275 {
276 return this._datatype;
277 }
278
279 /***
280 * Method getFIELDItem
281 *
282 * @param index
283 */
284 public org.astrogrid.registry.beans.resource.votable.FIELDItem getFIELDItem(int index)
285 throws java.lang.IndexOutOfBoundsException
286 {
287
288 if ((index < 0) || (index > _items.size())) {
289 throw new IndexOutOfBoundsException();
290 }
291
292 return (org.astrogrid.registry.beans.resource.votable.FIELDItem) _items.get(index);
293 }
294
295 /***
296 * Method getFIELDItem
297 */
298 public org.astrogrid.registry.beans.resource.votable.FIELDItem[] getFIELDItem()
299 {
300 int size = _items.size();
301 org.astrogrid.registry.beans.resource.votable.FIELDItem[] mArray = new org.astrogrid.registry.beans.resource.votable.FIELDItem[size];
302 for (int index = 0; index < size; index++) {
303 mArray[index] = (org.astrogrid.registry.beans.resource.votable.FIELDItem) _items.get(index);
304 }
305 return mArray;
306 }
307
308 /***
309 * Method getFIELDItemCount
310 */
311 public int getFIELDItemCount()
312 {
313 return _items.size();
314 }
315
316 /***
317 * Returns the value of field 'ID'.
318 *
319 * @return the value of field 'ID'.
320 */
321 public java.lang.String getID()
322 {
323 return this._ID;
324 }
325
326 /***
327 * Returns the value of field 'name'.
328 *
329 * @return the value of field 'name'.
330 */
331 public java.lang.String getName()
332 {
333 return this._name;
334 }
335
336 /***
337 * Returns the value of field 'precision'.
338 *
339 * @return the value of field 'precision'.
340 */
341 public java.lang.String getPrecision()
342 {
343 return this._precision;
344 }
345
346 /***
347 * Returns the value of field 'ref'.
348 *
349 * @return the value of field 'ref'.
350 */
351 public java.lang.Object getRef()
352 {
353 return this._ref;
354 }
355
356 /***
357 * Returns the value of field 'type'.
358 *
359 * @return the value of field 'type'.
360 */
361 public org.astrogrid.registry.beans.resource.votable.types.FIELDItemTypeType getType()
362 {
363 return this._type;
364 }
365
366 /***
367 * Returns the value of field 'ucd'.
368 *
369 * @return the value of field 'ucd'.
370 */
371 public java.lang.String getUcd()
372 {
373 return this._ucd;
374 }
375
376 /***
377 * Returns the value of field 'unit'.
378 *
379 * @return the value of field 'unit'.
380 */
381 public java.lang.String getUnit()
382 {
383 return this._unit;
384 }
385
386 /***
387 * Returns the value of field 'width'.
388 *
389 * @return the value of field 'width'.
390 */
391 public int getWidth()
392 {
393 return this._width;
394 }
395
396 /***
397 * Method hasWidth
398 */
399 public boolean hasWidth()
400 {
401 return this._has_width;
402 }
403
404 /***
405 * Method isValid
406 */
407 public boolean isValid()
408 {
409 try {
410 validate();
411 }
412 catch (org.exolab.castor.xml.ValidationException vex) {
413 return false;
414 }
415 return true;
416 }
417
418 /***
419 * Method marshal
420 *
421 * @param out
422 */
423 public void marshal(java.io.Writer out)
424 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
425 {
426
427 Marshaller.marshal(this, out);
428 }
429
430 /***
431 * Method marshal
432 *
433 * @param handler
434 */
435 public void marshal(org.xml.sax.ContentHandler handler)
436 throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
437 {
438
439 Marshaller.marshal(this, handler);
440 }
441
442 /***
443 * Method removeFIELDItem
444 *
445 * @param vFIELDItem
446 */
447 public boolean removeFIELDItem(org.astrogrid.registry.beans.resource.votable.FIELDItem vFIELDItem)
448 {
449 boolean removed = _items.remove(vFIELDItem);
450 return removed;
451 }
452
453 /***
454 * Sets the value of field 'arraysize'.
455 *
456 * @param arraysize the value of field 'arraysize'.
457 */
458 public void setArraysize(java.lang.String arraysize)
459 {
460 this._arraysize = arraysize;
461 }
462
463 /***
464 * Sets the value of field 'datatype'.
465 *
466 * @param datatype the value of field 'datatype'.
467 */
468 public void setDatatype(org.astrogrid.registry.beans.resource.votable.types.DataType datatype)
469 {
470 this._datatype = datatype;
471 }
472
473 /***
474 * Method setFIELDItem
475 *
476 * @param index
477 * @param vFIELDItem
478 */
479 public void setFIELDItem(int index, org.astrogrid.registry.beans.resource.votable.FIELDItem vFIELDItem)
480 throws java.lang.IndexOutOfBoundsException
481 {
482
483 if ((index < 0) || (index > _items.size())) {
484 throw new IndexOutOfBoundsException();
485 }
486 _items.set(index, vFIELDItem);
487 }
488
489 /***
490 * Method setFIELDItem
491 *
492 * @param FIELDItemArray
493 */
494 public void setFIELDItem(org.astrogrid.registry.beans.resource.votable.FIELDItem[] FIELDItemArray)
495 {
496
497 _items.clear();
498 for (int i = 0; i < FIELDItemArray.length; i++) {
499 _items.add(FIELDItemArray[i]);
500 }
501 }
502
503 /***
504 * Sets the value of field 'ID'.
505 *
506 * @param ID the value of field 'ID'.
507 */
508 public void setID(java.lang.String ID)
509 {
510 this._ID = ID;
511 }
512
513 /***
514 * Sets the value of field 'name'.
515 *
516 * @param name the value of field 'name'.
517 */
518 public void setName(java.lang.String name)
519 {
520 this._name = name;
521 }
522
523 /***
524 * Sets the value of field 'precision'.
525 *
526 * @param precision the value of field 'precision'.
527 */
528 public void setPrecision(java.lang.String precision)
529 {
530 this._precision = precision;
531 }
532
533 /***
534 * Sets the value of field 'ref'.
535 *
536 * @param ref the value of field 'ref'.
537 */
538 public void setRef(java.lang.Object ref)
539 {
540 this._ref = ref;
541 }
542
543 /***
544 * Sets the value of field 'type'.
545 *
546 * @param type the value of field 'type'.
547 */
548 public void setType(org.astrogrid.registry.beans.resource.votable.types.FIELDItemTypeType type)
549 {
550 this._type = type;
551 }
552
553 /***
554 * Sets the value of field 'ucd'.
555 *
556 * @param ucd the value of field 'ucd'.
557 */
558 public void setUcd(java.lang.String ucd)
559 {
560 this._ucd = ucd;
561 }
562
563 /***
564 * Sets the value of field 'unit'.
565 *
566 * @param unit the value of field 'unit'.
567 */
568 public void setUnit(java.lang.String unit)
569 {
570 this._unit = unit;
571 }
572
573 /***
574 * Sets the value of field 'width'.
575 *
576 * @param width the value of field 'width'.
577 */
578 public void setWidth(int width)
579 {
580 this._width = width;
581 this._has_width = true;
582 }
583
584 /***
585 * Method unmarshalFIELD
586 *
587 * @param reader
588 */
589 public static org.astrogrid.registry.beans.resource.votable.FIELD unmarshalFIELD(java.io.Reader reader)
590 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
591 {
592 return (org.astrogrid.registry.beans.resource.votable.FIELD) Unmarshaller.unmarshal(org.astrogrid.registry.beans.resource.votable.FIELD.class, reader);
593 }
594
595 /***
596 * Method validate
597 */
598 public void validate()
599 throws org.exolab.castor.xml.ValidationException
600 {
601 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
602 validator.validate(this);
603 }
604
605 }