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