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