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