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
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
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
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
19 package jalview.schemabinding.version2;
\r
21 //---------------------------------/
\r
22 //- Imported classes and packages -/
\r
23 //---------------------------------/
\r
25 import org.exolab.castor.xml.Marshaller;
\r
26 import org.exolab.castor.xml.Unmarshaller;
\r
29 * developed after mapRangeType from
\r
30 * http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes
\r
32 * This effectively represents a java.util.MapList object
\r
35 * @version $Revision$ $Date$
\r
37 public class MapListType implements java.io.Serializable {
\r
40 //--------------------------/
\r
41 //- Class/Member Variables -/
\r
42 //--------------------------/
\r
45 * number of dictionary symbol widths involved in each
\r
46 * mapped position on this sequence (for example, 3 for a dna
\r
48 * region that is being mapped to a protein sequence). This is
\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
54 private long _mapFromUnit;
\r
57 * keeps track of state for field: _mapFromUnit
\r
59 private boolean _has_mapFromUnit;
\r
62 * number of dictionary symbol widths involved in each
\r
63 * mapped position on this sequence (for example, 3 for a dna
\r
65 * region that is being mapped to a protein sequence). This is
\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
71 private long _mapToUnit;
\r
74 * keeps track of state for field: _mapToUnit
\r
76 private boolean _has_mapToUnit;
\r
79 * a region from start to end inclusive
\r
81 private java.util.Vector _mapListFromList;
\r
84 * a region from start to end inclusive
\r
86 private java.util.Vector _mapListToList;
\r
93 public MapListType() {
\r
95 this._mapListFromList = new java.util.Vector();
\r
96 this._mapListToList = new java.util.Vector();
\r
107 * @param vMapListFrom
\r
108 * @throws java.lang.IndexOutOfBoundsException if the index
\r
109 * given is outside the bounds of the collection
\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
121 * @param vMapListFrom
\r
122 * @throws java.lang.IndexOutOfBoundsException if the index
\r
123 * given is outside the bounds of the collection
\r
125 public void addMapListFrom(
\r
127 final jalview.schemabinding.version2.MapListFrom vMapListFrom)
\r
128 throws java.lang.IndexOutOfBoundsException {
\r
129 this._mapListFromList.add(index, vMapListFrom);
\r
135 * @param vMapListTo
\r
136 * @throws java.lang.IndexOutOfBoundsException if the index
\r
137 * given is outside the bounds of the collection
\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
149 * @param vMapListTo
\r
150 * @throws java.lang.IndexOutOfBoundsException if the index
\r
151 * given is outside the bounds of the collection
\r
153 public void addMapListTo(
\r
155 final jalview.schemabinding.version2.MapListTo vMapListTo)
\r
156 throws java.lang.IndexOutOfBoundsException {
\r
157 this._mapListToList.add(index, vMapListTo);
\r
162 public void deleteMapFromUnit(
\r
164 this._has_mapFromUnit= false;
\r
169 public void deleteMapToUnit(
\r
171 this._has_mapToUnit= false;
\r
175 * Method enumerateMapListFrom.
\r
177 * @return an Enumeration over all
\r
178 * jalview.schemabinding.version2.MapListFrom elements
\r
180 public java.util.Enumeration enumerateMapListFrom(
\r
182 return this._mapListFromList.elements();
\r
186 * Method enumerateMapListTo.
\r
188 * @return an Enumeration over all
\r
189 * jalview.schemabinding.version2.MapListTo elements
\r
191 public java.util.Enumeration enumerateMapListTo(
\r
193 return this._mapListToList.elements();
\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
202 * region that is being mapped to a protein sequence). This is
\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
208 * @return the value of field 'MapFromUnit'.
\r
210 public long getMapFromUnit(
\r
212 return this._mapFromUnit;
\r
216 * Method getMapListFrom.
\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
224 public jalview.schemabinding.version2.MapListFrom getMapListFrom(
\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
232 return (jalview.schemabinding.version2.MapListFrom) _mapListFromList.get(index);
\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
242 * @return this collection as an Array
\r
244 public jalview.schemabinding.version2.MapListFrom[] getMapListFrom(
\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
251 * Method getMapListFromCount.
\r
253 * @return the size of this collection
\r
255 public int getMapListFromCount(
\r
257 return this._mapListFromList.size();
\r
261 * Method getMapListTo.
\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
269 public jalview.schemabinding.version2.MapListTo getMapListTo(
\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
277 return (jalview.schemabinding.version2.MapListTo) _mapListToList.get(index);
\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
287 * @return this collection as an Array
\r
289 public jalview.schemabinding.version2.MapListTo[] getMapListTo(
\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
296 * Method getMapListToCount.
\r
298 * @return the size of this collection
\r
300 public int getMapListToCount(
\r
302 return this._mapListToList.size();
\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
311 * region that is being mapped to a protein sequence). This is
\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
317 * @return the value of field 'MapToUnit'.
\r
319 public long getMapToUnit(
\r
321 return this._mapToUnit;
\r
325 * Method hasMapFromUnit.
\r
327 * @return true if at least one MapFromUnit has been added
\r
329 public boolean hasMapFromUnit(
\r
331 return this._has_mapFromUnit;
\r
335 * Method hasMapToUnit.
\r
337 * @return true if at least one MapToUnit has been added
\r
339 public boolean hasMapToUnit(
\r
341 return this._has_mapToUnit;
\r
347 * @return true if this object is valid according to the schema
\r
349 public boolean isValid(
\r
353 } catch (org.exolab.castor.xml.ValidationException vex) {
\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
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
378 * @throws java.io.IOException if an IOException occurs during
\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
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
393 public void removeAllMapListFrom(
\r
395 this._mapListFromList.clear();
\r
400 public void removeAllMapListTo(
\r
402 this._mapListToList.clear();
\r
406 * Method removeMapListFrom.
\r
408 * @param vMapListFrom
\r
409 * @return true if the object was removed from the collection.
\r
411 public boolean removeMapListFrom(
\r
412 final jalview.schemabinding.version2.MapListFrom vMapListFrom) {
\r
413 boolean removed = _mapListFromList.remove(vMapListFrom);
\r
418 * Method removeMapListFromAt.
\r
421 * @return the element removed from the collection
\r
423 public jalview.schemabinding.version2.MapListFrom removeMapListFromAt(
\r
425 java.lang.Object obj = this._mapListFromList.remove(index);
\r
426 return (jalview.schemabinding.version2.MapListFrom) obj;
\r
430 * Method removeMapListTo.
\r
432 * @param vMapListTo
\r
433 * @return true if the object was removed from the collection.
\r
435 public boolean removeMapListTo(
\r
436 final jalview.schemabinding.version2.MapListTo vMapListTo) {
\r
437 boolean removed = _mapListToList.remove(vMapListTo);
\r
442 * Method removeMapListToAt.
\r
445 * @return the element removed from the collection
\r
447 public jalview.schemabinding.version2.MapListTo removeMapListToAt(
\r
449 java.lang.Object obj = this._mapListToList.remove(index);
\r
450 return (jalview.schemabinding.version2.MapListTo) obj;
\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
459 * region that is being mapped to a protein sequence). This is
\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
465 * @param mapFromUnit the value of field 'mapFromUnit'.
\r
467 public void setMapFromUnit(
\r
468 final long mapFromUnit) {
\r
469 this._mapFromUnit = mapFromUnit;
\r
470 this._has_mapFromUnit = true;
\r
477 * @param vMapListFrom
\r
478 * @throws java.lang.IndexOutOfBoundsException if the index
\r
479 * given is outside the bounds of the collection
\r
481 public void setMapListFrom(
\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
490 this._mapListFromList.set(index, vMapListFrom);
\r
496 * @param vMapListFromArray
\r
498 public void setMapListFrom(
\r
499 final jalview.schemabinding.version2.MapListFrom[] vMapListFromArray) {
\r
501 _mapListFromList.clear();
\r
503 for (int i = 0; i < vMapListFromArray.length; i++) {
\r
504 this._mapListFromList.add(vMapListFromArray[i]);
\r
512 * @param vMapListTo
\r
513 * @throws java.lang.IndexOutOfBoundsException if the index
\r
514 * given is outside the bounds of the collection
\r
516 public void setMapListTo(
\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
525 this._mapListToList.set(index, vMapListTo);
\r
531 * @param vMapListToArray
\r
533 public void setMapListTo(
\r
534 final jalview.schemabinding.version2.MapListTo[] vMapListToArray) {
\r
536 _mapListToList.clear();
\r
538 for (int i = 0; i < vMapListToArray.length; i++) {
\r
539 this._mapListToList.add(vMapListToArray[i]);
\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
549 * region that is being mapped to a protein sequence). This is
\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
555 * @param mapToUnit the value of field 'mapToUnit'.
\r
557 public void setMapToUnit(
\r
558 final long mapToUnit) {
\r
559 this._mapToUnit = mapToUnit;
\r
560 this._has_mapToUnit = true;
\r
564 * Method unmarshal.
\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
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
583 * @throws org.exolab.castor.xml.ValidationException if this
\r
584 * object is an invalid instance according to the schema
\r
586 public void validate(
\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