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: SpectralType.java,v 1.14 2007/01/04 16:26:07 clq2 Exp $
6    */
7   
8   package org.astrogrid.registry.beans.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.resource.dataservice.types.WavebandType;
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 SpectralType.
29   * 
30   * @version $Revision: 1.14 $ $Date: 2007/01/04 16:26:07 $
31   */
32  public class SpectralType 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.resource.dataservice.WavelengthRangeType _wavelengthRange;
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 _spectralResolution;
62  
63      /***
64       * keeps track of state for field: _spectralResolution
65       */
66      private boolean _has_spectralResolution;
67  
68  
69        //----------------/
70       //- Constructors -/
71      //----------------/
72  
73      public SpectralType() {
74          super();
75          _wavebandList = new ArrayList();
76      } //-- org.astrogrid.registry.beans.resource.dataservice.SpectralType()
77  
78  
79        //-----------/
80       //- Methods -/
81      //-----------/
82  
83      /***
84       * Method addWaveband
85       * 
86       * @param vWaveband
87       */
88      public void addWaveband(org.astrogrid.registry.beans.resource.dataservice.types.WavebandType vWaveband)
89          throws java.lang.IndexOutOfBoundsException
90      {
91          _wavebandList.add(vWaveband);
92      } //-- void addWaveband(org.astrogrid.registry.beans.resource.dataservice.types.WavebandType) 
93  
94      /***
95       * Method addWaveband
96       * 
97       * @param index
98       * @param vWaveband
99       */
100     public void addWaveband(int index, org.astrogrid.registry.beans.resource.dataservice.types.WavebandType vWaveband)
101         throws java.lang.IndexOutOfBoundsException
102     {
103         _wavebandList.add(index, vWaveband);
104     } //-- void addWaveband(int, org.astrogrid.registry.beans.resource.dataservice.types.WavebandType) 
105 
106     /***
107      * Method clearWaveband
108      */
109     public void clearWaveband()
110     {
111         _wavebandList.clear();
112     } //-- void clearWaveband() 
113 
114     /***
115      * Method deleteSpectralResolution
116      */
117     public void deleteSpectralResolution()
118     {
119         this._has_spectralResolution= false;
120     } //-- void deleteSpectralResolution() 
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 SpectralType) {
144         
145             SpectralType temp = (SpectralType)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._wavelengthRange != null) {
154                 if (temp._wavelengthRange == null) return false;
155                 else if (!(this._wavelengthRange.equals(temp._wavelengthRange))) 
156                     return false;
157             }
158             else if (temp._wavelengthRange != null)
159                 return false;
160             if (this._spectralResolution != temp._spectralResolution)
161                 return false;
162             if (this._has_spectralResolution != temp._has_spectralResolution)
163                 return false;
164             return true;
165         }
166         return false;
167     } //-- boolean equals(java.lang.Object) 
168 
169     /***
170      * Returns the value of field 'spectralResolution'. The field
171      * 'spectralResolution' has the following description: The
172      * spectral resolution that is typical of the
173      *  observations of interest, given as a ratio of the
174      * wavelength
175      *  width (delta-lambda) to the observing wavelength (lambda).
176      *  
177      * 
178      * @return the value of field 'spectralResolution'.
179      */
180     public float getSpectralResolution()
181     {
182         return this._spectralResolution;
183     } //-- float getSpectralResolution() 
184 
185     /***
186      * Method getWaveband
187      * 
188      * @param index
189      */
190     public org.astrogrid.registry.beans.resource.dataservice.types.WavebandType getWaveband(int index)
191         throws java.lang.IndexOutOfBoundsException
192     {
193         //-- check bounds for index
194         if ((index < 0) || (index > _wavebandList.size())) {
195             throw new IndexOutOfBoundsException();
196         }
197         
198         return (org.astrogrid.registry.beans.resource.dataservice.types.WavebandType) _wavebandList.get(index);
199     } //-- org.astrogrid.registry.beans.resource.dataservice.types.WavebandType getWaveband(int) 
200 
201     /***
202      * Method getWaveband
203      */
204     public org.astrogrid.registry.beans.resource.dataservice.types.WavebandType[] getWaveband()
205     {
206         int size = _wavebandList.size();
207         org.astrogrid.registry.beans.resource.dataservice.types.WavebandType[] mArray = new org.astrogrid.registry.beans.resource.dataservice.types.WavebandType[size];
208         for (int index = 0; index < size; index++) {
209             mArray[index] = (org.astrogrid.registry.beans.resource.dataservice.types.WavebandType) _wavebandList.get(index);
210         }
211         return mArray;
212     } //-- org.astrogrid.registry.beans.resource.dataservice.types.WavebandType[] getWaveband() 
213 
214     /***
215      * Method getWavebandCount
216      */
217     public int getWavebandCount()
218     {
219         return _wavebandList.size();
220     } //-- int getWavebandCount() 
221 
222     /***
223      * Returns the value of field 'wavelengthRange'. The field
224      * 'wavelengthRange' has the following description: a range of
225      * the electro-magnetic spectrum specified by 
226      *  a lower and upper wavelength limit.
227      *  
228      * 
229      * @return the value of field 'wavelengthRange'.
230      */
231     public org.astrogrid.registry.beans.resource.dataservice.WavelengthRangeType getWavelengthRange()
232     {
233         return this._wavelengthRange;
234     } //-- org.astrogrid.registry.beans.resource.dataservice.WavelengthRangeType getWavelengthRange() 
235 
236     /***
237      * Method hasSpectralResolution
238      */
239     public boolean hasSpectralResolution()
240     {
241         return this._has_spectralResolution;
242     } //-- boolean hasSpectralResolution() 
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.resource.dataservice.types.WavebandType vWaveband)
288     {
289         boolean removed = _wavebandList.remove(vWaveband);
290         return removed;
291     } //-- boolean removeWaveband(org.astrogrid.registry.beans.resource.dataservice.types.WavebandType) 
292 
293     /***
294      * Sets the value of field 'spectralResolution'. The field
295      * 'spectralResolution' has the following description: The
296      * spectral resolution that is typical of the
297      *  observations of interest, given as a ratio of the
298      * wavelength
299      *  width (delta-lambda) to the observing wavelength (lambda).
300      *  
301      * 
302      * @param spectralResolution the value of field
303      * 'spectralResolution'.
304      */
305     public void setSpectralResolution(float spectralResolution)
306     {
307         this._spectralResolution = spectralResolution;
308         this._has_spectralResolution = true;
309     } //-- void setSpectralResolution(float) 
310 
311     /***
312      * Method setWaveband
313      * 
314      * @param index
315      * @param vWaveband
316      */
317     public void setWaveband(int index, org.astrogrid.registry.beans.resource.dataservice.types.WavebandType vWaveband)
318         throws java.lang.IndexOutOfBoundsException
319     {
320         //-- check bounds for index
321         if ((index < 0) || (index > _wavebandList.size())) {
322             throw new IndexOutOfBoundsException();
323         }
324         _wavebandList.set(index, vWaveband);
325     } //-- void setWaveband(int, org.astrogrid.registry.beans.resource.dataservice.types.WavebandType) 
326 
327     /***
328      * Method setWaveband
329      * 
330      * @param wavebandArray
331      */
332     public void setWaveband(org.astrogrid.registry.beans.resource.dataservice.types.WavebandType[] wavebandArray)
333     {
334         //-- copy array
335         _wavebandList.clear();
336         for (int i = 0; i < wavebandArray.length; i++) {
337             _wavebandList.add(wavebandArray[i]);
338         }
339     } //-- void setWaveband(org.astrogrid.registry.beans.resource.dataservice.types.WavebandType) 
340 
341     /***
342      * Sets the value of field 'wavelengthRange'. The field
343      * 'wavelengthRange' has the following description: a range of
344      * the electro-magnetic spectrum specified by 
345      *  a lower and upper wavelength limit.
346      *  
347      * 
348      * @param wavelengthRange the value of field 'wavelengthRange'.
349      */
350     public void setWavelengthRange(org.astrogrid.registry.beans.resource.dataservice.WavelengthRangeType wavelengthRange)
351     {
352         this._wavelengthRange = wavelengthRange;
353     } //-- void setWavelengthRange(org.astrogrid.registry.beans.resource.dataservice.WavelengthRangeType) 
354 
355     /***
356      * Method unmarshalSpectralType
357      * 
358      * @param reader
359      */
360     public static org.astrogrid.registry.beans.resource.dataservice.SpectralType unmarshalSpectralType(java.io.Reader reader)
361         throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
362     {
363         return (org.astrogrid.registry.beans.resource.dataservice.SpectralType) Unmarshaller.unmarshal(org.astrogrid.registry.beans.resource.dataservice.SpectralType.class, reader);
364     } //-- org.astrogrid.registry.beans.resource.dataservice.SpectralType unmarshalSpectralType(java.io.Reader) 
365 
366     /***
367      * Method validate
368      */
369     public void validate()
370         throws org.exolab.castor.xml.ValidationException
371     {
372         org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
373         validator.validate(this);
374     } //-- void validate() 
375 
376 }