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: AccessType.java,v 1.14 2007/01/04 16:26:08 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.AccessURLType;
21  import org.astrogrid.registry.beans.resource.dataservice.types.RightsType;
22  import org.exolab.castor.xml.MarshalException;
23  import org.exolab.castor.xml.Marshaller;
24  import org.exolab.castor.xml.Unmarshaller;
25  import org.exolab.castor.xml.ValidationException;
26  import org.xml.sax.ContentHandler;
27  
28  /***
29   * Class AccessType.
30   * 
31   * @version $Revision: 1.14 $ $Date: 2007/01/04 16:26:08 $
32   */
33  public class AccessType extends org.astrogrid.common.bean.BaseBean 
34  implements java.io.Serializable
35  {
36  
37  
38        //--------------------------/
39       //- Class/Member Variables -/
40      //--------------------------/
41  
42      /***
43       * The physical or digital manifestation of the information
44       * supported
45       *  by a resource.
46       *  
47       */
48      private java.util.ArrayList _formatList;
49  
50      /***
51       * Information about rights held in and over the resource.
52       *  
53       */
54      private org.astrogrid.registry.beans.resource.dataservice.types.RightsType _rights;
55  
56      /***
57       * Specifically, this is a URL that can be used to
58       *  download the data contained in the data collection in
59       *  question. 
60       *  
61       */
62      private org.astrogrid.registry.beans.resource.AccessURLType _accessURL;
63  
64  
65        //----------------/
66       //- Constructors -/
67      //----------------/
68  
69      public AccessType() {
70          super();
71          _formatList = new ArrayList();
72      } //-- org.astrogrid.registry.beans.resource.dataservice.AccessType()
73  
74  
75        //-----------/
76       //- Methods -/
77      //-----------/
78  
79      /***
80       * Method addFormat
81       * 
82       * @param vFormat
83       */
84      public void addFormat(org.astrogrid.registry.beans.resource.dataservice.FormatType vFormat)
85          throws java.lang.IndexOutOfBoundsException
86      {
87          _formatList.add(vFormat);
88      } //-- void addFormat(org.astrogrid.registry.beans.resource.dataservice.FormatType) 
89  
90      /***
91       * Method addFormat
92       * 
93       * @param index
94       * @param vFormat
95       */
96      public void addFormat(int index, org.astrogrid.registry.beans.resource.dataservice.FormatType vFormat)
97          throws java.lang.IndexOutOfBoundsException
98      {
99          _formatList.add(index, vFormat);
100     } //-- void addFormat(int, org.astrogrid.registry.beans.resource.dataservice.FormatType) 
101 
102     /***
103      * Method clearFormat
104      */
105     public void clearFormat()
106     {
107         _formatList.clear();
108     } //-- void clearFormat() 
109 
110     /***
111      * Method enumerateFormat
112      */
113     public java.util.Enumeration enumerateFormat()
114     {
115         return new org.exolab.castor.util.IteratorEnumeration(_formatList.iterator());
116     } //-- java.util.Enumeration enumerateFormat() 
117 
118     /***
119      * Note: hashCode() has not been overriden
120      * 
121      * @param obj
122      */
123     public boolean equals(java.lang.Object obj)
124     {
125         if ( this == obj )
126             return true;
127         
128         if (super.equals(obj)==false)
129             return false;
130         
131         if (obj instanceof AccessType) {
132         
133             AccessType temp = (AccessType)obj;
134             if (this._formatList != null) {
135                 if (temp._formatList == null) return false;
136                 else if (!(this._formatList.equals(temp._formatList))) 
137                     return false;
138             }
139             else if (temp._formatList != null)
140                 return false;
141             if (this._rights != null) {
142                 if (temp._rights == null) return false;
143                 else if (!(this._rights.equals(temp._rights))) 
144                     return false;
145             }
146             else if (temp._rights != null)
147                 return false;
148             if (this._accessURL != null) {
149                 if (temp._accessURL == null) return false;
150                 else if (!(this._accessURL.equals(temp._accessURL))) 
151                     return false;
152             }
153             else if (temp._accessURL != null)
154                 return false;
155             return true;
156         }
157         return false;
158     } //-- boolean equals(java.lang.Object) 
159 
160     /***
161      * Returns the value of field 'accessURL'. The field
162      * 'accessURL' has the following description: Specifically,
163      * this is a URL that can be used to
164      *  download the data contained in the data collection in
165      *  question. 
166      *  
167      * 
168      * @return the value of field 'accessURL'.
169      */
170     public org.astrogrid.registry.beans.resource.AccessURLType getAccessURL()
171     {
172         return this._accessURL;
173     } //-- org.astrogrid.registry.beans.resource.AccessURLType getAccessURL() 
174 
175     /***
176      * Method getFormat
177      * 
178      * @param index
179      */
180     public org.astrogrid.registry.beans.resource.dataservice.FormatType getFormat(int index)
181         throws java.lang.IndexOutOfBoundsException
182     {
183         //-- check bounds for index
184         if ((index < 0) || (index > _formatList.size())) {
185             throw new IndexOutOfBoundsException();
186         }
187         
188         return (org.astrogrid.registry.beans.resource.dataservice.FormatType) _formatList.get(index);
189     } //-- org.astrogrid.registry.beans.resource.dataservice.FormatType getFormat(int) 
190 
191     /***
192      * Method getFormat
193      */
194     public org.astrogrid.registry.beans.resource.dataservice.FormatType[] getFormat()
195     {
196         int size = _formatList.size();
197         org.astrogrid.registry.beans.resource.dataservice.FormatType[] mArray = new org.astrogrid.registry.beans.resource.dataservice.FormatType[size];
198         for (int index = 0; index < size; index++) {
199             mArray[index] = (org.astrogrid.registry.beans.resource.dataservice.FormatType) _formatList.get(index);
200         }
201         return mArray;
202     } //-- org.astrogrid.registry.beans.resource.dataservice.FormatType[] getFormat() 
203 
204     /***
205      * Method getFormatCount
206      */
207     public int getFormatCount()
208     {
209         return _formatList.size();
210     } //-- int getFormatCount() 
211 
212     /***
213      * Returns the value of field 'rights'. The field 'rights' has
214      * the following description: Information about rights held in
215      * and over the resource.
216      *  
217      * 
218      * @return the value of field 'rights'.
219      */
220     public org.astrogrid.registry.beans.resource.dataservice.types.RightsType getRights()
221     {
222         return this._rights;
223     } //-- org.astrogrid.registry.beans.resource.dataservice.types.RightsType getRights() 
224 
225     /***
226      * Method isValid
227      */
228     public boolean isValid()
229     {
230         try {
231             validate();
232         }
233         catch (org.exolab.castor.xml.ValidationException vex) {
234             return false;
235         }
236         return true;
237     } //-- boolean isValid() 
238 
239     /***
240      * Method marshal
241      * 
242      * @param out
243      */
244     public void marshal(java.io.Writer out)
245         throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
246     {
247         
248         Marshaller.marshal(this, out);
249     } //-- void marshal(java.io.Writer) 
250 
251     /***
252      * Method marshal
253      * 
254      * @param handler
255      */
256     public void marshal(org.xml.sax.ContentHandler handler)
257         throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
258     {
259         
260         Marshaller.marshal(this, handler);
261     } //-- void marshal(org.xml.sax.ContentHandler) 
262 
263     /***
264      * Method removeFormat
265      * 
266      * @param vFormat
267      */
268     public boolean removeFormat(org.astrogrid.registry.beans.resource.dataservice.FormatType vFormat)
269     {
270         boolean removed = _formatList.remove(vFormat);
271         return removed;
272     } //-- boolean removeFormat(org.astrogrid.registry.beans.resource.dataservice.FormatType) 
273 
274     /***
275      * Sets the value of field 'accessURL'. The field 'accessURL'
276      * has the following description: Specifically, this is a URL
277      * that can be used to
278      *  download the data contained in the data collection in
279      *  question. 
280      *  
281      * 
282      * @param accessURL the value of field 'accessURL'.
283      */
284     public void setAccessURL(org.astrogrid.registry.beans.resource.AccessURLType accessURL)
285     {
286         this._accessURL = accessURL;
287     } //-- void setAccessURL(org.astrogrid.registry.beans.resource.AccessURLType) 
288 
289     /***
290      * Method setFormat
291      * 
292      * @param index
293      * @param vFormat
294      */
295     public void setFormat(int index, org.astrogrid.registry.beans.resource.dataservice.FormatType vFormat)
296         throws java.lang.IndexOutOfBoundsException
297     {
298         //-- check bounds for index
299         if ((index < 0) || (index > _formatList.size())) {
300             throw new IndexOutOfBoundsException();
301         }
302         _formatList.set(index, vFormat);
303     } //-- void setFormat(int, org.astrogrid.registry.beans.resource.dataservice.FormatType) 
304 
305     /***
306      * Method setFormat
307      * 
308      * @param formatArray
309      */
310     public void setFormat(org.astrogrid.registry.beans.resource.dataservice.FormatType[] formatArray)
311     {
312         //-- copy array
313         _formatList.clear();
314         for (int i = 0; i < formatArray.length; i++) {
315             _formatList.add(formatArray[i]);
316         }
317     } //-- void setFormat(org.astrogrid.registry.beans.resource.dataservice.FormatType) 
318 
319     /***
320      * Sets the value of field 'rights'. The field 'rights' has the
321      * following description: Information about rights held in and
322      * over the resource.
323      *  
324      * 
325      * @param rights the value of field 'rights'.
326      */
327     public void setRights(org.astrogrid.registry.beans.resource.dataservice.types.RightsType rights)
328     {
329         this._rights = rights;
330     } //-- void setRights(org.astrogrid.registry.beans.resource.dataservice.types.RightsType) 
331 
332     /***
333      * Method unmarshalAccessType
334      * 
335      * @param reader
336      */
337     public static org.astrogrid.registry.beans.resource.dataservice.AccessType unmarshalAccessType(java.io.Reader reader)
338         throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
339     {
340         return (org.astrogrid.registry.beans.resource.dataservice.AccessType) Unmarshaller.unmarshal(org.astrogrid.registry.beans.resource.dataservice.AccessType.class, reader);
341     } //-- org.astrogrid.registry.beans.resource.dataservice.AccessType unmarshalAccessType(java.io.Reader) 
342 
343     /***
344      * Method validate
345      */
346     public void validate()
347         throws org.exolab.castor.xml.ValidationException
348     {
349         org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
350         validator.validate(this);
351     } //-- void validate() 
352 
353 }