View Javadoc

1   /*
2    * This class was automatically generated with 
3    * <a href="http://www.castor.org">Castor 0.9.4.3</a>, using an XML
4    * Schema.
5    * $Id: Spectral.java,v 1.2 2007/01/04 16:26:25 clq2 Exp $
6    */
7   
8   package org.astrogrid.registry.beans.v10.resource.dataservice;
9   
10    //---------------------------------/
11   //- Imported classes and packages -/
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.dataservice.types.Waveband;
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 Spectral.
29   * 
30   * @version $Revision: 1.2 $ $Date: 2007/01/04 16:26:25 $
31   */
32  public class Spectral extends org.astrogrid.common.bean.BaseBean 
33  implements java.io.Serializable
34  {
35  
36  
37        //--------------------------/
38       //- Class/Member Variables -/
39      //--------------------------/
40  
41      /***
42       * a named spectral region of the electro-magnetic spectrum.
43       *  
44       */
45      private java.util.ArrayList _wavebandList;
46  
47      /***
48       * a range of the electro-magnetic spectrum specified by 
49       *  a lower and upper wavelength limit.
50       *  
51       */
52      private org.astrogrid.registry.beans.v10.resource.dataservice.WavelengthRange _range;
53  
54      /***
55       * The spectral resolution that is typical of the
56       *  observations of interest, given as a ratio of the
57       * wavelength
58       *  width (delta-lambda) to the observing wavelength (lambda).
59       *  
60       */
61      private float _resolution;
62  
63      /***
64       * keeps track of state for field: _resolution
65       */
66      private boolean _has_resolution;
67  
68  
69        //----------------/
70       //- Constructors -/
71      //----------------/
72  
73      public Spectral() {
74          super();
75          _wavebandList = new ArrayList();
76      } //-- org.astrogrid.registry.beans.v10.resource.dataservice.Spectral()
77  
78  
79        //-----------/
80       //- Methods -/
81      //-----------/
82  
83      /***
84       * Method addWaveband
85       * 
86       * @param vWaveband
87       */
88      public void addWaveband(org.astrogrid.registry.beans.v10.resource.dataservice.types.Waveband vWaveband)
89          throws java.lang.IndexOutOfBoundsException
90      {
91          _wavebandList.add(vWaveband);
92      } //-- void addWaveband(org.astrogrid.registry.beans.v10.resource.dataservice.types.Waveband) 
93  
94      /***
95       * Method addWaveband
96       * 
97       * @param index
98       * @param vWaveband
99       */
100     public void addWaveband(int index, org.astrogrid.registry.beans.v10.resource.dataservice.types.Waveband vWaveband)
101         throws java.lang.IndexOutOfBoundsException
102     {
103         _wavebandList.add(index, vWaveband);
104     } //-- void addWaveband(int, org.astrogrid.registry.beans.v10.resource.dataservice.types.Waveband) 
105 
106     /***
107      * Method clearWaveband
108      */
109     public void clearWaveband()
110     {
111         _wavebandList.clear();
112     } //-- void clearWaveband() 
113 
114     /***
115      * Method deleteResolution
116      */
117     public void deleteResolution()
118     {
119         this._has_resolution= false;
120     } //-- void deleteResolution() 
121 
122     /***
123      * Method enumerateWaveband
124      */
125     public java.util.Enumeration enumerateWaveband()
126     {
127         return new org.exolab.castor.util.IteratorEnumeration(_wavebandList.iterator());
128     } //-- java.util.Enumeration enumerateWaveband() 
129 
130     /***
131      * Note: hashCode() has not been overriden
132      * 
133      * @param obj
134      */
135     public boolean equals(java.lang.Object obj)
136     {
137         if ( this == obj )
138             return true;
139         
140         if (super.equals(obj)==false)
141             return false;
142         
143         if (obj instanceof Spectral) {
144         
145             Spectral temp = (Spectral)obj;
146             if (this._wavebandList != null) {
147                 if (temp._wavebandList == null) return false;
148                 else if (!(this._wavebandList.equals(temp._wavebandList))) 
149                     return false;
150             }
151             else if (temp._wavebandList != null)
152                 return false;
153             if (this._range != null) {
154                 if (temp._range == null) return false;
155                 else if (!(this._range.equals(temp._range))) 
156                     return false;
157             }
158             else if (temp._range != null)
159                 return false;
160             if (this._resolution != temp._resolution)
161                 return false;
162             if (this._has_resolution != temp._has_resolution)
163                 return false;
164             return true;
165         }
166         return false;
167     } //-- boolean equals(java.lang.Object) 
168 
169     /***
170      * Returns the value of field 'range'. The field 'range' has
171      * the following description: a range of the electro-magnetic
172      * spectrum specified by 
173      *  a lower and upper wavelength limit.
174      *  
175      * 
176      * @return the value of field 'range'.
177      */
178     public org.astrogrid.registry.beans.v10.resource.dataservice.WavelengthRange getRange()
179     {
180         return this._range;
181     } //-- org.astrogrid.registry.beans.v10.resource.dataservice.WavelengthRange getRange() 
182 
183     /***
184      * Returns the value of field 'resolution'. The field
185      * 'resolution' has the following description: The spectral
186      * resolution that is typical of the
187      *  observations of interest, given as a ratio of the
188      * wavelength
189      *  width (delta-lambda) to the observing wavelength (lambda).
190      *  
191      * 
192      * @return the value of field 'resolution'.
193      */
194     public float getResolution()
195     {
196         return this._resolution;
197     } //-- float getResolution() 
198 
199     /***
200      * Method getWaveband
201      * 
202      * @param index
203      */
204     public org.astrogrid.registry.beans.v10.resource.dataservice.types.Waveband getWaveband(int index)
205         throws java.lang.IndexOutOfBoundsException
206     {
207         //-- check bounds for index
208         if ((index < 0) || (index > _wavebandList.size())) {
209             throw new IndexOutOfBoundsException();
210         }
211         
212         return (org.astrogrid.registry.beans.v10.resource.dataservice.types.Waveband) _wavebandList.get(index);
213     } //-- org.astrogrid.registry.beans.v10.resource.dataservice.types.Waveband getWaveband(int) 
214 
215     /***
216      * Method getWaveband
217      */
218     public org.astrogrid.registry.beans.v10.resource.dataservice.types.Waveband[] getWaveband()
219     {
220         int size = _wavebandList.size();
221         org.astrogrid.registry.beans.v10.resource.dataservice.types.Waveband[] mArray = new org.astrogrid.registry.beans.v10.resource.dataservice.types.Waveband[size];
222         for (int index = 0; index < size; index++) {
223             mArray[index] = (org.astrogrid.registry.beans.v10.resource.dataservice.types.Waveband) _wavebandList.get(index);
224         }
225         return mArray;
226     } //-- org.astrogrid.registry.beans.v10.resource.dataservice.types.Waveband[] getWaveband() 
227 
228     /***
229      * Method getWavebandCount
230      */
231     public int getWavebandCount()
232     {
233         return _wavebandList.size();
234     } //-- int getWavebandCount() 
235 
236     /***
237      * Method hasResolution
238      */
239     public boolean hasResolution()
240     {
241         return this._has_resolution;
242     } //-- boolean hasResolution() 
243 
244     /***
245      * Method isValid
246      */
247     public boolean isValid()
248     {
249         try {
250             validate();
251         }
252         catch (org.exolab.castor.xml.ValidationException vex) {
253             return false;
254         }
255         return true;
256     } //-- boolean isValid() 
257 
258     /***
259      * Method marshal
260      * 
261      * @param out
262      */
263     public void marshal(java.io.Writer out)
264         throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
265     {
266         
267         Marshaller.marshal(this, out);
268     } //-- void marshal(java.io.Writer) 
269 
270     /***
271      * Method marshal
272      * 
273      * @param handler
274      */
275     public void marshal(org.xml.sax.ContentHandler handler)
276         throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
277     {
278         
279         Marshaller.marshal(this, handler);
280     } //-- void marshal(org.xml.sax.ContentHandler) 
281 
282     /***
283      * Method removeWaveband
284      * 
285      * @param vWaveband
286      */
287     public boolean removeWaveband(org.astrogrid.registry.beans.v10.resource.dataservice.types.Waveband vWaveband)
288     {
289         boolean removed = _wavebandList.remove(vWaveband);
290         return removed;
291     } //-- boolean removeWaveband(org.astrogrid.registry.beans.v10.resource.dataservice.types.Waveband) 
292 
293     /***
294      * Sets the value of field 'range'. The field 'range' has the
295      * following description: a range of the electro-magnetic
296      * spectrum specified by 
297      *  a lower and upper wavelength limit.
298      *  
299      * 
300      * @param range the value of field 'range'.
301      */
302     public void setRange(org.astrogrid.registry.beans.v10.resource.dataservice.WavelengthRange range)
303     {
304         this._range = range;
305     } //-- void setRange(org.astrogrid.registry.beans.v10.resource.dataservice.WavelengthRange) 
306 
307     /***
308      * Sets the value of field 'resolution'. The field 'resolution'
309      * has the following description: The spectral resolution that
310      * is typical of the
311      *  observations of interest, given as a ratio of the
312      * wavelength
313      *  width (delta-lambda) to the observing wavelength (lambda).
314      *  
315      * 
316      * @param resolution the value of field 'resolution'.
317      */
318     public void setResolution(float resolution)
319     {
320         this._resolution = resolution;
321         this._has_resolution = true;
322     } //-- void setResolution(float) 
323 
324     /***
325      * Method setWaveband
326      * 
327      * @param index
328      * @param vWaveband
329      */
330     public void setWaveband(int index, org.astrogrid.registry.beans.v10.resource.dataservice.types.Waveband vWaveband)
331         throws java.lang.IndexOutOfBoundsException
332     {
333         //-- check bounds for index
334         if ((index < 0) || (index > _wavebandList.size())) {
335             throw new IndexOutOfBoundsException();
336         }
337         _wavebandList.set(index, vWaveband);
338     } //-- void setWaveband(int, org.astrogrid.registry.beans.v10.resource.dataservice.types.Waveband) 
339 
340     /***
341      * Method setWaveband
342      * 
343      * @param wavebandArray
344      */
345     public void setWaveband(org.astrogrid.registry.beans.v10.resource.dataservice.types.Waveband[] wavebandArray)
346     {
347         //-- copy array
348         _wavebandList.clear();
349         for (int i = 0; i < wavebandArray.length; i++) {
350             _wavebandList.add(wavebandArray[i]);
351         }
352     } //-- void setWaveband(org.astrogrid.registry.beans.v10.resource.dataservice.types.Waveband) 
353 
354     /***
355      * Method unmarshalSpectral
356      * 
357      * @param reader
358      */
359     public static org.astrogrid.registry.beans.v10.resource.dataservice.Spectral unmarshalSpectral(java.io.Reader reader)
360         throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
361     {
362         return (org.astrogrid.registry.beans.v10.resource.dataservice.Spectral) Unmarshaller.unmarshal(org.astrogrid.registry.beans.v10.resource.dataservice.Spectral.class, reader);
363     } //-- org.astrogrid.registry.beans.v10.resource.dataservice.Spectral unmarshalSpectral(java.io.Reader) 
364 
365     /***
366      * Method validate
367      */
368     public void validate()
369         throws org.exolab.castor.xml.ValidationException
370     {
371         org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
372         validator.validate(this);
373     } //-- void validate() 
374 
375 }