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: VODescription.java,v 1.14 2007/01/04 16:26:22 clq2 Exp $
6    */
7   
8   package org.astrogrid.registry.beans.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 description of one or more VO Resources
28   *  This element is used as a general container for multiple
29   * resource
30   *  descriptions and can be used as a root element.
31   *  
32   * 
33   * @version $Revision: 1.14 $ $Date: 2007/01/04 16:26:22 $
34   */
35  public class VODescription extends org.astrogrid.common.bean.BaseBean 
36  implements java.io.Serializable
37  {
38  
39  
40        //--------------------------/
41       //- Class/Member Variables -/
42      //--------------------------/
43  
44      /***
45       * Any entity that is describable and identifiable by a IVOA
46       * Identifier.
47       *  
48       */
49      private java.util.ArrayList _resourceList;
50  
51  
52        //----------------/
53       //- Constructors -/
54      //----------------/
55  
56      public VODescription() {
57          super();
58          _resourceList = new ArrayList();
59      } //-- org.astrogrid.registry.beans.resource.VODescription()
60  
61  
62        //-----------/
63       //- Methods -/
64      //-----------/
65  
66      /***
67       * Method addResource
68       * 
69       * @param vResource
70       */
71      public void addResource(org.astrogrid.registry.beans.resource.ResourceType vResource)
72          throws java.lang.IndexOutOfBoundsException
73      {
74          _resourceList.add(vResource);
75      } //-- void addResource(org.astrogrid.registry.beans.resource.ResourceType) 
76  
77      /***
78       * Method addResource
79       * 
80       * @param index
81       * @param vResource
82       */
83      public void addResource(int index, org.astrogrid.registry.beans.resource.ResourceType vResource)
84          throws java.lang.IndexOutOfBoundsException
85      {
86          _resourceList.add(index, vResource);
87      } //-- void addResource(int, org.astrogrid.registry.beans.resource.ResourceType) 
88  
89      /***
90       * Method clearResource
91       */
92      public void clearResource()
93      {
94          _resourceList.clear();
95      } //-- void clearResource() 
96  
97      /***
98       * Method enumerateResource
99       */
100     public java.util.Enumeration enumerateResource()
101     {
102         return new org.exolab.castor.util.IteratorEnumeration(_resourceList.iterator());
103     } //-- java.util.Enumeration enumerateResource() 
104 
105     /***
106      * Note: hashCode() has not been overriden
107      * 
108      * @param obj
109      */
110     public boolean equals(java.lang.Object obj)
111     {
112         if ( this == obj )
113             return true;
114         
115         if (super.equals(obj)==false)
116             return false;
117         
118         if (obj instanceof VODescription) {
119         
120             VODescription temp = (VODescription)obj;
121             if (this._resourceList != null) {
122                 if (temp._resourceList == null) return false;
123                 else if (!(this._resourceList.equals(temp._resourceList))) 
124                     return false;
125             }
126             else if (temp._resourceList != null)
127                 return false;
128             return true;
129         }
130         return false;
131     } //-- boolean equals(java.lang.Object) 
132 
133     /***
134      * Method getResource
135      * 
136      * @param index
137      */
138     public org.astrogrid.registry.beans.resource.ResourceType getResource(int index)
139         throws java.lang.IndexOutOfBoundsException
140     {
141         //-- check bounds for index
142         if ((index < 0) || (index > _resourceList.size())) {
143             throw new IndexOutOfBoundsException();
144         }
145         
146         return (org.astrogrid.registry.beans.resource.ResourceType) _resourceList.get(index);
147     } //-- org.astrogrid.registry.beans.resource.ResourceType getResource(int) 
148 
149     /***
150      * Method getResource
151      */
152     public org.astrogrid.registry.beans.resource.ResourceType[] getResource()
153     {
154         int size = _resourceList.size();
155         org.astrogrid.registry.beans.resource.ResourceType[] mArray = new org.astrogrid.registry.beans.resource.ResourceType[size];
156         for (int index = 0; index < size; index++) {
157             mArray[index] = (org.astrogrid.registry.beans.resource.ResourceType) _resourceList.get(index);
158         }
159         return mArray;
160     } //-- org.astrogrid.registry.beans.resource.ResourceType[] getResource() 
161 
162     /***
163      * Method getResourceCount
164      */
165     public int getResourceCount()
166     {
167         return _resourceList.size();
168     } //-- int getResourceCount() 
169 
170     /***
171      * Method isValid
172      */
173     public boolean isValid()
174     {
175         try {
176             validate();
177         }
178         catch (org.exolab.castor.xml.ValidationException vex) {
179             return false;
180         }
181         return true;
182     } //-- boolean isValid() 
183 
184     /***
185      * Method marshal
186      * 
187      * @param out
188      */
189     public void marshal(java.io.Writer out)
190         throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
191     {
192         
193         Marshaller.marshal(this, out);
194     } //-- void marshal(java.io.Writer) 
195 
196     /***
197      * Method marshal
198      * 
199      * @param handler
200      */
201     public void marshal(org.xml.sax.ContentHandler handler)
202         throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
203     {
204         
205         Marshaller.marshal(this, handler);
206     } //-- void marshal(org.xml.sax.ContentHandler) 
207 
208     /***
209      * Method removeResource
210      * 
211      * @param vResource
212      */
213     public boolean removeResource(org.astrogrid.registry.beans.resource.ResourceType vResource)
214     {
215         boolean removed = _resourceList.remove(vResource);
216         return removed;
217     } //-- boolean removeResource(org.astrogrid.registry.beans.resource.ResourceType) 
218 
219     /***
220      * Method setResource
221      * 
222      * @param index
223      * @param vResource
224      */
225     public void setResource(int index, org.astrogrid.registry.beans.resource.ResourceType vResource)
226         throws java.lang.IndexOutOfBoundsException
227     {
228         //-- check bounds for index
229         if ((index < 0) || (index > _resourceList.size())) {
230             throw new IndexOutOfBoundsException();
231         }
232         _resourceList.set(index, vResource);
233     } //-- void setResource(int, org.astrogrid.registry.beans.resource.ResourceType) 
234 
235     /***
236      * Method setResource
237      * 
238      * @param resourceArray
239      */
240     public void setResource(org.astrogrid.registry.beans.resource.ResourceType[] resourceArray)
241     {
242         //-- copy array
243         _resourceList.clear();
244         for (int i = 0; i < resourceArray.length; i++) {
245             _resourceList.add(resourceArray[i]);
246         }
247     } //-- void setResource(org.astrogrid.registry.beans.resource.ResourceType) 
248 
249     /***
250      * Method unmarshalVODescription
251      * 
252      * @param reader
253      */
254     public static org.astrogrid.registry.beans.resource.VODescription unmarshalVODescription(java.io.Reader reader)
255         throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
256     {
257         return (org.astrogrid.registry.beans.resource.VODescription) Unmarshaller.unmarshal(org.astrogrid.registry.beans.resource.VODescription.class, reader);
258     } //-- org.astrogrid.registry.beans.resource.VODescription unmarshalVODescription(java.io.Reader) 
259 
260     /***
261      * Method validate
262      */
263     public void validate()
264         throws org.exolab.castor.xml.ValidationException
265     {
266         org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
267         validator.validate(this);
268     } //-- void validate() 
269 
270 }