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