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