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