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