71e2eb66418567955c2536cdb63722f64ef5d3ab
[jalview.git] / src / jalview / binding / Pdbentry.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)
3  * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
4  * 
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  * 
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  * 
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
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       //----------------/
57      //- Constructors -/
58     //----------------/
59
60     public Pdbentry() {
61         super();
62         this._items = new java.util.Vector();
63     }
64
65
66       //-----------/
67      //- Methods -/
68     //-----------/
69
70     /**
71      * 
72      * 
73      * @param vPdbentryItem
74      * @throws java.lang.IndexOutOfBoundsException if the index
75      * given is outside the bounds of the collection
76      */
77     public void addPdbentryItem(
78             final jalview.binding.PdbentryItem vPdbentryItem)
79     throws java.lang.IndexOutOfBoundsException {
80         this._items.addElement(vPdbentryItem);
81     }
82
83     /**
84      * 
85      * 
86      * @param index
87      * @param vPdbentryItem
88      * @throws java.lang.IndexOutOfBoundsException if the index
89      * given is outside the bounds of the collection
90      */
91     public void addPdbentryItem(
92             final int index,
93             final jalview.binding.PdbentryItem vPdbentryItem)
94     throws java.lang.IndexOutOfBoundsException {
95         this._items.add(index, vPdbentryItem);
96     }
97
98     /**
99      * Method enumeratePdbentryItem.
100      * 
101      * @return an Enumeration over all jalview.binding.PdbentryItem
102      * elements
103      */
104     public java.util.Enumeration enumeratePdbentryItem(
105     ) {
106         return this._items.elements();
107     }
108
109     /**
110      * Returns the value of field 'id'.
111      * 
112      * @return the value of field 'Id'.
113      */
114     public java.lang.String getId(
115     ) {
116         return this._id;
117     }
118
119     /**
120      * Method getPdbentryItem.
121      * 
122      * @param index
123      * @throws java.lang.IndexOutOfBoundsException if the index
124      * given is outside the bounds of the collection
125      * @return the value of the jalview.binding.PdbentryItem at the
126      * given index
127      */
128     public jalview.binding.PdbentryItem getPdbentryItem(
129             final int index)
130     throws java.lang.IndexOutOfBoundsException {
131         // check bounds for index
132         if (index < 0 || index >= this._items.size()) {
133             throw new IndexOutOfBoundsException("getPdbentryItem: Index value '" + index + "' not in range [0.." + (this._items.size() - 1) + "]");
134         }
135         
136         return (jalview.binding.PdbentryItem) _items.get(index);
137     }
138
139     /**
140      * Method getPdbentryItem.Returns the contents of the
141      * collection in an Array.  <p>Note:  Just in case the
142      * collection contents are changing in another thread, we pass
143      * a 0-length Array of the correct type into the API call. 
144      * This way we <i>know</i> that the Array returned is of
145      * 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             validate();
184         } catch (org.exolab.castor.xml.ValidationException vex) {
185             return false;
186         }
187         return true;
188     }
189
190     /**
191      * 
192      * 
193      * @param out
194      * @throws org.exolab.castor.xml.MarshalException if object is
195      * null or if any SAXException is thrown during marshaling
196      * @throws org.exolab.castor.xml.ValidationException if this
197      * object is an invalid instance according to the schema
198      */
199     public void marshal(
200             final java.io.Writer out)
201     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
202         Marshaller.marshal(this, out);
203     }
204
205     /**
206      * 
207      * 
208      * @param handler
209      * @throws java.io.IOException if an IOException occurs during
210      * marshaling
211      * @throws org.exolab.castor.xml.ValidationException if this
212      * object is an invalid instance according to the schema
213      * @throws org.exolab.castor.xml.MarshalException if object is
214      * null or if any SAXException is thrown during marshaling
215      */
216     public void marshal(
217             final org.xml.sax.ContentHandler handler)
218     throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
219         Marshaller.marshal(this, handler);
220     }
221
222     /**
223      */
224     public void removeAllPdbentryItem(
225     ) {
226         this._items.clear();
227     }
228
229     /**
230      * Method removePdbentryItem.
231      * 
232      * @param vPdbentryItem
233      * @return true if the object was removed from the collection.
234      */
235     public boolean removePdbentryItem(
236             final jalview.binding.PdbentryItem vPdbentryItem) {
237         boolean removed = _items.remove(vPdbentryItem);
238         return removed;
239     }
240
241     /**
242      * Method removePdbentryItemAt.
243      * 
244      * @param index
245      * @return the element removed from the collection
246      */
247     public jalview.binding.PdbentryItem removePdbentryItemAt(
248             final int index) {
249         java.lang.Object obj = this._items.remove(index);
250         return (jalview.binding.PdbentryItem) obj;
251     }
252
253     /**
254      * Sets the value of field 'id'.
255      * 
256      * @param id the value of field 'id'.
257      */
258     public void setId(
259             final java.lang.String id) {
260         this._id = id;
261     }
262
263     /**
264      * 
265      * 
266      * @param index
267      * @param vPdbentryItem
268      * @throws java.lang.IndexOutOfBoundsException if the index
269      * given is outside the bounds of the collection
270      */
271     public void setPdbentryItem(
272             final int index,
273             final jalview.binding.PdbentryItem vPdbentryItem)
274     throws java.lang.IndexOutOfBoundsException {
275         // check bounds for index
276         if (index < 0 || index >= this._items.size()) {
277             throw new IndexOutOfBoundsException("setPdbentryItem: Index value '" + index + "' not in range [0.." + (this._items.size() - 1) + "]");
278         }
279         
280         this._items.set(index, vPdbentryItem);
281     }
282
283     /**
284      * 
285      * 
286      * @param vPdbentryItemArray
287      */
288     public void setPdbentryItem(
289             final jalview.binding.PdbentryItem[] vPdbentryItemArray) {
290         //-- copy array
291         _items.clear();
292         
293         for (int i = 0; i < vPdbentryItemArray.length; i++) {
294                 this._items.add(vPdbentryItemArray[i]);
295         }
296     }
297
298     /**
299      * Sets the value of field 'type'.
300      * 
301      * @param type the value of field 'type'.
302      */
303     public void setType(
304             final java.lang.String type) {
305         this._type = type;
306     }
307
308     /**
309      * Method unmarshal.
310      * 
311      * @param reader
312      * @throws org.exolab.castor.xml.MarshalException if object is
313      * null or if any SAXException is thrown during marshaling
314      * @throws org.exolab.castor.xml.ValidationException if this
315      * object is an invalid instance according to the schema
316      * @return the unmarshaled jalview.binding.Pdbentry
317      */
318     public static jalview.binding.Pdbentry unmarshal(
319             final java.io.Reader reader)
320     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
321         return (jalview.binding.Pdbentry) Unmarshaller.unmarshal(jalview.binding.Pdbentry.class, reader);
322     }
323
324     /**
325      * 
326      * 
327      * @throws org.exolab.castor.xml.ValidationException if this
328      * object is an invalid instance according to the schema
329      */
330     public void validate(
331     )
332     throws org.exolab.castor.xml.ValidationException {
333         org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
334         validator.validate(this);
335     }
336
337 }