JAL-1432 updated copyright notices
[jalview.git] / src / jalview / schemabinding / version2 / Pdbids.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
3  * Copyright (C) 2014 The Jalview Authors
4  * 
5  * This file is part of Jalview.
6  * 
7  * Jalview is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License 
9  * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
10  *  
11  * Jalview is distributed in the hope that it will be useful, but 
12  * WITHOUT ANY WARRANTY; without even the implied warranty 
13  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
14  * PURPOSE.  See the GNU General Public License for more details.
15  * 
16  * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
17  * The Jalview Authors are detailed in the 'AUTHORS' file.
18  */
19 package jalview.schemabinding.version2;
20
21 //---------------------------------/
22 //- Imported classes and packages -/
23 //---------------------------------/
24
25 import org.exolab.castor.xml.Marshaller;
26 import org.exolab.castor.xml.Unmarshaller;
27
28 /**
29  * Class Pdbids.
30  * 
31  * @version $Revision$ $Date$
32  */
33 public class Pdbids extends jalview.schemabinding.version2.Pdbentry
34         implements java.io.Serializable
35 {
36
37   // --------------------------/
38   // - Class/Member Variables -/
39   // --------------------------/
40
41   /**
42    * Field _structureStateList.
43    */
44   private java.util.Vector _structureStateList;
45
46   // ----------------/
47   // - Constructors -/
48   // ----------------/
49
50   public Pdbids()
51   {
52     super();
53     this._structureStateList = new java.util.Vector();
54   }
55
56   // -----------/
57   // - Methods -/
58   // -----------/
59
60   /**
61    * 
62    * 
63    * @param vStructureState
64    * @throws java.lang.IndexOutOfBoundsException
65    *           if the index given is outside the bounds of the collection
66    */
67   public void addStructureState(
68           final jalview.schemabinding.version2.StructureState vStructureState)
69           throws java.lang.IndexOutOfBoundsException
70   {
71     this._structureStateList.addElement(vStructureState);
72   }
73
74   /**
75    * 
76    * 
77    * @param index
78    * @param vStructureState
79    * @throws java.lang.IndexOutOfBoundsException
80    *           if the index given is outside the bounds of the collection
81    */
82   public void addStructureState(
83           final int index,
84           final jalview.schemabinding.version2.StructureState vStructureState)
85           throws java.lang.IndexOutOfBoundsException
86   {
87     this._structureStateList.add(index, vStructureState);
88   }
89
90   /**
91    * Method enumerateStructureState.
92    * 
93    * @return an Enumeration over all
94    *         jalview.schemabinding.version2.StructureState elements
95    */
96   public java.util.Enumeration enumerateStructureState()
97   {
98     return this._structureStateList.elements();
99   }
100
101   /**
102    * Method getStructureState.
103    * 
104    * @param index
105    * @throws java.lang.IndexOutOfBoundsException
106    *           if the index given is outside the bounds of the collection
107    * @return the value of the jalview.schemabinding.version2.StructureState at
108    *         the given index
109    */
110   public jalview.schemabinding.version2.StructureState getStructureState(
111           final int index) throws java.lang.IndexOutOfBoundsException
112   {
113     // check bounds for index
114     if (index < 0 || index >= this._structureStateList.size())
115     {
116       throw new IndexOutOfBoundsException(
117               "getStructureState: Index value '" + index
118                       + "' not in range [0.."
119                       + (this._structureStateList.size() - 1) + "]");
120     }
121
122     return (jalview.schemabinding.version2.StructureState) _structureStateList
123             .get(index);
124   }
125
126   /**
127    * Method getStructureState.Returns the contents of the collection in an
128    * Array.
129    * <p>
130    * Note: Just in case the collection contents are changing in another thread,
131    * we pass a 0-length Array of the correct type into the API call. This way we
132    * <i>know</i> that the Array returned is of exactly the correct length.
133    * 
134    * @return this collection as an Array
135    */
136   public jalview.schemabinding.version2.StructureState[] getStructureState()
137   {
138     jalview.schemabinding.version2.StructureState[] array = new jalview.schemabinding.version2.StructureState[0];
139     return (jalview.schemabinding.version2.StructureState[]) this._structureStateList
140             .toArray(array);
141   }
142
143   /**
144    * Method getStructureStateCount.
145    * 
146    * @return the size of this collection
147    */
148   public int getStructureStateCount()
149   {
150     return this._structureStateList.size();
151   }
152
153   /**
154    * Method isValid.
155    * 
156    * @return true if this object is valid according to the schema
157    */
158   public boolean isValid()
159   {
160     try
161     {
162       validate();
163     } catch (org.exolab.castor.xml.ValidationException vex)
164     {
165       return false;
166     }
167     return true;
168   }
169
170   /**
171    * 
172    * 
173    * @param out
174    * @throws org.exolab.castor.xml.MarshalException
175    *           if object is null or if any SAXException is thrown during
176    *           marshaling
177    * @throws org.exolab.castor.xml.ValidationException
178    *           if this object is an invalid instance according to the schema
179    */
180   public void marshal(final java.io.Writer out)
181           throws org.exolab.castor.xml.MarshalException,
182           org.exolab.castor.xml.ValidationException
183   {
184     Marshaller.marshal(this, out);
185   }
186
187   /**
188    * 
189    * 
190    * @param handler
191    * @throws java.io.IOException
192    *           if an IOException occurs during marshaling
193    * @throws org.exolab.castor.xml.ValidationException
194    *           if this object is an invalid instance according to the schema
195    * @throws org.exolab.castor.xml.MarshalException
196    *           if object is null or if any SAXException is thrown during
197    *           marshaling
198    */
199   public void marshal(final org.xml.sax.ContentHandler handler)
200           throws java.io.IOException,
201           org.exolab.castor.xml.MarshalException,
202           org.exolab.castor.xml.ValidationException
203   {
204     Marshaller.marshal(this, handler);
205   }
206
207   /**
208      */
209   public void removeAllStructureState()
210   {
211     this._structureStateList.clear();
212   }
213
214   /**
215    * Method removeStructureState.
216    * 
217    * @param vStructureState
218    * @return true if the object was removed from the collection.
219    */
220   public boolean removeStructureState(
221           final jalview.schemabinding.version2.StructureState vStructureState)
222   {
223     boolean removed = _structureStateList.remove(vStructureState);
224     return removed;
225   }
226
227   /**
228    * Method removeStructureStateAt.
229    * 
230    * @param index
231    * @return the element removed from the collection
232    */
233   public jalview.schemabinding.version2.StructureState removeStructureStateAt(
234           final int index)
235   {
236     java.lang.Object obj = this._structureStateList.remove(index);
237     return (jalview.schemabinding.version2.StructureState) obj;
238   }
239
240   /**
241    * 
242    * 
243    * @param index
244    * @param vStructureState
245    * @throws java.lang.IndexOutOfBoundsException
246    *           if the index given is outside the bounds of the collection
247    */
248   public void setStructureState(
249           final int index,
250           final jalview.schemabinding.version2.StructureState vStructureState)
251           throws java.lang.IndexOutOfBoundsException
252   {
253     // check bounds for index
254     if (index < 0 || index >= this._structureStateList.size())
255     {
256       throw new IndexOutOfBoundsException(
257               "setStructureState: Index value '" + index
258                       + "' not in range [0.."
259                       + (this._structureStateList.size() - 1) + "]");
260     }
261
262     this._structureStateList.set(index, vStructureState);
263   }
264
265   /**
266    * 
267    * 
268    * @param vStructureStateArray
269    */
270   public void setStructureState(
271           final jalview.schemabinding.version2.StructureState[] vStructureStateArray)
272   {
273     // -- copy array
274     _structureStateList.clear();
275
276     for (int i = 0; i < vStructureStateArray.length; i++)
277     {
278       this._structureStateList.add(vStructureStateArray[i]);
279     }
280   }
281
282   /**
283    * Method unmarshal.
284    * 
285    * @param reader
286    * @throws org.exolab.castor.xml.MarshalException
287    *           if object is null or if any SAXException is thrown during
288    *           marshaling
289    * @throws org.exolab.castor.xml.ValidationException
290    *           if this object is an invalid instance according to the schema
291    * @return the unmarshaled jalview.schemabinding.version2.Pdbentry
292    */
293   public static jalview.schemabinding.version2.Pdbentry unmarshal(
294           final java.io.Reader reader)
295           throws org.exolab.castor.xml.MarshalException,
296           org.exolab.castor.xml.ValidationException
297   {
298     return (jalview.schemabinding.version2.Pdbentry) Unmarshaller
299             .unmarshal(jalview.schemabinding.version2.Pdbids.class, reader);
300   }
301
302   /**
303    * 
304    * 
305    * @throws org.exolab.castor.xml.ValidationException
306    *           if this object is an invalid instance according to the schema
307    */
308   public void validate() throws org.exolab.castor.xml.ValidationException
309   {
310     org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
311     validator.validate(this);
312   }
313
314 }