1
2
3
4
5
6
7
8 package org.astrogrid.registry.beans.v10.resource.dataservice;
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.v10.resource.AccessURL;
21 import org.astrogrid.registry.beans.v10.resource.ResourceName;
22 import org.astrogrid.registry.beans.v10.resource.dataservice.types.Rights;
23 import org.exolab.castor.xml.MarshalException;
24 import org.exolab.castor.xml.Marshaller;
25 import org.exolab.castor.xml.Unmarshaller;
26 import org.exolab.castor.xml.ValidationException;
27 import org.xml.sax.ContentHandler;
28
29 /***
30 * A logical grouping of data which, in general, is composed of one
31 *
32 * or more accessible datasets.
33 *
34 * (A dataset is a collection of digitally-encoded data with a
35 * that
36 * is normally accessible as a single unit, e.g. a file.)
37 *
38 *
39 * @version $Revision: 1.2 $ $Date: 2007/01/04 16:26:26 $
40 */
41 public class DataCollection extends org.astrogrid.registry.beans.v10.resource.Resource
42 implements java.io.Serializable
43 {
44
45
46
47
48
49
50 /***
51 * the observatory or facility used to collect the data
52 * contained or managed by this resource.
53 *
54 */
55 private java.util.ArrayList _facilityList;
56
57 /***
58 * the Instrument used to collect the data contain or
59 * managed by a resource.
60 *
61 */
62 private java.util.ArrayList _instrumentList;
63
64 /***
65 * Extent of the content of the resource over space, time,
66 * and frequency.
67 *
68 */
69 private org.astrogrid.registry.beans.v10.resource.dataservice.Coverage _coverage;
70
71 /***
72 * The physical or digital manifestation of the information
73 * supported by a resource.
74 *
75 */
76 private java.util.ArrayList _formatList;
77
78 /***
79 * Information about rights held in and over the resource.
80 *
81 */
82 private java.util.ArrayList _rightsList;
83
84 /***
85 * The URL that can be used to download the data contained in
86 * this data collection.
87 *
88 */
89 private org.astrogrid.registry.beans.v10.resource.AccessURL _accessURL;
90
91
92
93
94
95
96 public DataCollection() {
97 super();
98 _facilityList = new ArrayList();
99 _instrumentList = new ArrayList();
100 _formatList = new ArrayList();
101 _rightsList = new ArrayList();
102 }
103
104
105
106
107
108
109 /***
110 * Method addFacility
111 *
112 * @param vFacility
113 */
114 public void addFacility(org.astrogrid.registry.beans.v10.resource.ResourceName vFacility)
115 throws java.lang.IndexOutOfBoundsException
116 {
117 _facilityList.add(vFacility);
118 }
119
120 /***
121 * Method addFacility
122 *
123 * @param index
124 * @param vFacility
125 */
126 public void addFacility(int index, org.astrogrid.registry.beans.v10.resource.ResourceName vFacility)
127 throws java.lang.IndexOutOfBoundsException
128 {
129 _facilityList.add(index, vFacility);
130 }
131
132 /***
133 * Method addFormat
134 *
135 * @param vFormat
136 */
137 public void addFormat(org.astrogrid.registry.beans.v10.resource.dataservice.Format vFormat)
138 throws java.lang.IndexOutOfBoundsException
139 {
140 _formatList.add(vFormat);
141 }
142
143 /***
144 * Method addFormat
145 *
146 * @param index
147 * @param vFormat
148 */
149 public void addFormat(int index, org.astrogrid.registry.beans.v10.resource.dataservice.Format vFormat)
150 throws java.lang.IndexOutOfBoundsException
151 {
152 _formatList.add(index, vFormat);
153 }
154
155 /***
156 * Method addInstrument
157 *
158 * @param vInstrument
159 */
160 public void addInstrument(org.astrogrid.registry.beans.v10.resource.ResourceName vInstrument)
161 throws java.lang.IndexOutOfBoundsException
162 {
163 _instrumentList.add(vInstrument);
164 }
165
166 /***
167 * Method addInstrument
168 *
169 * @param index
170 * @param vInstrument
171 */
172 public void addInstrument(int index, org.astrogrid.registry.beans.v10.resource.ResourceName vInstrument)
173 throws java.lang.IndexOutOfBoundsException
174 {
175 _instrumentList.add(index, vInstrument);
176 }
177
178 /***
179 * Method addRights
180 *
181 * @param vRights
182 */
183 public void addRights(org.astrogrid.registry.beans.v10.resource.dataservice.types.Rights vRights)
184 throws java.lang.IndexOutOfBoundsException
185 {
186 _rightsList.add(vRights);
187 }
188
189 /***
190 * Method addRights
191 *
192 * @param index
193 * @param vRights
194 */
195 public void addRights(int index, org.astrogrid.registry.beans.v10.resource.dataservice.types.Rights vRights)
196 throws java.lang.IndexOutOfBoundsException
197 {
198 _rightsList.add(index, vRights);
199 }
200
201 /***
202 * Method clearFacility
203 */
204 public void clearFacility()
205 {
206 _facilityList.clear();
207 }
208
209 /***
210 * Method clearFormat
211 */
212 public void clearFormat()
213 {
214 _formatList.clear();
215 }
216
217 /***
218 * Method clearInstrument
219 */
220 public void clearInstrument()
221 {
222 _instrumentList.clear();
223 }
224
225 /***
226 * Method clearRights
227 */
228 public void clearRights()
229 {
230 _rightsList.clear();
231 }
232
233 /***
234 * Method enumerateFacility
235 */
236 public java.util.Enumeration enumerateFacility()
237 {
238 return new org.exolab.castor.util.IteratorEnumeration(_facilityList.iterator());
239 }
240
241 /***
242 * Method enumerateFormat
243 */
244 public java.util.Enumeration enumerateFormat()
245 {
246 return new org.exolab.castor.util.IteratorEnumeration(_formatList.iterator());
247 }
248
249 /***
250 * Method enumerateInstrument
251 */
252 public java.util.Enumeration enumerateInstrument()
253 {
254 return new org.exolab.castor.util.IteratorEnumeration(_instrumentList.iterator());
255 }
256
257 /***
258 * Method enumerateRights
259 */
260 public java.util.Enumeration enumerateRights()
261 {
262 return new org.exolab.castor.util.IteratorEnumeration(_rightsList.iterator());
263 }
264
265 /***
266 * Note: hashCode() has not been overriden
267 *
268 * @param obj
269 */
270 public boolean equals(java.lang.Object obj)
271 {
272 if ( this == obj )
273 return true;
274
275 if (super.equals(obj)==false)
276 return false;
277
278 if (obj instanceof DataCollection) {
279
280 DataCollection temp = (DataCollection)obj;
281 if (this._facilityList != null) {
282 if (temp._facilityList == null) return false;
283 else if (!(this._facilityList.equals(temp._facilityList)))
284 return false;
285 }
286 else if (temp._facilityList != null)
287 return false;
288 if (this._instrumentList != null) {
289 if (temp._instrumentList == null) return false;
290 else if (!(this._instrumentList.equals(temp._instrumentList)))
291 return false;
292 }
293 else if (temp._instrumentList != null)
294 return false;
295 if (this._coverage != null) {
296 if (temp._coverage == null) return false;
297 else if (!(this._coverage.equals(temp._coverage)))
298 return false;
299 }
300 else if (temp._coverage != null)
301 return false;
302 if (this._formatList != null) {
303 if (temp._formatList == null) return false;
304 else if (!(this._formatList.equals(temp._formatList)))
305 return false;
306 }
307 else if (temp._formatList != null)
308 return false;
309 if (this._rightsList != null) {
310 if (temp._rightsList == null) return false;
311 else if (!(this._rightsList.equals(temp._rightsList)))
312 return false;
313 }
314 else if (temp._rightsList != null)
315 return false;
316 if (this._accessURL != null) {
317 if (temp._accessURL == null) return false;
318 else if (!(this._accessURL.equals(temp._accessURL)))
319 return false;
320 }
321 else if (temp._accessURL != null)
322 return false;
323 return true;
324 }
325 return false;
326 }
327
328 /***
329 * Returns the value of field 'accessURL'. The field
330 * 'accessURL' has the following description: The URL that can
331 * be used to download the data contained in
332 * this data collection.
333 *
334 *
335 * @return the value of field 'accessURL'.
336 */
337 public org.astrogrid.registry.beans.v10.resource.AccessURL getAccessURL()
338 {
339 return this._accessURL;
340 }
341
342 /***
343 * Returns the value of field 'coverage'. The field 'coverage'
344 * has the following description: Extent of the content of the
345 * resource over space, time,
346 * and frequency.
347 *
348 *
349 * @return the value of field 'coverage'.
350 */
351 public org.astrogrid.registry.beans.v10.resource.dataservice.Coverage getCoverage()
352 {
353 return this._coverage;
354 }
355
356 /***
357 * Method getFacility
358 *
359 * @param index
360 */
361 public org.astrogrid.registry.beans.v10.resource.ResourceName getFacility(int index)
362 throws java.lang.IndexOutOfBoundsException
363 {
364
365 if ((index < 0) || (index > _facilityList.size())) {
366 throw new IndexOutOfBoundsException();
367 }
368
369 return (org.astrogrid.registry.beans.v10.resource.ResourceName) _facilityList.get(index);
370 }
371
372 /***
373 * Method getFacility
374 */
375 public org.astrogrid.registry.beans.v10.resource.ResourceName[] getFacility()
376 {
377 int size = _facilityList.size();
378 org.astrogrid.registry.beans.v10.resource.ResourceName[] mArray = new org.astrogrid.registry.beans.v10.resource.ResourceName[size];
379 for (int index = 0; index < size; index++) {
380 mArray[index] = (org.astrogrid.registry.beans.v10.resource.ResourceName) _facilityList.get(index);
381 }
382 return mArray;
383 }
384
385 /***
386 * Method getFacilityCount
387 */
388 public int getFacilityCount()
389 {
390 return _facilityList.size();
391 }
392
393 /***
394 * Method getFormat
395 *
396 * @param index
397 */
398 public org.astrogrid.registry.beans.v10.resource.dataservice.Format getFormat(int index)
399 throws java.lang.IndexOutOfBoundsException
400 {
401
402 if ((index < 0) || (index > _formatList.size())) {
403 throw new IndexOutOfBoundsException();
404 }
405
406 return (org.astrogrid.registry.beans.v10.resource.dataservice.Format) _formatList.get(index);
407 }
408
409 /***
410 * Method getFormat
411 */
412 public org.astrogrid.registry.beans.v10.resource.dataservice.Format[] getFormat()
413 {
414 int size = _formatList.size();
415 org.astrogrid.registry.beans.v10.resource.dataservice.Format[] mArray = new org.astrogrid.registry.beans.v10.resource.dataservice.Format[size];
416 for (int index = 0; index < size; index++) {
417 mArray[index] = (org.astrogrid.registry.beans.v10.resource.dataservice.Format) _formatList.get(index);
418 }
419 return mArray;
420 }
421
422 /***
423 * Method getFormatCount
424 */
425 public int getFormatCount()
426 {
427 return _formatList.size();
428 }
429
430 /***
431 * Method getInstrument
432 *
433 * @param index
434 */
435 public org.astrogrid.registry.beans.v10.resource.ResourceName getInstrument(int index)
436 throws java.lang.IndexOutOfBoundsException
437 {
438
439 if ((index < 0) || (index > _instrumentList.size())) {
440 throw new IndexOutOfBoundsException();
441 }
442
443 return (org.astrogrid.registry.beans.v10.resource.ResourceName) _instrumentList.get(index);
444 }
445
446 /***
447 * Method getInstrument
448 */
449 public org.astrogrid.registry.beans.v10.resource.ResourceName[] getInstrument()
450 {
451 int size = _instrumentList.size();
452 org.astrogrid.registry.beans.v10.resource.ResourceName[] mArray = new org.astrogrid.registry.beans.v10.resource.ResourceName[size];
453 for (int index = 0; index < size; index++) {
454 mArray[index] = (org.astrogrid.registry.beans.v10.resource.ResourceName) _instrumentList.get(index);
455 }
456 return mArray;
457 }
458
459 /***
460 * Method getInstrumentCount
461 */
462 public int getInstrumentCount()
463 {
464 return _instrumentList.size();
465 }
466
467 /***
468 * Method getRights
469 *
470 * @param index
471 */
472 public org.astrogrid.registry.beans.v10.resource.dataservice.types.Rights getRights(int index)
473 throws java.lang.IndexOutOfBoundsException
474 {
475
476 if ((index < 0) || (index > _rightsList.size())) {
477 throw new IndexOutOfBoundsException();
478 }
479
480 return (org.astrogrid.registry.beans.v10.resource.dataservice.types.Rights) _rightsList.get(index);
481 }
482
483 /***
484 * Method getRights
485 */
486 public org.astrogrid.registry.beans.v10.resource.dataservice.types.Rights[] getRights()
487 {
488 int size = _rightsList.size();
489 org.astrogrid.registry.beans.v10.resource.dataservice.types.Rights[] mArray = new org.astrogrid.registry.beans.v10.resource.dataservice.types.Rights[size];
490 for (int index = 0; index < size; index++) {
491 mArray[index] = (org.astrogrid.registry.beans.v10.resource.dataservice.types.Rights) _rightsList.get(index);
492 }
493 return mArray;
494 }
495
496 /***
497 * Method getRightsCount
498 */
499 public int getRightsCount()
500 {
501 return _rightsList.size();
502 }
503
504 /***
505 * Method isValid
506 */
507 public boolean isValid()
508 {
509 try {
510 validate();
511 }
512 catch (org.exolab.castor.xml.ValidationException vex) {
513 return false;
514 }
515 return true;
516 }
517
518 /***
519 * Method marshal
520 *
521 * @param out
522 */
523 public void marshal(java.io.Writer out)
524 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
525 {
526
527 Marshaller.marshal(this, out);
528 }
529
530 /***
531 * Method marshal
532 *
533 * @param handler
534 */
535 public void marshal(org.xml.sax.ContentHandler handler)
536 throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
537 {
538
539 Marshaller.marshal(this, handler);
540 }
541
542 /***
543 * Method removeFacility
544 *
545 * @param vFacility
546 */
547 public boolean removeFacility(org.astrogrid.registry.beans.v10.resource.ResourceName vFacility)
548 {
549 boolean removed = _facilityList.remove(vFacility);
550 return removed;
551 }
552
553 /***
554 * Method removeFormat
555 *
556 * @param vFormat
557 */
558 public boolean removeFormat(org.astrogrid.registry.beans.v10.resource.dataservice.Format vFormat)
559 {
560 boolean removed = _formatList.remove(vFormat);
561 return removed;
562 }
563
564 /***
565 * Method removeInstrument
566 *
567 * @param vInstrument
568 */
569 public boolean removeInstrument(org.astrogrid.registry.beans.v10.resource.ResourceName vInstrument)
570 {
571 boolean removed = _instrumentList.remove(vInstrument);
572 return removed;
573 }
574
575 /***
576 * Method removeRights
577 *
578 * @param vRights
579 */
580 public boolean removeRights(org.astrogrid.registry.beans.v10.resource.dataservice.types.Rights vRights)
581 {
582 boolean removed = _rightsList.remove(vRights);
583 return removed;
584 }
585
586 /***
587 * Sets the value of field 'accessURL'. The field 'accessURL'
588 * has the following description: The URL that can be used to
589 * download the data contained in
590 * this data collection.
591 *
592 *
593 * @param accessURL the value of field 'accessURL'.
594 */
595 public void setAccessURL(org.astrogrid.registry.beans.v10.resource.AccessURL accessURL)
596 {
597 this._accessURL = accessURL;
598 }
599
600 /***
601 * Sets the value of field 'coverage'. The field 'coverage' has
602 * the following description: Extent of the content of the
603 * resource over space, time,
604 * and frequency.
605 *
606 *
607 * @param coverage the value of field 'coverage'.
608 */
609 public void setCoverage(org.astrogrid.registry.beans.v10.resource.dataservice.Coverage coverage)
610 {
611 this._coverage = coverage;
612 }
613
614 /***
615 * Method setFacility
616 *
617 * @param index
618 * @param vFacility
619 */
620 public void setFacility(int index, org.astrogrid.registry.beans.v10.resource.ResourceName vFacility)
621 throws java.lang.IndexOutOfBoundsException
622 {
623
624 if ((index < 0) || (index > _facilityList.size())) {
625 throw new IndexOutOfBoundsException();
626 }
627 _facilityList.set(index, vFacility);
628 }
629
630 /***
631 * Method setFacility
632 *
633 * @param facilityArray
634 */
635 public void setFacility(org.astrogrid.registry.beans.v10.resource.ResourceName[] facilityArray)
636 {
637
638 _facilityList.clear();
639 for (int i = 0; i < facilityArray.length; i++) {
640 _facilityList.add(facilityArray[i]);
641 }
642 }
643
644 /***
645 * Method setFormat
646 *
647 * @param index
648 * @param vFormat
649 */
650 public void setFormat(int index, org.astrogrid.registry.beans.v10.resource.dataservice.Format vFormat)
651 throws java.lang.IndexOutOfBoundsException
652 {
653
654 if ((index < 0) || (index > _formatList.size())) {
655 throw new IndexOutOfBoundsException();
656 }
657 _formatList.set(index, vFormat);
658 }
659
660 /***
661 * Method setFormat
662 *
663 * @param formatArray
664 */
665 public void setFormat(org.astrogrid.registry.beans.v10.resource.dataservice.Format[] formatArray)
666 {
667
668 _formatList.clear();
669 for (int i = 0; i < formatArray.length; i++) {
670 _formatList.add(formatArray[i]);
671 }
672 }
673
674 /***
675 * Method setInstrument
676 *
677 * @param index
678 * @param vInstrument
679 */
680 public void setInstrument(int index, org.astrogrid.registry.beans.v10.resource.ResourceName vInstrument)
681 throws java.lang.IndexOutOfBoundsException
682 {
683
684 if ((index < 0) || (index > _instrumentList.size())) {
685 throw new IndexOutOfBoundsException();
686 }
687 _instrumentList.set(index, vInstrument);
688 }
689
690 /***
691 * Method setInstrument
692 *
693 * @param instrumentArray
694 */
695 public void setInstrument(org.astrogrid.registry.beans.v10.resource.ResourceName[] instrumentArray)
696 {
697
698 _instrumentList.clear();
699 for (int i = 0; i < instrumentArray.length; i++) {
700 _instrumentList.add(instrumentArray[i]);
701 }
702 }
703
704 /***
705 * Method setRights
706 *
707 * @param index
708 * @param vRights
709 */
710 public void setRights(int index, org.astrogrid.registry.beans.v10.resource.dataservice.types.Rights vRights)
711 throws java.lang.IndexOutOfBoundsException
712 {
713
714 if ((index < 0) || (index > _rightsList.size())) {
715 throw new IndexOutOfBoundsException();
716 }
717 _rightsList.set(index, vRights);
718 }
719
720 /***
721 * Method setRights
722 *
723 * @param rightsArray
724 */
725 public void setRights(org.astrogrid.registry.beans.v10.resource.dataservice.types.Rights[] rightsArray)
726 {
727
728 _rightsList.clear();
729 for (int i = 0; i < rightsArray.length; i++) {
730 _rightsList.add(rightsArray[i]);
731 }
732 }
733
734 /***
735 * Method unmarshalDataCollection
736 *
737 * @param reader
738 */
739 public static org.astrogrid.registry.beans.v10.resource.dataservice.DataCollection unmarshalDataCollection(java.io.Reader reader)
740 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
741 {
742 return (org.astrogrid.registry.beans.v10.resource.dataservice.DataCollection) Unmarshaller.unmarshal(org.astrogrid.registry.beans.v10.resource.dataservice.DataCollection.class, reader);
743 }
744
745 /***
746 * Method validate
747 */
748 public void validate()
749 throws org.exolab.castor.xml.ValidationException
750 {
751 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
752 validator.validate(this);
753 }
754
755 }