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