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