2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
3 * Copyright (C) 2014 The Jalview Authors
5 * This file is part of Jalview.
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.
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.
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.
21 package jalview.schemabinding.version2;
23 //---------------------------------/
24 //- Imported classes and packages -/
25 //---------------------------------/
27 import org.exolab.castor.xml.Marshaller;
28 import org.exolab.castor.xml.Unmarshaller;
31 * developed after mapRangeType from
32 * http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes
34 * This effectively represents a java.util.MapList object
37 * @version $Revision$ $Date$
39 public class MapListType implements java.io.Serializable
42 // --------------------------/
43 // - Class/Member Variables -/
44 // --------------------------/
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
53 private long _mapFromUnit;
56 * keeps track of state for field: _mapFromUnit
58 private boolean _has_mapFromUnit;
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
67 private long _mapToUnit;
70 * keeps track of state for field: _mapToUnit
72 private boolean _has_mapToUnit;
75 * a region from start to end inclusive
77 private java.util.Vector _mapListFromList;
80 * a region from start to end inclusive
82 private java.util.Vector _mapListToList;
91 this._mapListFromList = new java.util.Vector();
92 this._mapListToList = new java.util.Vector();
102 * @param vMapListFrom
103 * @throws java.lang.IndexOutOfBoundsException
104 * if the index given is outside the bounds of the collection
106 public void addMapListFrom(
107 final jalview.schemabinding.version2.MapListFrom vMapListFrom)
108 throws java.lang.IndexOutOfBoundsException
110 this._mapListFromList.addElement(vMapListFrom);
117 * @param vMapListFrom
118 * @throws java.lang.IndexOutOfBoundsException
119 * if the index given is outside the bounds of the collection
121 public void addMapListFrom(final int index,
122 final jalview.schemabinding.version2.MapListFrom vMapListFrom)
123 throws java.lang.IndexOutOfBoundsException
125 this._mapListFromList.add(index, vMapListFrom);
132 * @throws java.lang.IndexOutOfBoundsException
133 * if the index given is outside the bounds of the collection
135 public void addMapListTo(
136 final jalview.schemabinding.version2.MapListTo vMapListTo)
137 throws java.lang.IndexOutOfBoundsException
139 this._mapListToList.addElement(vMapListTo);
147 * @throws java.lang.IndexOutOfBoundsException
148 * if the index given is outside the bounds of the collection
150 public void addMapListTo(final int index,
151 final jalview.schemabinding.version2.MapListTo vMapListTo)
152 throws java.lang.IndexOutOfBoundsException
154 this._mapListToList.add(index, vMapListTo);
159 public void deleteMapFromUnit()
161 this._has_mapFromUnit = false;
166 public void deleteMapToUnit()
168 this._has_mapToUnit = false;
172 * Method enumerateMapListFrom.
174 * @return an Enumeration over all jalview.schemabinding.version2.MapListFrom
177 public java.util.Enumeration enumerateMapListFrom()
179 return this._mapListFromList.elements();
183 * Method enumerateMapListTo.
185 * @return an Enumeration over all jalview.schemabinding.version2.MapListTo
188 public java.util.Enumeration enumerateMapListTo()
190 return this._mapListToList.elements();
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.
201 * @return the value of field 'MapFromUnit'.
203 public long getMapFromUnit()
205 return this._mapFromUnit;
209 * Method getMapListFrom.
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
217 public jalview.schemabinding.version2.MapListFrom getMapListFrom(
218 final int index) throws java.lang.IndexOutOfBoundsException
220 // check bounds for index
221 if (index < 0 || index >= this._mapListFromList.size())
223 throw new IndexOutOfBoundsException("getMapListFrom: Index value '"
224 + index + "' not in range [0.."
225 + (this._mapListFromList.size() - 1) + "]");
228 return (jalview.schemabinding.version2.MapListFrom) _mapListFromList
233 * Method getMapListFrom.Returns the contents of the collection in an Array.
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.
239 * @return this collection as an Array
241 public jalview.schemabinding.version2.MapListFrom[] getMapListFrom()
243 jalview.schemabinding.version2.MapListFrom[] array = new jalview.schemabinding.version2.MapListFrom[0];
244 return (jalview.schemabinding.version2.MapListFrom[]) this._mapListFromList
249 * Method getMapListFromCount.
251 * @return the size of this collection
253 public int getMapListFromCount()
255 return this._mapListFromList.size();
259 * Method getMapListTo.
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
267 public jalview.schemabinding.version2.MapListTo getMapListTo(
268 final int index) throws java.lang.IndexOutOfBoundsException
270 // check bounds for index
271 if (index < 0 || index >= this._mapListToList.size())
273 throw new IndexOutOfBoundsException("getMapListTo: Index value '"
274 + index + "' not in range [0.."
275 + (this._mapListToList.size() - 1) + "]");
278 return (jalview.schemabinding.version2.MapListTo) _mapListToList
283 * Method getMapListTo.Returns the contents of the collection in an Array.
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.
289 * @return this collection as an Array
291 public jalview.schemabinding.version2.MapListTo[] getMapListTo()
293 jalview.schemabinding.version2.MapListTo[] array = new jalview.schemabinding.version2.MapListTo[0];
294 return (jalview.schemabinding.version2.MapListTo[]) this._mapListToList
299 * Method getMapListToCount.
301 * @return the size of this collection
303 public int getMapListToCount()
305 return this._mapListToList.size();
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.
316 * @return the value of field 'MapToUnit'.
318 public long getMapToUnit()
320 return this._mapToUnit;
324 * Method hasMapFromUnit.
326 * @return true if at least one MapFromUnit has been added
328 public boolean hasMapFromUnit()
330 return this._has_mapFromUnit;
334 * Method hasMapToUnit.
336 * @return true if at least one MapToUnit has been added
338 public boolean hasMapToUnit()
340 return this._has_mapToUnit;
346 * @return true if this object is valid according to the schema
348 public boolean isValid()
353 } catch (org.exolab.castor.xml.ValidationException vex)
364 * @throws org.exolab.castor.xml.MarshalException
365 * if object is null or if any SAXException is thrown during
367 * @throws org.exolab.castor.xml.ValidationException
368 * if this object is an invalid instance according to the schema
370 public void marshal(final java.io.Writer out)
371 throws org.exolab.castor.xml.MarshalException,
372 org.exolab.castor.xml.ValidationException
374 Marshaller.marshal(this, out);
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
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
394 Marshaller.marshal(this, handler);
399 public void removeAllMapListFrom()
401 this._mapListFromList.clear();
406 public void removeAllMapListTo()
408 this._mapListToList.clear();
412 * Method removeMapListFrom.
414 * @param vMapListFrom
415 * @return true if the object was removed from the collection.
417 public boolean removeMapListFrom(
418 final jalview.schemabinding.version2.MapListFrom vMapListFrom)
420 boolean removed = _mapListFromList.remove(vMapListFrom);
425 * Method removeMapListFromAt.
428 * @return the element removed from the collection
430 public jalview.schemabinding.version2.MapListFrom removeMapListFromAt(
433 java.lang.Object obj = this._mapListFromList.remove(index);
434 return (jalview.schemabinding.version2.MapListFrom) obj;
438 * Method removeMapListTo.
441 * @return true if the object was removed from the collection.
443 public boolean removeMapListTo(
444 final jalview.schemabinding.version2.MapListTo vMapListTo)
446 boolean removed = _mapListToList.remove(vMapListTo);
451 * Method removeMapListToAt.
454 * @return the element removed from the collection
456 public jalview.schemabinding.version2.MapListTo removeMapListToAt(
459 java.lang.Object obj = this._mapListToList.remove(index);
460 return (jalview.schemabinding.version2.MapListTo) obj;
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.
472 * the value of field 'mapFromUnit'.
474 public void setMapFromUnit(final long mapFromUnit)
476 this._mapFromUnit = mapFromUnit;
477 this._has_mapFromUnit = true;
484 * @param vMapListFrom
485 * @throws java.lang.IndexOutOfBoundsException
486 * if the index given is outside the bounds of the collection
488 public void setMapListFrom(final int index,
489 final jalview.schemabinding.version2.MapListFrom vMapListFrom)
490 throws java.lang.IndexOutOfBoundsException
492 // check bounds for index
493 if (index < 0 || index >= this._mapListFromList.size())
495 throw new IndexOutOfBoundsException("setMapListFrom: Index value '"
496 + index + "' not in range [0.."
497 + (this._mapListFromList.size() - 1) + "]");
500 this._mapListFromList.set(index, vMapListFrom);
506 * @param vMapListFromArray
508 public void setMapListFrom(
509 final jalview.schemabinding.version2.MapListFrom[] vMapListFromArray)
512 _mapListFromList.clear();
514 for (int i = 0; i < vMapListFromArray.length; i++)
516 this._mapListFromList.add(vMapListFromArray[i]);
525 * @throws java.lang.IndexOutOfBoundsException
526 * if the index given is outside the bounds of the collection
528 public void setMapListTo(final int index,
529 final jalview.schemabinding.version2.MapListTo vMapListTo)
530 throws java.lang.IndexOutOfBoundsException
532 // check bounds for index
533 if (index < 0 || index >= this._mapListToList.size())
535 throw new IndexOutOfBoundsException("setMapListTo: Index value '"
536 + index + "' not in range [0.."
537 + (this._mapListToList.size() - 1) + "]");
540 this._mapListToList.set(index, vMapListTo);
546 * @param vMapListToArray
548 public void setMapListTo(
549 final jalview.schemabinding.version2.MapListTo[] vMapListToArray)
552 _mapListToList.clear();
554 for (int i = 0; i < vMapListToArray.length; i++)
556 this._mapListToList.add(vMapListToArray[i]);
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.
569 * the value of field 'mapToUnit'.
571 public void setMapToUnit(final long mapToUnit)
573 this._mapToUnit = mapToUnit;
574 this._has_mapToUnit = true;
581 * @throws org.exolab.castor.xml.MarshalException
582 * if object is null or if any SAXException is thrown during
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
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
593 return (jalview.schemabinding.version2.MapListType) Unmarshaller
594 .unmarshal(jalview.schemabinding.version2.MapListType.class,
601 * @throws org.exolab.castor.xml.ValidationException
602 * if this object is an invalid instance according to the schema
604 public void validate() throws org.exolab.castor.xml.ValidationException
606 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
607 validator.validate(this);