merge from 2_4_Release branch
[jalview.git] / src / jalview / schemabinding / version2 / Pdbentry.java
1 /*\r
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)\r
3  * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
4  * \r
5  * This program is free software; you can redistribute it and/or\r
6  * modify it under the terms of the GNU General Public License\r
7  * as published by the Free Software Foundation; either version 2\r
8  * of the License, or (at your option) any later version.\r
9  * \r
10  * This program is distributed in the hope that it will be useful,\r
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
13  * GNU General Public License for more details.\r
14  * \r
15  * You should have received a copy of the GNU General Public License\r
16  * along with this program; if not, write to the Free Software\r
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA\r
18  */\r
19 package jalview.schemabinding.version2;\r
20 \r
21 // ---------------------------------/\r
22 // - Imported classes and packages -/\r
23 // ---------------------------------/\r
24 \r
25 import org.exolab.castor.xml.Marshaller;\r
26 import org.exolab.castor.xml.Unmarshaller;\r
27 \r
28 /**\r
29  * Class Pdbentry.\r
30  * \r
31  * @version $Revision$ $Date$\r
32  */\r
33 public class Pdbentry implements java.io.Serializable\r
34 {\r
35 \r
36   // --------------------------/\r
37   // - Class/Member Variables -/\r
38   // --------------------------/\r
39 \r
40   /**\r
41    * Field _id.\r
42    */\r
43   private java.lang.String _id;\r
44 \r
45   /**\r
46    * Field _type.\r
47    */\r
48   private java.lang.String _type;\r
49 \r
50   /**\r
51    * Field _file.\r
52    */\r
53   private java.lang.String _file;\r
54 \r
55   /**\r
56    * Field _items.\r
57    */\r
58   private java.util.Vector _items;\r
59 \r
60   // ----------------/\r
61   // - Constructors -/\r
62   // ----------------/\r
63 \r
64   public Pdbentry()\r
65   {\r
66     super();\r
67     this._items = new java.util.Vector();\r
68   }\r
69 \r
70   // -----------/\r
71   // - Methods -/\r
72   // -----------/\r
73 \r
74   /**\r
75    * \r
76    * \r
77    * @param vPdbentryItem\r
78    * @throws java.lang.IndexOutOfBoundsException\r
79    *                 if the index given is outside the bounds of the collection\r
80    */\r
81   public void addPdbentryItem(\r
82           final jalview.schemabinding.version2.PdbentryItem vPdbentryItem)\r
83           throws java.lang.IndexOutOfBoundsException\r
84   {\r
85     this._items.addElement(vPdbentryItem);\r
86   }\r
87 \r
88   /**\r
89    * \r
90    * \r
91    * @param index\r
92    * @param vPdbentryItem\r
93    * @throws java.lang.IndexOutOfBoundsException\r
94    *                 if the index given is outside the bounds of the collection\r
95    */\r
96   public void addPdbentryItem(final int index,\r
97           final jalview.schemabinding.version2.PdbentryItem vPdbentryItem)\r
98           throws java.lang.IndexOutOfBoundsException\r
99   {\r
100     this._items.add(index, vPdbentryItem);\r
101   }\r
102 \r
103   /**\r
104    * Method enumeratePdbentryItem.\r
105    * \r
106    * @return an Enumeration over all jalview.schemabinding.version2.PdbentryItem\r
107    *         elements\r
108    */\r
109   public java.util.Enumeration enumeratePdbentryItem()\r
110   {\r
111     return this._items.elements();\r
112   }\r
113 \r
114   /**\r
115    * Returns the value of field 'file'.\r
116    * \r
117    * @return the value of field 'File'.\r
118    */\r
119   public java.lang.String getFile()\r
120   {\r
121     return this._file;\r
122   }\r
123 \r
124   /**\r
125    * Returns the value of field 'id'.\r
126    * \r
127    * @return the value of field 'Id'.\r
128    */\r
129   public java.lang.String getId()\r
130   {\r
131     return this._id;\r
132   }\r
133 \r
134   /**\r
135    * Method getPdbentryItem.\r
136    * \r
137    * @param index\r
138    * @throws java.lang.IndexOutOfBoundsException\r
139    *                 if the index given is outside the bounds of the collection\r
140    * @return the value of the jalview.schemabinding.version2.PdbentryItem at the\r
141    *         given inde\r
142    */\r
143   public jalview.schemabinding.version2.PdbentryItem getPdbentryItem(\r
144           final int index) throws java.lang.IndexOutOfBoundsException\r
145   {\r
146     // check bounds for index\r
147     if (index < 0 || index >= this._items.size())\r
148     {\r
149       throw new IndexOutOfBoundsException("getPdbentryItem: Index value '"\r
150               + index + "' not in range [0.." + (this._items.size() - 1)\r
151               + "]");\r
152     }\r
153 \r
154     return (jalview.schemabinding.version2.PdbentryItem) _items.get(index);\r
155   }\r
156 \r
157   /**\r
158    * Method getPdbentryItem.Returns the contents of the collection in an Array.\r
159    * <p>\r
160    * Note: Just in case the collection contents are changing in another thread,\r
161    * we pass a 0-length Array of the correct type into the API call. This way we\r
162    * <i>know</i> that the Array returned is of exactly the correct length.\r
163    * \r
164    * @return this collection as an Array\r
165    */\r
166   public jalview.schemabinding.version2.PdbentryItem[] getPdbentryItem()\r
167   {\r
168     jalview.schemabinding.version2.PdbentryItem[] array = new jalview.schemabinding.version2.PdbentryItem[0];\r
169     return (jalview.schemabinding.version2.PdbentryItem[]) this._items\r
170             .toArray(array);\r
171   }\r
172 \r
173   /**\r
174    * Method getPdbentryItemCount.\r
175    * \r
176    * @return the size of this collection\r
177    */\r
178   public int getPdbentryItemCount()\r
179   {\r
180     return this._items.size();\r
181   }\r
182 \r
183   /**\r
184    * Returns the value of field 'type'.\r
185    * \r
186    * @return the value of field 'Type'.\r
187    */\r
188   public java.lang.String getType()\r
189   {\r
190     return this._type;\r
191   }\r
192 \r
193   /**\r
194    * Method isValid.\r
195    * \r
196    * @return true if this object is valid according to the schema\r
197    */\r
198   public boolean isValid()\r
199   {\r
200     try\r
201     {\r
202       validate();\r
203     } catch (org.exolab.castor.xml.ValidationException vex)\r
204     {\r
205       return false;\r
206     }\r
207     return true;\r
208   }\r
209 \r
210   /**\r
211    * \r
212    * \r
213    * @param out\r
214    * @throws org.exolab.castor.xml.MarshalException\r
215    *                 if object is null or if any SAXException is thrown during\r
216    *                 marshaling\r
217    * @throws org.exolab.castor.xml.ValidationException\r
218    *                 if this object is an invalid instance according to the\r
219    *                 schema\r
220    */\r
221   public void marshal(final java.io.Writer out)\r
222           throws org.exolab.castor.xml.MarshalException,\r
223           org.exolab.castor.xml.ValidationException\r
224   {\r
225     Marshaller.marshal(this, out);\r
226   }\r
227 \r
228   /**\r
229    * \r
230    * \r
231    * @param handler\r
232    * @throws java.io.IOException\r
233    *                 if an IOException occurs during marshaling\r
234    * @throws org.exolab.castor.xml.ValidationException\r
235    *                 if this object is an invalid instance according to the\r
236    *                 schema\r
237    * @throws org.exolab.castor.xml.MarshalException\r
238    *                 if object is null or if any SAXException is thrown during\r
239    *                 marshaling\r
240    */\r
241   public void marshal(final org.xml.sax.ContentHandler handler)\r
242           throws java.io.IOException,\r
243           org.exolab.castor.xml.MarshalException,\r
244           org.exolab.castor.xml.ValidationException\r
245   {\r
246     Marshaller.marshal(this, handler);\r
247   }\r
248 \r
249   /**\r
250    */\r
251   public void removeAllPdbentryItem()\r
252   {\r
253     this._items.clear();\r
254   }\r
255 \r
256   /**\r
257    * Method removePdbentryItem.\r
258    * \r
259    * @param vPdbentryItem\r
260    * @return true if the object was removed from the collection.\r
261    */\r
262   public boolean removePdbentryItem(\r
263           final jalview.schemabinding.version2.PdbentryItem vPdbentryItem)\r
264   {\r
265     boolean removed = _items.remove(vPdbentryItem);\r
266     return removed;\r
267   }\r
268 \r
269   /**\r
270    * Method removePdbentryItemAt.\r
271    * \r
272    * @param index\r
273    * @return the element removed from the collection\r
274    */\r
275   public jalview.schemabinding.version2.PdbentryItem removePdbentryItemAt(\r
276           final int index)\r
277   {\r
278     java.lang.Object obj = this._items.remove(index);\r
279     return (jalview.schemabinding.version2.PdbentryItem) obj;\r
280   }\r
281 \r
282   /**\r
283    * Sets the value of field 'file'.\r
284    * \r
285    * @param file\r
286    *                the value of field 'file'.\r
287    */\r
288   public void setFile(final java.lang.String file)\r
289   {\r
290     this._file = file;\r
291   }\r
292 \r
293   /**\r
294    * Sets the value of field 'id'.\r
295    * \r
296    * @param id\r
297    *                the value of field 'id'.\r
298    */\r
299   public void setId(final java.lang.String id)\r
300   {\r
301     this._id = id;\r
302   }\r
303 \r
304   /**\r
305    * \r
306    * \r
307    * @param index\r
308    * @param vPdbentryItem\r
309    * @throws java.lang.IndexOutOfBoundsException\r
310    *                 if the index given is outside the bounds of the collection\r
311    */\r
312   public void setPdbentryItem(final int index,\r
313           final jalview.schemabinding.version2.PdbentryItem vPdbentryItem)\r
314           throws java.lang.IndexOutOfBoundsException\r
315   {\r
316     // check bounds for index\r
317     if (index < 0 || index >= this._items.size())\r
318     {\r
319       throw new IndexOutOfBoundsException("setPdbentryItem: Index value '"\r
320               + index + "' not in range [0.." + (this._items.size() - 1)\r
321               + "]");\r
322     }\r
323 \r
324     this._items.set(index, vPdbentryItem);\r
325   }\r
326 \r
327   /**\r
328    * \r
329    * \r
330    * @param vPdbentryItemArray\r
331    */\r
332   public void setPdbentryItem(\r
333           final jalview.schemabinding.version2.PdbentryItem[] vPdbentryItemArray)\r
334   {\r
335     // -- copy array\r
336     _items.clear();\r
337 \r
338     for (int i = 0; i < vPdbentryItemArray.length; i++)\r
339     {\r
340       this._items.add(vPdbentryItemArray[i]);\r
341     }\r
342   }\r
343 \r
344   /**\r
345    * Sets the value of field 'type'.\r
346    * \r
347    * @param type\r
348    *                the value of field 'type'.\r
349    */\r
350   public void setType(final java.lang.String type)\r
351   {\r
352     this._type = type;\r
353   }\r
354 \r
355   /**\r
356    * Method unmarshal.\r
357    * \r
358    * @param reader\r
359    * @throws org.exolab.castor.xml.MarshalException\r
360    *                 if object is null or if any SAXException is thrown during\r
361    *                 marshaling\r
362    * @throws org.exolab.castor.xml.ValidationException\r
363    *                 if this object is an invalid instance according to the\r
364    *                 schema\r
365    * @return the unmarshaled jalview.schemabinding.version2.Pdbentry\r
366    */\r
367   public static jalview.schemabinding.version2.Pdbentry unmarshal(\r
368           final java.io.Reader reader)\r
369           throws org.exolab.castor.xml.MarshalException,\r
370           org.exolab.castor.xml.ValidationException\r
371   {\r
372     return (jalview.schemabinding.version2.Pdbentry) Unmarshaller\r
373             .unmarshal(jalview.schemabinding.version2.Pdbentry.class,\r
374                     reader);\r
375   }\r
376 \r
377   /**\r
378    * \r
379    * \r
380    * @throws org.exolab.castor.xml.ValidationException\r
381    *                 if this object is an invalid instance according to the\r
382    *                 schema\r
383    */\r
384   public void validate() throws org.exolab.castor.xml.ValidationException\r
385   {\r
386     org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();\r
387     validator.validate(this);\r
388   }\r
389 \r
390 }\r