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