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