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