apply gpl development license
[jalview.git] / src / jalview / schemabinding / version2 / Sequence.java
1 /*\r
2  * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)\r
3  * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
4  * \r
5  * This program is free software; you can redistribute it and/or\r
6  * modify it under the terms of the GNU General Public License\r
7  * as published by the Free Software Foundation; either version 2\r
8  * of the License, or (at your option) any later version.\r
9  * \r
10  * This program is distributed in the hope that it will be useful,\r
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
13  * GNU General Public License for more details.\r
14  * \r
15  * You should have received a copy of the GNU General Public License\r
16  * along with this program; if not, write to the Free Software\r
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA\r
18  */\r
19 package jalview.schemabinding.version2;\r
20 \r
21   //---------------------------------/\r
22  //- Imported classes and packages -/\r
23 //---------------------------------/\r
24 \r
25 import org.exolab.castor.xml.Marshaller;\r
26 import org.exolab.castor.xml.Unmarshaller;\r
27 \r
28 /**\r
29  * Class Sequence.\r
30  * \r
31  * @version $Revision$ $Date$\r
32  */\r
33 public class Sequence extends jalview.schemabinding.version2.SequenceType \r
34 implements java.io.Serializable\r
35 {\r
36 \r
37 \r
38       //--------------------------/\r
39      //- Class/Member Variables -/\r
40     //--------------------------/\r
41 \r
42     /**\r
43      * dataset sequence id for this sequence. Will be created as\r
44      * union of sequences.\r
45      *  \r
46      */\r
47     private java.lang.String _dsseqid;\r
48 \r
49     /**\r
50      * Field _DBRefList.\r
51      */\r
52     private java.util.Vector _DBRefList;\r
53 \r
54 \r
55       //----------------/\r
56      //- Constructors -/\r
57     //----------------/\r
58 \r
59     public Sequence() {\r
60         super();\r
61         this._DBRefList = new java.util.Vector();\r
62     }\r
63 \r
64 \r
65       //-----------/\r
66      //- Methods -/\r
67     //-----------/\r
68 \r
69     /**\r
70      * \r
71      * \r
72      * @param vDBRef\r
73      * @throws java.lang.IndexOutOfBoundsException if the index\r
74      * given is outside the bounds of the collection\r
75      */\r
76     public void addDBRef(\r
77             final jalview.schemabinding.version2.DBRef vDBRef)\r
78     throws java.lang.IndexOutOfBoundsException {\r
79         this._DBRefList.addElement(vDBRef);\r
80     }\r
81 \r
82     /**\r
83      * \r
84      * \r
85      * @param index\r
86      * @param vDBRef\r
87      * @throws java.lang.IndexOutOfBoundsException if the index\r
88      * given is outside the bounds of the collection\r
89      */\r
90     public void addDBRef(\r
91             final int index,\r
92             final jalview.schemabinding.version2.DBRef vDBRef)\r
93     throws java.lang.IndexOutOfBoundsException {\r
94         this._DBRefList.add(index, vDBRef);\r
95     }\r
96 \r
97     /**\r
98      * Method enumerateDBRef.\r
99      * \r
100      * @return an Enumeration over all\r
101      * jalview.schemabinding.version2.DBRef elements\r
102      */\r
103     public java.util.Enumeration enumerateDBRef(\r
104     ) {\r
105         return this._DBRefList.elements();\r
106     }\r
107 \r
108     /**\r
109      * Method getDBRef.\r
110      * \r
111      * @param index\r
112      * @throws java.lang.IndexOutOfBoundsException if the index\r
113      * given is outside the bounds of the collection\r
114      * @return the value of the\r
115      * jalview.schemabinding.version2.DBRef at the given index\r
116      */\r
117     public jalview.schemabinding.version2.DBRef getDBRef(\r
118             final int index)\r
119     throws java.lang.IndexOutOfBoundsException {\r
120         // check bounds for index\r
121         if (index < 0 || index >= this._DBRefList.size()) {\r
122             throw new IndexOutOfBoundsException("getDBRef: Index value '" + index + "' not in range [0.." + (this._DBRefList.size() - 1) + "]");\r
123         }\r
124         \r
125         return (jalview.schemabinding.version2.DBRef) _DBRefList.get(index);\r
126     }\r
127 \r
128     /**\r
129      * Method getDBRef.Returns the contents of the collection in an\r
130      * Array.  <p>Note:  Just in case the collection contents are\r
131      * changing in another thread, we pass a 0-length Array of the\r
132      * correct type into the API call.  This way we <i>know</i>\r
133      * that the Array returned is of exactly the correct length.\r
134      * \r
135      * @return this collection as an Array\r
136      */\r
137     public jalview.schemabinding.version2.DBRef[] getDBRef(\r
138     ) {\r
139         jalview.schemabinding.version2.DBRef[] array = new jalview.schemabinding.version2.DBRef[0];\r
140         return (jalview.schemabinding.version2.DBRef[]) this._DBRefList.toArray(array);\r
141     }\r
142 \r
143     /**\r
144      * Method getDBRefCount.\r
145      * \r
146      * @return the size of this collection\r
147      */\r
148     public int getDBRefCount(\r
149     ) {\r
150         return this._DBRefList.size();\r
151     }\r
152 \r
153     /**\r
154      * Returns the value of field 'dsseqid'. The field 'dsseqid'\r
155      * has the following description: dataset sequence id for this\r
156      * sequence. Will be created as union of sequences.\r
157      *  \r
158      * \r
159      * @return the value of field 'Dsseqid'.\r
160      */\r
161     public java.lang.String getDsseqid(\r
162     ) {\r
163         return this._dsseqid;\r
164     }\r
165 \r
166     /**\r
167      * Method isValid.\r
168      * \r
169      * @return true if this object is valid according to the schema\r
170      */\r
171     public boolean isValid(\r
172     ) {\r
173         try {\r
174             validate();\r
175         } catch (org.exolab.castor.xml.ValidationException vex) {\r
176             return false;\r
177         }\r
178         return true;\r
179     }\r
180 \r
181     /**\r
182      * \r
183      * \r
184      * @param out\r
185      * @throws org.exolab.castor.xml.MarshalException if object is\r
186      * null or if any SAXException is thrown during marshaling\r
187      * @throws org.exolab.castor.xml.ValidationException if this\r
188      * object is an invalid instance according to the schema\r
189      */\r
190     public void marshal(\r
191             final java.io.Writer out)\r
192     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {\r
193         Marshaller.marshal(this, out);\r
194     }\r
195 \r
196     /**\r
197      * \r
198      * \r
199      * @param handler\r
200      * @throws java.io.IOException if an IOException occurs during\r
201      * marshaling\r
202      * @throws org.exolab.castor.xml.ValidationException if this\r
203      * object is an invalid instance according to the schema\r
204      * @throws org.exolab.castor.xml.MarshalException if object is\r
205      * null or if any SAXException is thrown during marshaling\r
206      */\r
207     public void marshal(\r
208             final org.xml.sax.ContentHandler handler)\r
209     throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {\r
210         Marshaller.marshal(this, handler);\r
211     }\r
212 \r
213     /**\r
214      */\r
215     public void removeAllDBRef(\r
216     ) {\r
217         this._DBRefList.clear();\r
218     }\r
219 \r
220     /**\r
221      * Method removeDBRef.\r
222      * \r
223      * @param vDBRef\r
224      * @return true if the object was removed from the collection.\r
225      */\r
226     public boolean removeDBRef(\r
227             final jalview.schemabinding.version2.DBRef vDBRef) {\r
228         boolean removed = _DBRefList.remove(vDBRef);\r
229         return removed;\r
230     }\r
231 \r
232     /**\r
233      * Method removeDBRefAt.\r
234      * \r
235      * @param index\r
236      * @return the element removed from the collection\r
237      */\r
238     public jalview.schemabinding.version2.DBRef removeDBRefAt(\r
239             final int index) {\r
240         java.lang.Object obj = this._DBRefList.remove(index);\r
241         return (jalview.schemabinding.version2.DBRef) obj;\r
242     }\r
243 \r
244     /**\r
245      * \r
246      * \r
247      * @param index\r
248      * @param vDBRef\r
249      * @throws java.lang.IndexOutOfBoundsException if the index\r
250      * given is outside the bounds of the collection\r
251      */\r
252     public void setDBRef(\r
253             final int index,\r
254             final jalview.schemabinding.version2.DBRef vDBRef)\r
255     throws java.lang.IndexOutOfBoundsException {\r
256         // check bounds for index\r
257         if (index < 0 || index >= this._DBRefList.size()) {\r
258             throw new IndexOutOfBoundsException("setDBRef: Index value '" + index + "' not in range [0.." + (this._DBRefList.size() - 1) + "]");\r
259         }\r
260         \r
261         this._DBRefList.set(index, vDBRef);\r
262     }\r
263 \r
264     /**\r
265      * \r
266      * \r
267      * @param vDBRefArray\r
268      */\r
269     public void setDBRef(\r
270             final jalview.schemabinding.version2.DBRef[] vDBRefArray) {\r
271         //-- copy array\r
272         _DBRefList.clear();\r
273         \r
274         for (int i = 0; i < vDBRefArray.length; i++) {\r
275                 this._DBRefList.add(vDBRefArray[i]);\r
276         }\r
277     }\r
278 \r
279     /**\r
280      * Sets the value of field 'dsseqid'. The field 'dsseqid' has\r
281      * the following description: dataset sequence id for this\r
282      * sequence. Will be created as union of sequences.\r
283      *  \r
284      * \r
285      * @param dsseqid the value of field 'dsseqid'.\r
286      */\r
287     public void setDsseqid(\r
288             final java.lang.String dsseqid) {\r
289         this._dsseqid = dsseqid;\r
290     }\r
291 \r
292     /**\r
293      * Method unmarshal.\r
294      * \r
295      * @param reader\r
296      * @throws org.exolab.castor.xml.MarshalException if object is\r
297      * null or if any SAXException is thrown during marshaling\r
298      * @throws org.exolab.castor.xml.ValidationException if this\r
299      * object is an invalid instance according to the schema\r
300      * @return the unmarshaled\r
301      * jalview.schemabinding.version2.SequenceType\r
302      */\r
303     public static jalview.schemabinding.version2.SequenceType unmarshal(\r
304             final java.io.Reader reader)\r
305     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {\r
306         return (jalview.schemabinding.version2.SequenceType) Unmarshaller.unmarshal(jalview.schemabinding.version2.Sequence.class, reader);\r
307     }\r
308 \r
309     /**\r
310      * \r
311      * \r
312      * @throws org.exolab.castor.xml.ValidationException if this\r
313      * object is an invalid instance according to the schema\r
314      */\r
315     public void validate(\r
316     )\r
317     throws org.exolab.castor.xml.ValidationException {\r
318         org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();\r
319         validator.validate(this);\r
320     }\r
321 \r
322 }\r