JAL-1503 update version in GPL header
[jalview.git] / src / jalview / schemabinding / version2 / Sequence.java
1 /*******************************************************************************
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.1)
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.  
17  * If not, see <http://www.gnu.org/licenses/>.
18  * The Jalview Authors are detailed in the 'AUTHORS' file.
19  ******************************************************************************/
20 /*
21  * This class was automatically generated with 
22  * <a href="http://www.castor.org">Castor 1.1</a>, using an XML
23  * Schema.
24  * $Id$
25  */
26
27 package jalview.schemabinding.version2;
28
29 //---------------------------------/
30 //- Imported classes and packages -/
31 //---------------------------------/
32
33 import org.exolab.castor.xml.Marshaller;
34 import org.exolab.castor.xml.Unmarshaller;
35
36 /**
37  * Class Sequence.
38  * 
39  * @version $Revision$ $Date$
40  */
41 public class Sequence extends jalview.schemabinding.version2.SequenceType
42         implements java.io.Serializable
43 {
44
45   // --------------------------/
46   // - Class/Member Variables -/
47   // --------------------------/
48
49   /**
50    * dataset sequence id for this sequence. Will be created as union of
51    * sequences.
52    * 
53    */
54   private java.lang.String _dsseqid;
55
56   /**
57    * Field _DBRefList.
58    */
59   private java.util.Vector _DBRefList;
60
61   // ----------------/
62   // - Constructors -/
63   // ----------------/
64
65   public Sequence()
66   {
67     super();
68     this._DBRefList = new java.util.Vector();
69   }
70
71   // -----------/
72   // - Methods -/
73   // -----------/
74
75   /**
76    * 
77    * 
78    * @param vDBRef
79    * @throws java.lang.IndexOutOfBoundsException
80    *           if the index given is outside the bounds of the collection
81    */
82   public void addDBRef(final jalview.schemabinding.version2.DBRef vDBRef)
83           throws java.lang.IndexOutOfBoundsException
84   {
85     this._DBRefList.addElement(vDBRef);
86   }
87
88   /**
89    * 
90    * 
91    * @param index
92    * @param vDBRef
93    * @throws java.lang.IndexOutOfBoundsException
94    *           if the index given is outside the bounds of the collection
95    */
96   public void addDBRef(final int index,
97           final jalview.schemabinding.version2.DBRef vDBRef)
98           throws java.lang.IndexOutOfBoundsException
99   {
100     this._DBRefList.add(index, vDBRef);
101   }
102
103   /**
104    * Method enumerateDBRef.
105    * 
106    * @return an Enumeration over all jalview.schemabinding.version2.DBRef
107    *         elements
108    */
109   public java.util.Enumeration enumerateDBRef()
110   {
111     return this._DBRefList.elements();
112   }
113
114   /**
115    * Method getDBRef.
116    * 
117    * @param index
118    * @throws java.lang.IndexOutOfBoundsException
119    *           if the index given is outside the bounds of the collection
120    * @return the value of the jalview.schemabinding.version2.DBRef at the given
121    *         index
122    */
123   public jalview.schemabinding.version2.DBRef getDBRef(final int index)
124           throws java.lang.IndexOutOfBoundsException
125   {
126     // check bounds for index
127     if (index < 0 || index >= this._DBRefList.size())
128     {
129       throw new IndexOutOfBoundsException("getDBRef: Index value '" + index
130               + "' not in range [0.." + (this._DBRefList.size() - 1) + "]");
131     }
132
133     return (jalview.schemabinding.version2.DBRef) _DBRefList.get(index);
134   }
135
136   /**
137    * Method getDBRef.Returns the contents of the collection in an Array.
138    * <p>
139    * Note: Just in case the collection contents are changing in another thread,
140    * we pass a 0-length Array of the correct type into the API call. This way we
141    * <i>know</i> that the Array returned is of exactly the correct length.
142    * 
143    * @return this collection as an Array
144    */
145   public jalview.schemabinding.version2.DBRef[] getDBRef()
146   {
147     jalview.schemabinding.version2.DBRef[] array = new jalview.schemabinding.version2.DBRef[0];
148     return (jalview.schemabinding.version2.DBRef[]) this._DBRefList
149             .toArray(array);
150   }
151
152   /**
153    * Method getDBRefCount.
154    * 
155    * @return the size of this collection
156    */
157   public int getDBRefCount()
158   {
159     return this._DBRefList.size();
160   }
161
162   /**
163    * Returns the value of field 'dsseqid'. The field 'dsseqid' has the following
164    * description: dataset sequence id for this sequence. Will be created as
165    * union of sequences.
166    * 
167    * 
168    * @return the value of field 'Dsseqid'.
169    */
170   public java.lang.String getDsseqid()
171   {
172     return this._dsseqid;
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 removeAllDBRef()
232   {
233     this._DBRefList.clear();
234   }
235
236   /**
237    * Method removeDBRef.
238    * 
239    * @param vDBRef
240    * @return true if the object was removed from the collection.
241    */
242   public boolean removeDBRef(
243           final jalview.schemabinding.version2.DBRef vDBRef)
244   {
245     boolean removed = _DBRefList.remove(vDBRef);
246     return removed;
247   }
248
249   /**
250    * Method removeDBRefAt.
251    * 
252    * @param index
253    * @return the element removed from the collection
254    */
255   public jalview.schemabinding.version2.DBRef removeDBRefAt(final int index)
256   {
257     java.lang.Object obj = this._DBRefList.remove(index);
258     return (jalview.schemabinding.version2.DBRef) obj;
259   }
260
261   /**
262    * 
263    * 
264    * @param index
265    * @param vDBRef
266    * @throws java.lang.IndexOutOfBoundsException
267    *           if the index given is outside the bounds of the collection
268    */
269   public void setDBRef(final int index,
270           final jalview.schemabinding.version2.DBRef vDBRef)
271           throws java.lang.IndexOutOfBoundsException
272   {
273     // check bounds for index
274     if (index < 0 || index >= this._DBRefList.size())
275     {
276       throw new IndexOutOfBoundsException("setDBRef: Index value '" + index
277               + "' not in range [0.." + (this._DBRefList.size() - 1) + "]");
278     }
279
280     this._DBRefList.set(index, vDBRef);
281   }
282
283   /**
284    * 
285    * 
286    * @param vDBRefArray
287    */
288   public void setDBRef(
289           final jalview.schemabinding.version2.DBRef[] vDBRefArray)
290   {
291     // -- copy array
292     _DBRefList.clear();
293
294     for (int i = 0; i < vDBRefArray.length; i++)
295     {
296       this._DBRefList.add(vDBRefArray[i]);
297     }
298   }
299
300   /**
301    * Sets the value of field 'dsseqid'. The field 'dsseqid' has the following
302    * description: dataset sequence id for this sequence. Will be created as
303    * union of sequences.
304    * 
305    * 
306    * @param dsseqid
307    *          the value of field 'dsseqid'.
308    */
309   public void setDsseqid(final java.lang.String dsseqid)
310   {
311     this._dsseqid = dsseqid;
312   }
313
314   /**
315    * Method unmarshal.
316    * 
317    * @param reader
318    * @throws org.exolab.castor.xml.MarshalException
319    *           if object is null or if any SAXException is thrown during
320    *           marshaling
321    * @throws org.exolab.castor.xml.ValidationException
322    *           if this object is an invalid instance according to the schema
323    * @return the unmarshaled jalview.schemabinding.version2.SequenceType
324    */
325   public static jalview.schemabinding.version2.SequenceType unmarshal(
326           final java.io.Reader reader)
327           throws org.exolab.castor.xml.MarshalException,
328           org.exolab.castor.xml.ValidationException
329   {
330     return (jalview.schemabinding.version2.SequenceType) Unmarshaller
331             .unmarshal(jalview.schemabinding.version2.Sequence.class,
332                     reader);
333   }
334
335   /**
336    * 
337    * 
338    * @throws org.exolab.castor.xml.ValidationException
339    *           if this object is an invalid instance according to the schema
340    */
341   public void validate() throws org.exolab.castor.xml.ValidationException
342   {
343     org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
344     validator.validate(this);
345   }
346
347 }