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.ResourceName;
21 import org.exolab.castor.xml.MarshalException;
22 import org.exolab.castor.xml.Marshaller;
23 import org.exolab.castor.xml.Unmarshaller;
24 import org.exolab.castor.xml.ValidationException;
25 import org.xml.sax.ContentHandler;
26
27 /***
28 * A service for accessing astronomical data
29 *
30 *
31 * @version $Revision: 1.2 $ $Date: 2007/01/04 16:26:25 $
32 */
33 public class SkyService extends org.astrogrid.registry.beans.v10.resource.Service
34 implements java.io.Serializable
35 {
36
37
38
39
40
41
42 /***
43 * the observatory or facility used to collect the data
44 * contained or managed by this resource.
45 *
46 */
47 private java.util.ArrayList _facilityList;
48
49 /***
50 * the Instrument used to collect the data contain or
51 * managed by a resource.
52 *
53 */
54 private java.util.ArrayList _instrumentList;
55
56 /***
57 * Extent of the content of the resource over space, time,
58 * and frequency.
59 *
60 */
61 private org.astrogrid.registry.beans.v10.resource.dataservice.Coverage _coverage;
62
63
64
65
66
67
68 public SkyService() {
69 super();
70 _facilityList = new ArrayList();
71 _instrumentList = new ArrayList();
72 }
73
74
75
76
77
78
79 /***
80 * Method addFacility
81 *
82 * @param vFacility
83 */
84 public void addFacility(org.astrogrid.registry.beans.v10.resource.ResourceName vFacility)
85 throws java.lang.IndexOutOfBoundsException
86 {
87 _facilityList.add(vFacility);
88 }
89
90 /***
91 * Method addFacility
92 *
93 * @param index
94 * @param vFacility
95 */
96 public void addFacility(int index, org.astrogrid.registry.beans.v10.resource.ResourceName vFacility)
97 throws java.lang.IndexOutOfBoundsException
98 {
99 _facilityList.add(index, vFacility);
100 }
101
102 /***
103 * Method addInstrument
104 *
105 * @param vInstrument
106 */
107 public void addInstrument(org.astrogrid.registry.beans.v10.resource.ResourceName vInstrument)
108 throws java.lang.IndexOutOfBoundsException
109 {
110 _instrumentList.add(vInstrument);
111 }
112
113 /***
114 * Method addInstrument
115 *
116 * @param index
117 * @param vInstrument
118 */
119 public void addInstrument(int index, org.astrogrid.registry.beans.v10.resource.ResourceName vInstrument)
120 throws java.lang.IndexOutOfBoundsException
121 {
122 _instrumentList.add(index, vInstrument);
123 }
124
125 /***
126 * Method clearFacility
127 */
128 public void clearFacility()
129 {
130 _facilityList.clear();
131 }
132
133 /***
134 * Method clearInstrument
135 */
136 public void clearInstrument()
137 {
138 _instrumentList.clear();
139 }
140
141 /***
142 * Method enumerateFacility
143 */
144 public java.util.Enumeration enumerateFacility()
145 {
146 return new org.exolab.castor.util.IteratorEnumeration(_facilityList.iterator());
147 }
148
149 /***
150 * Method enumerateInstrument
151 */
152 public java.util.Enumeration enumerateInstrument()
153 {
154 return new org.exolab.castor.util.IteratorEnumeration(_instrumentList.iterator());
155 }
156
157 /***
158 * Note: hashCode() has not been overriden
159 *
160 * @param obj
161 */
162 public boolean equals(java.lang.Object obj)
163 {
164 if ( this == obj )
165 return true;
166
167 if (super.equals(obj)==false)
168 return false;
169
170 if (obj instanceof SkyService) {
171
172 SkyService temp = (SkyService)obj;
173 if (this._facilityList != null) {
174 if (temp._facilityList == null) return false;
175 else if (!(this._facilityList.equals(temp._facilityList)))
176 return false;
177 }
178 else if (temp._facilityList != null)
179 return false;
180 if (this._instrumentList != null) {
181 if (temp._instrumentList == null) return false;
182 else if (!(this._instrumentList.equals(temp._instrumentList)))
183 return false;
184 }
185 else if (temp._instrumentList != null)
186 return false;
187 if (this._coverage != null) {
188 if (temp._coverage == null) return false;
189 else if (!(this._coverage.equals(temp._coverage)))
190 return false;
191 }
192 else if (temp._coverage != null)
193 return false;
194 return true;
195 }
196 return false;
197 }
198
199 /***
200 * Returns the value of field 'coverage'. The field 'coverage'
201 * has the following description: Extent of the content of the
202 * resource over space, time,
203 * and frequency.
204 *
205 *
206 * @return the value of field 'coverage'.
207 */
208 public org.astrogrid.registry.beans.v10.resource.dataservice.Coverage getCoverage()
209 {
210 return this._coverage;
211 }
212
213 /***
214 * Method getFacility
215 *
216 * @param index
217 */
218 public org.astrogrid.registry.beans.v10.resource.ResourceName getFacility(int index)
219 throws java.lang.IndexOutOfBoundsException
220 {
221
222 if ((index < 0) || (index > _facilityList.size())) {
223 throw new IndexOutOfBoundsException();
224 }
225
226 return (org.astrogrid.registry.beans.v10.resource.ResourceName) _facilityList.get(index);
227 }
228
229 /***
230 * Method getFacility
231 */
232 public org.astrogrid.registry.beans.v10.resource.ResourceName[] getFacility()
233 {
234 int size = _facilityList.size();
235 org.astrogrid.registry.beans.v10.resource.ResourceName[] mArray = new org.astrogrid.registry.beans.v10.resource.ResourceName[size];
236 for (int index = 0; index < size; index++) {
237 mArray[index] = (org.astrogrid.registry.beans.v10.resource.ResourceName) _facilityList.get(index);
238 }
239 return mArray;
240 }
241
242 /***
243 * Method getFacilityCount
244 */
245 public int getFacilityCount()
246 {
247 return _facilityList.size();
248 }
249
250 /***
251 * Method getInstrument
252 *
253 * @param index
254 */
255 public org.astrogrid.registry.beans.v10.resource.ResourceName getInstrument(int index)
256 throws java.lang.IndexOutOfBoundsException
257 {
258
259 if ((index < 0) || (index > _instrumentList.size())) {
260 throw new IndexOutOfBoundsException();
261 }
262
263 return (org.astrogrid.registry.beans.v10.resource.ResourceName) _instrumentList.get(index);
264 }
265
266 /***
267 * Method getInstrument
268 */
269 public org.astrogrid.registry.beans.v10.resource.ResourceName[] getInstrument()
270 {
271 int size = _instrumentList.size();
272 org.astrogrid.registry.beans.v10.resource.ResourceName[] mArray = new org.astrogrid.registry.beans.v10.resource.ResourceName[size];
273 for (int index = 0; index < size; index++) {
274 mArray[index] = (org.astrogrid.registry.beans.v10.resource.ResourceName) _instrumentList.get(index);
275 }
276 return mArray;
277 }
278
279 /***
280 * Method getInstrumentCount
281 */
282 public int getInstrumentCount()
283 {
284 return _instrumentList.size();
285 }
286
287 /***
288 * Method isValid
289 */
290 public boolean isValid()
291 {
292 try {
293 validate();
294 }
295 catch (org.exolab.castor.xml.ValidationException vex) {
296 return false;
297 }
298 return true;
299 }
300
301 /***
302 * Method marshal
303 *
304 * @param out
305 */
306 public void marshal(java.io.Writer out)
307 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
308 {
309
310 Marshaller.marshal(this, out);
311 }
312
313 /***
314 * Method marshal
315 *
316 * @param handler
317 */
318 public void marshal(org.xml.sax.ContentHandler handler)
319 throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
320 {
321
322 Marshaller.marshal(this, handler);
323 }
324
325 /***
326 * Method removeFacility
327 *
328 * @param vFacility
329 */
330 public boolean removeFacility(org.astrogrid.registry.beans.v10.resource.ResourceName vFacility)
331 {
332 boolean removed = _facilityList.remove(vFacility);
333 return removed;
334 }
335
336 /***
337 * Method removeInstrument
338 *
339 * @param vInstrument
340 */
341 public boolean removeInstrument(org.astrogrid.registry.beans.v10.resource.ResourceName vInstrument)
342 {
343 boolean removed = _instrumentList.remove(vInstrument);
344 return removed;
345 }
346
347 /***
348 * Sets the value of field 'coverage'. The field 'coverage' has
349 * the following description: Extent of the content of the
350 * resource over space, time,
351 * and frequency.
352 *
353 *
354 * @param coverage the value of field 'coverage'.
355 */
356 public void setCoverage(org.astrogrid.registry.beans.v10.resource.dataservice.Coverage coverage)
357 {
358 this._coverage = coverage;
359 }
360
361 /***
362 * Method setFacility
363 *
364 * @param index
365 * @param vFacility
366 */
367 public void setFacility(int index, org.astrogrid.registry.beans.v10.resource.ResourceName vFacility)
368 throws java.lang.IndexOutOfBoundsException
369 {
370
371 if ((index < 0) || (index > _facilityList.size())) {
372 throw new IndexOutOfBoundsException();
373 }
374 _facilityList.set(index, vFacility);
375 }
376
377 /***
378 * Method setFacility
379 *
380 * @param facilityArray
381 */
382 public void setFacility(org.astrogrid.registry.beans.v10.resource.ResourceName[] facilityArray)
383 {
384
385 _facilityList.clear();
386 for (int i = 0; i < facilityArray.length; i++) {
387 _facilityList.add(facilityArray[i]);
388 }
389 }
390
391 /***
392 * Method setInstrument
393 *
394 * @param index
395 * @param vInstrument
396 */
397 public void setInstrument(int index, org.astrogrid.registry.beans.v10.resource.ResourceName vInstrument)
398 throws java.lang.IndexOutOfBoundsException
399 {
400
401 if ((index < 0) || (index > _instrumentList.size())) {
402 throw new IndexOutOfBoundsException();
403 }
404 _instrumentList.set(index, vInstrument);
405 }
406
407 /***
408 * Method setInstrument
409 *
410 * @param instrumentArray
411 */
412 public void setInstrument(org.astrogrid.registry.beans.v10.resource.ResourceName[] instrumentArray)
413 {
414
415 _instrumentList.clear();
416 for (int i = 0; i < instrumentArray.length; i++) {
417 _instrumentList.add(instrumentArray[i]);
418 }
419 }
420
421 /***
422 * Method unmarshalSkyService
423 *
424 * @param reader
425 */
426 public static org.astrogrid.registry.beans.v10.resource.dataservice.SkyService unmarshalSkyService(java.io.Reader reader)
427 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
428 {
429 return (org.astrogrid.registry.beans.v10.resource.dataservice.SkyService) Unmarshaller.unmarshal(org.astrogrid.registry.beans.v10.resource.dataservice.SkyService.class, reader);
430 }
431
432 /***
433 * Method validate
434 */
435 public void validate()
436 throws org.exolab.castor.xml.ValidationException
437 {
438 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
439 validator.validate(this);
440 }
441
442 }