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