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