Jalview 2.6 source licence
[jalview.git] / src / jalview / schemabinding / version2 / Pdbids.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 Pdbids.\r
29  * \r
30  * @version $Revision$ $Date$\r
31  */\r
32 public class Pdbids extends jalview.schemabinding.version2.Pdbentry\r
33         implements java.io.Serializable\r
34 {\r
35 \r
36   // --------------------------/\r
37   // - Class/Member Variables -/\r
38   // --------------------------/\r
39 \r
40   /**\r
41    * Field _structureStateList.\r
42    */\r
43   private java.util.Vector _structureStateList;\r
44 \r
45   // ----------------/\r
46   // - Constructors -/\r
47   // ----------------/\r
48 \r
49   public Pdbids()\r
50   {\r
51     super();\r
52     this._structureStateList = new java.util.Vector();\r
53   }\r
54 \r
55   // -----------/\r
56   // - Methods -/\r
57   // -----------/\r
58 \r
59   /**\r
60    * \r
61    * \r
62    * @param vStructureState\r
63    * @throws java.lang.IndexOutOfBoundsException\r
64    *           if the index given is outside the bounds of the collection\r
65    */\r
66   public void addStructureState(\r
67           final jalview.schemabinding.version2.StructureState vStructureState)\r
68           throws java.lang.IndexOutOfBoundsException\r
69   {\r
70     this._structureStateList.addElement(vStructureState);\r
71   }\r
72 \r
73   /**\r
74    * \r
75    * \r
76    * @param index\r
77    * @param vStructureState\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 addStructureState(\r
82           final int index,\r
83           final jalview.schemabinding.version2.StructureState vStructureState)\r
84           throws java.lang.IndexOutOfBoundsException\r
85   {\r
86     this._structureStateList.add(index, vStructureState);\r
87   }\r
88 \r
89   /**\r
90    * Method enumerateStructureState.\r
91    * \r
92    * @return an Enumeration over all\r
93    *         jalview.schemabinding.version2.StructureState elements\r
94    */\r
95   public java.util.Enumeration enumerateStructureState()\r
96   {\r
97     return this._structureStateList.elements();\r
98   }\r
99 \r
100   /**\r
101    * Method getStructureState.\r
102    * \r
103    * @param index\r
104    * @throws java.lang.IndexOutOfBoundsException\r
105    *           if the index given is outside the bounds of the collection\r
106    * @return the value of the jalview.schemabinding.version2.StructureState at\r
107    *         the given index\r
108    */\r
109   public jalview.schemabinding.version2.StructureState getStructureState(\r
110           final int index) throws java.lang.IndexOutOfBoundsException\r
111   {\r
112     // check bounds for index\r
113     if (index < 0 || index >= this._structureStateList.size())\r
114     {\r
115       throw new IndexOutOfBoundsException(\r
116               "getStructureState: Index value '" + index\r
117                       + "' not in range [0.."\r
118                       + (this._structureStateList.size() - 1) + "]");\r
119     }\r
120 \r
121     return (jalview.schemabinding.version2.StructureState) _structureStateList\r
122             .get(index);\r
123   }\r
124 \r
125   /**\r
126    * Method getStructureState.Returns the contents of the collection in an\r
127    * Array.\r
128    * <p>\r
129    * Note: Just in case the collection contents are changing in another thread,\r
130    * we pass a 0-length Array of the correct type into the API call. This way we\r
131    * <i>know</i> that the Array returned is of exactly the correct length.\r
132    * \r
133    * @return this collection as an Array\r
134    */\r
135   public jalview.schemabinding.version2.StructureState[] getStructureState()\r
136   {\r
137     jalview.schemabinding.version2.StructureState[] array = new jalview.schemabinding.version2.StructureState[0];\r
138     return (jalview.schemabinding.version2.StructureState[]) this._structureStateList\r
139             .toArray(array);\r
140   }\r
141 \r
142   /**\r
143    * Method getStructureStateCount.\r
144    * \r
145    * @return the size of this collection\r
146    */\r
147   public int getStructureStateCount()\r
148   {\r
149     return this._structureStateList.size();\r
150   }\r
151 \r
152   /**\r
153    * Method isValid.\r
154    * \r
155    * @return true if this object is valid according to the schema\r
156    */\r
157   public boolean isValid()\r
158   {\r
159     try\r
160     {\r
161       validate();\r
162     } catch (org.exolab.castor.xml.ValidationException vex)\r
163     {\r
164       return false;\r
165     }\r
166     return true;\r
167   }\r
168 \r
169   /**\r
170    * \r
171    * \r
172    * @param out\r
173    * @throws org.exolab.castor.xml.MarshalException\r
174    *           if object is null or if any SAXException is thrown during\r
175    *           marshaling\r
176    * @throws org.exolab.castor.xml.ValidationException\r
177    *           if this object is an invalid instance according to the schema\r
178    */\r
179   public void marshal(final java.io.Writer out)\r
180           throws org.exolab.castor.xml.MarshalException,\r
181           org.exolab.castor.xml.ValidationException\r
182   {\r
183     Marshaller.marshal(this, out);\r
184   }\r
185 \r
186   /**\r
187    * \r
188    * \r
189    * @param handler\r
190    * @throws java.io.IOException\r
191    *           if an IOException occurs during marshaling\r
192    * @throws org.exolab.castor.xml.ValidationException\r
193    *           if this object is an invalid instance according to the schema\r
194    * @throws org.exolab.castor.xml.MarshalException\r
195    *           if object is null or if any SAXException is thrown during\r
196    *           marshaling\r
197    */\r
198   public void marshal(final org.xml.sax.ContentHandler handler)\r
199           throws java.io.IOException,\r
200           org.exolab.castor.xml.MarshalException,\r
201           org.exolab.castor.xml.ValidationException\r
202   {\r
203     Marshaller.marshal(this, handler);\r
204   }\r
205 \r
206   /**\r
207      */\r
208   public void removeAllStructureState()\r
209   {\r
210     this._structureStateList.clear();\r
211   }\r
212 \r
213   /**\r
214    * Method removeStructureState.\r
215    * \r
216    * @param vStructureState\r
217    * @return true if the object was removed from the collection.\r
218    */\r
219   public boolean removeStructureState(\r
220           final jalview.schemabinding.version2.StructureState vStructureState)\r
221   {\r
222     boolean removed = _structureStateList.remove(vStructureState);\r
223     return removed;\r
224   }\r
225 \r
226   /**\r
227    * Method removeStructureStateAt.\r
228    * \r
229    * @param index\r
230    * @return the element removed from the collection\r
231    */\r
232   public jalview.schemabinding.version2.StructureState removeStructureStateAt(\r
233           final int index)\r
234   {\r
235     java.lang.Object obj = this._structureStateList.remove(index);\r
236     return (jalview.schemabinding.version2.StructureState) obj;\r
237   }\r
238 \r
239   /**\r
240    * \r
241    * \r
242    * @param index\r
243    * @param vStructureState\r
244    * @throws java.lang.IndexOutOfBoundsException\r
245    *           if the index given is outside the bounds of the collection\r
246    */\r
247   public void setStructureState(\r
248           final int index,\r
249           final jalview.schemabinding.version2.StructureState vStructureState)\r
250           throws java.lang.IndexOutOfBoundsException\r
251   {\r
252     // check bounds for index\r
253     if (index < 0 || index >= this._structureStateList.size())\r
254     {\r
255       throw new IndexOutOfBoundsException(\r
256               "setStructureState: Index value '" + index\r
257                       + "' not in range [0.."\r
258                       + (this._structureStateList.size() - 1) + "]");\r
259     }\r
260 \r
261     this._structureStateList.set(index, vStructureState);\r
262   }\r
263 \r
264   /**\r
265    * \r
266    * \r
267    * @param vStructureStateArray\r
268    */\r
269   public void setStructureState(\r
270           final jalview.schemabinding.version2.StructureState[] vStructureStateArray)\r
271   {\r
272     // -- copy array\r
273     _structureStateList.clear();\r
274 \r
275     for (int i = 0; i < vStructureStateArray.length; i++)\r
276     {\r
277       this._structureStateList.add(vStructureStateArray[i]);\r
278     }\r
279   }\r
280 \r
281   /**\r
282    * Method unmarshal.\r
283    * \r
284    * @param reader\r
285    * @throws org.exolab.castor.xml.MarshalException\r
286    *           if object is null or if any SAXException is thrown during\r
287    *           marshaling\r
288    * @throws org.exolab.castor.xml.ValidationException\r
289    *           if this object is an invalid instance according to the schema\r
290    * @return the unmarshaled jalview.schemabinding.version2.Pdbentry\r
291    */\r
292   public static jalview.schemabinding.version2.Pdbentry unmarshal(\r
293           final java.io.Reader reader)\r
294           throws org.exolab.castor.xml.MarshalException,\r
295           org.exolab.castor.xml.ValidationException\r
296   {\r
297     return (jalview.schemabinding.version2.Pdbentry) Unmarshaller\r
298             .unmarshal(jalview.schemabinding.version2.Pdbids.class, reader);\r
299   }\r
300 \r
301   /**\r
302    * \r
303    * \r
304    * @throws org.exolab.castor.xml.ValidationException\r
305    *           if this object is an invalid instance according to the schema\r
306    */\r
307   public void validate() throws org.exolab.castor.xml.ValidationException\r
308   {\r
309     org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();\r
310     validator.validate(this);\r
311   }\r
312 \r
313 }\r