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.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 Spatial.
28 *
29 * @version $Revision: 1.2 $ $Date: 2007/01/04 16:26:24 $
30 */
31 public class Spatial extends org.astrogrid.common.bean.BaseBean
32 implements java.io.Serializable
33 {
34
35
36
37
38
39
40 /***
41 * a coverage area of the sky
42 */
43 private java.util.ArrayList _regionList;
44
45 /***
46 * The spatial (angular) resolution that is typical of the
47 * observations of interest, in decimal degrees.
48 *
49 */
50 private float _resolution;
51
52 /***
53 * keeps track of state for field: _resolution
54 */
55 private boolean _has_resolution;
56
57 /***
58 * The intrinsic size scale, given in arcseconds, associated
59 * with data items contained in a resource.
60 *
61 */
62 private float _regionOfRegard;
63
64 /***
65 * keeps track of state for field: _regionOfRegard
66 */
67 private boolean _has_regionOfRegard;
68
69
70
71
72
73
74 public Spatial() {
75 super();
76 _regionList = new ArrayList();
77 }
78
79
80
81
82
83
84 /***
85 * Method addRegion
86 *
87 * @param vRegion
88 */
89 public void addRegion(org.astrogrid.registry.beans.v10.resource.dataservice.Region vRegion)
90 throws java.lang.IndexOutOfBoundsException
91 {
92 _regionList.add(vRegion);
93 }
94
95 /***
96 * Method addRegion
97 *
98 * @param index
99 * @param vRegion
100 */
101 public void addRegion(int index, org.astrogrid.registry.beans.v10.resource.dataservice.Region vRegion)
102 throws java.lang.IndexOutOfBoundsException
103 {
104 _regionList.add(index, vRegion);
105 }
106
107 /***
108 * Method clearRegion
109 */
110 public void clearRegion()
111 {
112 _regionList.clear();
113 }
114
115 /***
116 * Method deleteRegionOfRegard
117 */
118 public void deleteRegionOfRegard()
119 {
120 this._has_regionOfRegard= false;
121 }
122
123 /***
124 * Method deleteResolution
125 */
126 public void deleteResolution()
127 {
128 this._has_resolution= false;
129 }
130
131 /***
132 * Method enumerateRegion
133 */
134 public java.util.Enumeration enumerateRegion()
135 {
136 return new org.exolab.castor.util.IteratorEnumeration(_regionList.iterator());
137 }
138
139 /***
140 * Note: hashCode() has not been overriden
141 *
142 * @param obj
143 */
144 public boolean equals(java.lang.Object obj)
145 {
146 if ( this == obj )
147 return true;
148
149 if (super.equals(obj)==false)
150 return false;
151
152 if (obj instanceof Spatial) {
153
154 Spatial temp = (Spatial)obj;
155 if (this._regionList != null) {
156 if (temp._regionList == null) return false;
157 else if (!(this._regionList.equals(temp._regionList)))
158 return false;
159 }
160 else if (temp._regionList != null)
161 return false;
162 if (this._resolution != temp._resolution)
163 return false;
164 if (this._has_resolution != temp._has_resolution)
165 return false;
166 if (this._regionOfRegard != temp._regionOfRegard)
167 return false;
168 if (this._has_regionOfRegard != temp._has_regionOfRegard)
169 return false;
170 return true;
171 }
172 return false;
173 }
174
175 /***
176 * Method getRegion
177 *
178 * @param index
179 */
180 public org.astrogrid.registry.beans.v10.resource.dataservice.Region getRegion(int index)
181 throws java.lang.IndexOutOfBoundsException
182 {
183
184 if ((index < 0) || (index > _regionList.size())) {
185 throw new IndexOutOfBoundsException();
186 }
187
188 return (org.astrogrid.registry.beans.v10.resource.dataservice.Region) _regionList.get(index);
189 }
190
191 /***
192 * Method getRegion
193 */
194 public org.astrogrid.registry.beans.v10.resource.dataservice.Region[] getRegion()
195 {
196 int size = _regionList.size();
197 org.astrogrid.registry.beans.v10.resource.dataservice.Region[] mArray = new org.astrogrid.registry.beans.v10.resource.dataservice.Region[size];
198 for (int index = 0; index < size; index++) {
199 mArray[index] = (org.astrogrid.registry.beans.v10.resource.dataservice.Region) _regionList.get(index);
200 }
201 return mArray;
202 }
203
204 /***
205 * Method getRegionCount
206 */
207 public int getRegionCount()
208 {
209 return _regionList.size();
210 }
211
212 /***
213 * Returns the value of field 'regionOfRegard'. The field
214 * 'regionOfRegard' has the following description: The
215 * intrinsic size scale, given in arcseconds, associated
216 * with data items contained in a resource.
217 *
218 *
219 * @return the value of field 'regionOfRegard'.
220 */
221 public float getRegionOfRegard()
222 {
223 return this._regionOfRegard;
224 }
225
226 /***
227 * Returns the value of field 'resolution'. The field
228 * 'resolution' has the following description: The spatial
229 * (angular) resolution that is typical of the
230 * observations of interest, in decimal degrees.
231 *
232 *
233 * @return the value of field 'resolution'.
234 */
235 public float getResolution()
236 {
237 return this._resolution;
238 }
239
240 /***
241 * Method hasRegionOfRegard
242 */
243 public boolean hasRegionOfRegard()
244 {
245 return this._has_regionOfRegard;
246 }
247
248 /***
249 * Method hasResolution
250 */
251 public boolean hasResolution()
252 {
253 return this._has_resolution;
254 }
255
256 /***
257 * Method isValid
258 */
259 public boolean isValid()
260 {
261 try {
262 validate();
263 }
264 catch (org.exolab.castor.xml.ValidationException vex) {
265 return false;
266 }
267 return true;
268 }
269
270 /***
271 * Method marshal
272 *
273 * @param out
274 */
275 public void marshal(java.io.Writer out)
276 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
277 {
278
279 Marshaller.marshal(this, out);
280 }
281
282 /***
283 * Method marshal
284 *
285 * @param handler
286 */
287 public void marshal(org.xml.sax.ContentHandler handler)
288 throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
289 {
290
291 Marshaller.marshal(this, handler);
292 }
293
294 /***
295 * Method removeRegion
296 *
297 * @param vRegion
298 */
299 public boolean removeRegion(org.astrogrid.registry.beans.v10.resource.dataservice.Region vRegion)
300 {
301 boolean removed = _regionList.remove(vRegion);
302 return removed;
303 }
304
305 /***
306 * Method setRegion
307 *
308 * @param index
309 * @param vRegion
310 */
311 public void setRegion(int index, org.astrogrid.registry.beans.v10.resource.dataservice.Region vRegion)
312 throws java.lang.IndexOutOfBoundsException
313 {
314
315 if ((index < 0) || (index > _regionList.size())) {
316 throw new IndexOutOfBoundsException();
317 }
318 _regionList.set(index, vRegion);
319 }
320
321 /***
322 * Method setRegion
323 *
324 * @param regionArray
325 */
326 public void setRegion(org.astrogrid.registry.beans.v10.resource.dataservice.Region[] regionArray)
327 {
328
329 _regionList.clear();
330 for (int i = 0; i < regionArray.length; i++) {
331 _regionList.add(regionArray[i]);
332 }
333 }
334
335 /***
336 * Sets the value of field 'regionOfRegard'. The field
337 * 'regionOfRegard' has the following description: The
338 * intrinsic size scale, given in arcseconds, associated
339 * with data items contained in a resource.
340 *
341 *
342 * @param regionOfRegard the value of field 'regionOfRegard'.
343 */
344 public void setRegionOfRegard(float regionOfRegard)
345 {
346 this._regionOfRegard = regionOfRegard;
347 this._has_regionOfRegard = true;
348 }
349
350 /***
351 * Sets the value of field 'resolution'. The field 'resolution'
352 * has the following description: The spatial (angular)
353 * resolution that is typical of the
354 * observations of interest, in decimal degrees.
355 *
356 *
357 * @param resolution the value of field 'resolution'.
358 */
359 public void setResolution(float resolution)
360 {
361 this._resolution = resolution;
362 this._has_resolution = true;
363 }
364
365 /***
366 * Method unmarshalSpatial
367 *
368 * @param reader
369 */
370 public static org.astrogrid.registry.beans.v10.resource.dataservice.Spatial unmarshalSpatial(java.io.Reader reader)
371 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
372 {
373 return (org.astrogrid.registry.beans.v10.resource.dataservice.Spatial) Unmarshaller.unmarshal(org.astrogrid.registry.beans.v10.resource.dataservice.Spatial.class, reader);
374 }
375
376 /***
377 * Method validate
378 */
379 public void validate()
380 throws org.exolab.castor.xml.ValidationException
381 {
382 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
383 validator.validate(this);
384 }
385
386 }