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