Copyright test
[jalview.git] / src / jalview / schemabinding / version2 / MapListType.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  * developed after mapRangeType from
39  * http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes
40  * 
41  * This effectively represents a java.util.MapList object
42  * 
43  * 
44  * @version $Revision$ $Date$
45  */
46 public class MapListType implements java.io.Serializable
47 {
48
49   // --------------------------/
50   // - Class/Member Variables -/
51   // --------------------------/
52
53   /**
54    * number of dictionary symbol widths involved in each mapped position on this
55    * sequence (for example, 3 for a dna sequence exon region that is being
56    * mapped to a protein sequence). This is optional, since the unit can be
57    * usually be inferred from the dictionary type of each sequence involved in
58    * the mapping.
59    */
60   private long _mapFromUnit;
61
62   /**
63    * keeps track of state for field: _mapFromUnit
64    */
65   private boolean _has_mapFromUnit;
66
67   /**
68    * number of dictionary symbol widths involved in each mapped position on this
69    * sequence (for example, 3 for a dna sequence exon region that is being
70    * mapped to a protein sequence). This is optional, since the unit can be
71    * usually be inferred from the dictionary type of each sequence involved in
72    * the mapping.
73    */
74   private long _mapToUnit;
75
76   /**
77    * keeps track of state for field: _mapToUnit
78    */
79   private boolean _has_mapToUnit;
80
81   /**
82    * a region from start to end inclusive
83    */
84   private java.util.Vector _mapListFromList;
85
86   /**
87    * a region from start to end inclusive
88    */
89   private java.util.Vector _mapListToList;
90
91   // ----------------/
92   // - Constructors -/
93   // ----------------/
94
95   public MapListType()
96   {
97     super();
98     this._mapListFromList = new java.util.Vector();
99     this._mapListToList = new java.util.Vector();
100   }
101
102   // -----------/
103   // - Methods -/
104   // -----------/
105
106   /**
107    * 
108    * 
109    * @param vMapListFrom
110    * @throws java.lang.IndexOutOfBoundsException
111    *           if the index given is outside the bounds of the collection
112    */
113   public void addMapListFrom(
114           final jalview.schemabinding.version2.MapListFrom vMapListFrom)
115           throws java.lang.IndexOutOfBoundsException
116   {
117     this._mapListFromList.addElement(vMapListFrom);
118   }
119
120   /**
121    * 
122    * 
123    * @param index
124    * @param vMapListFrom
125    * @throws java.lang.IndexOutOfBoundsException
126    *           if the index given is outside the bounds of the collection
127    */
128   public void addMapListFrom(final int index,
129           final jalview.schemabinding.version2.MapListFrom vMapListFrom)
130           throws java.lang.IndexOutOfBoundsException
131   {
132     this._mapListFromList.add(index, vMapListFrom);
133   }
134
135   /**
136    * 
137    * 
138    * @param vMapListTo
139    * @throws java.lang.IndexOutOfBoundsException
140    *           if the index given is outside the bounds of the collection
141    */
142   public void addMapListTo(
143           final jalview.schemabinding.version2.MapListTo vMapListTo)
144           throws java.lang.IndexOutOfBoundsException
145   {
146     this._mapListToList.addElement(vMapListTo);
147   }
148
149   /**
150    * 
151    * 
152    * @param index
153    * @param vMapListTo
154    * @throws java.lang.IndexOutOfBoundsException
155    *           if the index given is outside the bounds of the collection
156    */
157   public void addMapListTo(final int index,
158           final jalview.schemabinding.version2.MapListTo vMapListTo)
159           throws java.lang.IndexOutOfBoundsException
160   {
161     this._mapListToList.add(index, vMapListTo);
162   }
163
164   /**
165      */
166   public void deleteMapFromUnit()
167   {
168     this._has_mapFromUnit = false;
169   }
170
171   /**
172      */
173   public void deleteMapToUnit()
174   {
175     this._has_mapToUnit = false;
176   }
177
178   /**
179    * Method enumerateMapListFrom.
180    * 
181    * @return an Enumeration over all jalview.schemabinding.version2.MapListFrom
182    *         elements
183    */
184   public java.util.Enumeration enumerateMapListFrom()
185   {
186     return this._mapListFromList.elements();
187   }
188
189   /**
190    * Method enumerateMapListTo.
191    * 
192    * @return an Enumeration over all jalview.schemabinding.version2.MapListTo
193    *         elements
194    */
195   public java.util.Enumeration enumerateMapListTo()
196   {
197     return this._mapListToList.elements();
198   }
199
200   /**
201    * Returns the value of field 'mapFromUnit'. The field 'mapFromUnit' has the
202    * following description: number of dictionary symbol widths involved in each
203    * mapped position on this sequence (for example, 3 for a dna sequence exon
204    * region that is being mapped to a protein sequence). This is optional, since
205    * the unit can be usually be inferred from the dictionary type of each
206    * sequence involved in the mapping.
207    * 
208    * @return the value of field 'MapFromUnit'.
209    */
210   public long getMapFromUnit()
211   {
212     return this._mapFromUnit;
213   }
214
215   /**
216    * Method getMapListFrom.
217    * 
218    * @param index
219    * @throws java.lang.IndexOutOfBoundsException
220    *           if the index given is outside the bounds of the collection
221    * @return the value of the jalview.schemabinding.version2.MapListFrom at the
222    *         given index
223    */
224   public jalview.schemabinding.version2.MapListFrom getMapListFrom(
225           final int index) throws java.lang.IndexOutOfBoundsException
226   {
227     // check bounds for index
228     if (index < 0 || index >= this._mapListFromList.size())
229     {
230       throw new IndexOutOfBoundsException("getMapListFrom: Index value '"
231               + index + "' not in range [0.."
232               + (this._mapListFromList.size() - 1) + "]");
233     }
234
235     return (jalview.schemabinding.version2.MapListFrom) _mapListFromList
236             .get(index);
237   }
238
239   /**
240    * Method getMapListFrom.Returns the contents of the collection in an Array.
241    * <p>
242    * Note: Just in case the collection contents are changing in another thread,
243    * we pass a 0-length Array of the correct type into the API call. This way we
244    * <i>know</i> that the Array returned is of exactly the correct length.
245    * 
246    * @return this collection as an Array
247    */
248   public jalview.schemabinding.version2.MapListFrom[] getMapListFrom()
249   {
250     jalview.schemabinding.version2.MapListFrom[] array = new jalview.schemabinding.version2.MapListFrom[0];
251     return (jalview.schemabinding.version2.MapListFrom[]) this._mapListFromList
252             .toArray(array);
253   }
254
255   /**
256    * Method getMapListFromCount.
257    * 
258    * @return the size of this collection
259    */
260   public int getMapListFromCount()
261   {
262     return this._mapListFromList.size();
263   }
264
265   /**
266    * Method getMapListTo.
267    * 
268    * @param index
269    * @throws java.lang.IndexOutOfBoundsException
270    *           if the index given is outside the bounds of the collection
271    * @return the value of the jalview.schemabinding.version2.MapListTo at the
272    *         given index
273    */
274   public jalview.schemabinding.version2.MapListTo getMapListTo(
275           final int index) throws java.lang.IndexOutOfBoundsException
276   {
277     // check bounds for index
278     if (index < 0 || index >= this._mapListToList.size())
279     {
280       throw new IndexOutOfBoundsException("getMapListTo: Index value '"
281               + index + "' not in range [0.."
282               + (this._mapListToList.size() - 1) + "]");
283     }
284
285     return (jalview.schemabinding.version2.MapListTo) _mapListToList
286             .get(index);
287   }
288
289   /**
290    * Method getMapListTo.Returns the contents of the collection in an Array.
291    * <p>
292    * Note: Just in case the collection contents are changing in another thread,
293    * we pass a 0-length Array of the correct type into the API call. This way we
294    * <i>know</i> that the Array returned is of exactly the correct length.
295    * 
296    * @return this collection as an Array
297    */
298   public jalview.schemabinding.version2.MapListTo[] getMapListTo()
299   {
300     jalview.schemabinding.version2.MapListTo[] array = new jalview.schemabinding.version2.MapListTo[0];
301     return (jalview.schemabinding.version2.MapListTo[]) this._mapListToList
302             .toArray(array);
303   }
304
305   /**
306    * Method getMapListToCount.
307    * 
308    * @return the size of this collection
309    */
310   public int getMapListToCount()
311   {
312     return this._mapListToList.size();
313   }
314
315   /**
316    * Returns the value of field 'mapToUnit'. The field 'mapToUnit' has the
317    * following description: number of dictionary symbol widths involved in each
318    * mapped position on this sequence (for example, 3 for a dna sequence exon
319    * region that is being mapped to a protein sequence). This is optional, since
320    * the unit can be usually be inferred from the dictionary type of each
321    * sequence involved in the mapping.
322    * 
323    * @return the value of field 'MapToUnit'.
324    */
325   public long getMapToUnit()
326   {
327     return this._mapToUnit;
328   }
329
330   /**
331    * Method hasMapFromUnit.
332    * 
333    * @return true if at least one MapFromUnit has been added
334    */
335   public boolean hasMapFromUnit()
336   {
337     return this._has_mapFromUnit;
338   }
339
340   /**
341    * Method hasMapToUnit.
342    * 
343    * @return true if at least one MapToUnit has been added
344    */
345   public boolean hasMapToUnit()
346   {
347     return this._has_mapToUnit;
348   }
349
350   /**
351    * Method isValid.
352    * 
353    * @return true if this object is valid according to the schema
354    */
355   public boolean isValid()
356   {
357     try
358     {
359       validate();
360     } catch (org.exolab.castor.xml.ValidationException vex)
361     {
362       return false;
363     }
364     return true;
365   }
366
367   /**
368    * 
369    * 
370    * @param out
371    * @throws org.exolab.castor.xml.MarshalException
372    *           if object is null or if any SAXException is thrown during
373    *           marshaling
374    * @throws org.exolab.castor.xml.ValidationException
375    *           if this object is an invalid instance according to the schema
376    */
377   public void marshal(final java.io.Writer out)
378           throws org.exolab.castor.xml.MarshalException,
379           org.exolab.castor.xml.ValidationException
380   {
381     Marshaller.marshal(this, out);
382   }
383
384   /**
385    * 
386    * 
387    * @param handler
388    * @throws java.io.IOException
389    *           if an IOException occurs during marshaling
390    * @throws org.exolab.castor.xml.ValidationException
391    *           if this object is an invalid instance according to the schema
392    * @throws org.exolab.castor.xml.MarshalException
393    *           if object is null or if any SAXException is thrown during
394    *           marshaling
395    */
396   public void marshal(final org.xml.sax.ContentHandler handler)
397           throws java.io.IOException,
398           org.exolab.castor.xml.MarshalException,
399           org.exolab.castor.xml.ValidationException
400   {
401     Marshaller.marshal(this, handler);
402   }
403
404   /**
405      */
406   public void removeAllMapListFrom()
407   {
408     this._mapListFromList.clear();
409   }
410
411   /**
412      */
413   public void removeAllMapListTo()
414   {
415     this._mapListToList.clear();
416   }
417
418   /**
419    * Method removeMapListFrom.
420    * 
421    * @param vMapListFrom
422    * @return true if the object was removed from the collection.
423    */
424   public boolean removeMapListFrom(
425           final jalview.schemabinding.version2.MapListFrom vMapListFrom)
426   {
427     boolean removed = _mapListFromList.remove(vMapListFrom);
428     return removed;
429   }
430
431   /**
432    * Method removeMapListFromAt.
433    * 
434    * @param index
435    * @return the element removed from the collection
436    */
437   public jalview.schemabinding.version2.MapListFrom removeMapListFromAt(
438           final int index)
439   {
440     java.lang.Object obj = this._mapListFromList.remove(index);
441     return (jalview.schemabinding.version2.MapListFrom) obj;
442   }
443
444   /**
445    * Method removeMapListTo.
446    * 
447    * @param vMapListTo
448    * @return true if the object was removed from the collection.
449    */
450   public boolean removeMapListTo(
451           final jalview.schemabinding.version2.MapListTo vMapListTo)
452   {
453     boolean removed = _mapListToList.remove(vMapListTo);
454     return removed;
455   }
456
457   /**
458    * Method removeMapListToAt.
459    * 
460    * @param index
461    * @return the element removed from the collection
462    */
463   public jalview.schemabinding.version2.MapListTo removeMapListToAt(
464           final int index)
465   {
466     java.lang.Object obj = this._mapListToList.remove(index);
467     return (jalview.schemabinding.version2.MapListTo) obj;
468   }
469
470   /**
471    * Sets the value of field 'mapFromUnit'. The field 'mapFromUnit' has the
472    * following description: number of dictionary symbol widths involved in each
473    * mapped position on this sequence (for example, 3 for a dna sequence exon
474    * region that is being mapped to a protein sequence). This is optional, since
475    * the unit can be usually be inferred from the dictionary type of each
476    * sequence involved in the mapping.
477    * 
478    * @param mapFromUnit
479    *          the value of field 'mapFromUnit'.
480    */
481   public void setMapFromUnit(final long mapFromUnit)
482   {
483     this._mapFromUnit = mapFromUnit;
484     this._has_mapFromUnit = true;
485   }
486
487   /**
488    * 
489    * 
490    * @param index
491    * @param vMapListFrom
492    * @throws java.lang.IndexOutOfBoundsException
493    *           if the index given is outside the bounds of the collection
494    */
495   public void setMapListFrom(final int index,
496           final jalview.schemabinding.version2.MapListFrom vMapListFrom)
497           throws java.lang.IndexOutOfBoundsException
498   {
499     // check bounds for index
500     if (index < 0 || index >= this._mapListFromList.size())
501     {
502       throw new IndexOutOfBoundsException("setMapListFrom: Index value '"
503               + index + "' not in range [0.."
504               + (this._mapListFromList.size() - 1) + "]");
505     }
506
507     this._mapListFromList.set(index, vMapListFrom);
508   }
509
510   /**
511    * 
512    * 
513    * @param vMapListFromArray
514    */
515   public void setMapListFrom(
516           final jalview.schemabinding.version2.MapListFrom[] vMapListFromArray)
517   {
518     // -- copy array
519     _mapListFromList.clear();
520
521     for (int i = 0; i < vMapListFromArray.length; i++)
522     {
523       this._mapListFromList.add(vMapListFromArray[i]);
524     }
525   }
526
527   /**
528    * 
529    * 
530    * @param index
531    * @param vMapListTo
532    * @throws java.lang.IndexOutOfBoundsException
533    *           if the index given is outside the bounds of the collection
534    */
535   public void setMapListTo(final int index,
536           final jalview.schemabinding.version2.MapListTo vMapListTo)
537           throws java.lang.IndexOutOfBoundsException
538   {
539     // check bounds for index
540     if (index < 0 || index >= this._mapListToList.size())
541     {
542       throw new IndexOutOfBoundsException("setMapListTo: Index value '"
543               + index + "' not in range [0.."
544               + (this._mapListToList.size() - 1) + "]");
545     }
546
547     this._mapListToList.set(index, vMapListTo);
548   }
549
550   /**
551    * 
552    * 
553    * @param vMapListToArray
554    */
555   public void setMapListTo(
556           final jalview.schemabinding.version2.MapListTo[] vMapListToArray)
557   {
558     // -- copy array
559     _mapListToList.clear();
560
561     for (int i = 0; i < vMapListToArray.length; i++)
562     {
563       this._mapListToList.add(vMapListToArray[i]);
564     }
565   }
566
567   /**
568    * Sets the value of field 'mapToUnit'. The field 'mapToUnit' has the
569    * following description: number of dictionary symbol widths involved in each
570    * mapped position on this sequence (for example, 3 for a dna sequence exon
571    * region that is being mapped to a protein sequence). This is optional, since
572    * the unit can be usually be inferred from the dictionary type of each
573    * sequence involved in the mapping.
574    * 
575    * @param mapToUnit
576    *          the value of field 'mapToUnit'.
577    */
578   public void setMapToUnit(final long mapToUnit)
579   {
580     this._mapToUnit = mapToUnit;
581     this._has_mapToUnit = true;
582   }
583
584   /**
585    * Method unmarshal.
586    * 
587    * @param reader
588    * @throws org.exolab.castor.xml.MarshalException
589    *           if object is null or if any SAXException is thrown during
590    *           marshaling
591    * @throws org.exolab.castor.xml.ValidationException
592    *           if this object is an invalid instance according to the schema
593    * @return the unmarshaled jalview.schemabinding.version2.MapListType
594    */
595   public static jalview.schemabinding.version2.MapListType unmarshal(
596           final java.io.Reader reader)
597           throws org.exolab.castor.xml.MarshalException,
598           org.exolab.castor.xml.ValidationException
599   {
600     return (jalview.schemabinding.version2.MapListType) Unmarshaller
601             .unmarshal(jalview.schemabinding.version2.MapListType.class,
602                     reader);
603   }
604
605   /**
606    * 
607    * 
608    * @throws org.exolab.castor.xml.ValidationException
609    *           if this object is an invalid instance according to the schema
610    */
611   public void validate() throws org.exolab.castor.xml.ValidationException
612   {
613     org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
614     validator.validate(this);
615   }
616
617 }