2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
3 * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle
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 of the License, or (at your option) any later version.
11 * Jalview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
18 package jalview.schemabinding.version2;
20 //---------------------------------/
21 //- Imported classes and packages -/
22 //---------------------------------/
24 import org.exolab.castor.xml.Marshaller;
25 import org.exolab.castor.xml.Unmarshaller;
28 * developed after mapRangeType from
29 * http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes
31 * This effectively represents a java.util.MapList object
34 * @version $Revision$ $Date$
36 public class MapListType implements java.io.Serializable
39 // --------------------------/
40 // - Class/Member Variables -/
41 // --------------------------/
44 * number of dictionary symbol widths involved in each mapped position on this
45 * sequence (for example, 3 for a dna sequence exon region that is being
46 * mapped to a protein sequence). This is optional, since the unit can be
47 * usually be inferred from the dictionary type of each sequence involved in
50 private long _mapFromUnit;
53 * keeps track of state for field: _mapFromUnit
55 private boolean _has_mapFromUnit;
58 * number of dictionary symbol widths involved in each mapped position on this
59 * sequence (for example, 3 for a dna sequence exon region that is being
60 * mapped to a protein sequence). This is optional, since the unit can be
61 * usually be inferred from the dictionary type of each sequence involved in
64 private long _mapToUnit;
67 * keeps track of state for field: _mapToUnit
69 private boolean _has_mapToUnit;
72 * a region from start to end inclusive
74 private java.util.Vector _mapListFromList;
77 * a region from start to end inclusive
79 private java.util.Vector _mapListToList;
88 this._mapListFromList = new java.util.Vector();
89 this._mapListToList = new java.util.Vector();
100 * @throws java.lang.IndexOutOfBoundsException
101 * if the index given is outside the bounds of the collection
103 public void addMapListFrom(
104 final jalview.schemabinding.version2.MapListFrom vMapListFrom)
105 throws java.lang.IndexOutOfBoundsException
107 this._mapListFromList.addElement(vMapListFrom);
114 * @param vMapListFrom
115 * @throws java.lang.IndexOutOfBoundsException
116 * if the index given is outside the bounds of the collection
118 public void addMapListFrom(final int index,
119 final jalview.schemabinding.version2.MapListFrom vMapListFrom)
120 throws java.lang.IndexOutOfBoundsException
122 this._mapListFromList.add(index, vMapListFrom);
129 * @throws java.lang.IndexOutOfBoundsException
130 * if the index given is outside the bounds of the collection
132 public void addMapListTo(
133 final jalview.schemabinding.version2.MapListTo vMapListTo)
134 throws java.lang.IndexOutOfBoundsException
136 this._mapListToList.addElement(vMapListTo);
144 * @throws java.lang.IndexOutOfBoundsException
145 * if the index given is outside the bounds of the collection
147 public void addMapListTo(final int index,
148 final jalview.schemabinding.version2.MapListTo vMapListTo)
149 throws java.lang.IndexOutOfBoundsException
151 this._mapListToList.add(index, vMapListTo);
156 public void deleteMapFromUnit()
158 this._has_mapFromUnit = false;
163 public void deleteMapToUnit()
165 this._has_mapToUnit = false;
169 * Method enumerateMapListFrom.
171 * @return an Enumeration over all jalview.schemabinding.version2.MapListFrom
174 public java.util.Enumeration enumerateMapListFrom()
176 return this._mapListFromList.elements();
180 * Method enumerateMapListTo.
182 * @return an Enumeration over all jalview.schemabinding.version2.MapListTo
185 public java.util.Enumeration enumerateMapListTo()
187 return this._mapListToList.elements();
191 * Returns the value of field 'mapFromUnit'. The field 'mapFromUnit' has the
192 * following description: number of dictionary symbol widths involved in each
193 * mapped position on this sequence (for example, 3 for a dna sequence exon
194 * region that is being mapped to a protein sequence). This is optional, since
195 * the unit can be usually be inferred from the dictionary type of each
196 * sequence involved in the mapping.
198 * @return the value of field 'MapFromUnit'.
200 public long getMapFromUnit()
202 return this._mapFromUnit;
206 * Method getMapListFrom.
209 * @throws java.lang.IndexOutOfBoundsException
210 * if the index given is outside the bounds of the collection
211 * @return the value of the jalview.schemabinding.version2.MapListFrom at the
214 public jalview.schemabinding.version2.MapListFrom getMapListFrom(
215 final int index) throws java.lang.IndexOutOfBoundsException
217 // check bounds for index
218 if (index < 0 || index >= this._mapListFromList.size())
220 throw new IndexOutOfBoundsException("getMapListFrom: Index value '"
221 + index + "' not in range [0.."
222 + (this._mapListFromList.size() - 1) + "]");
225 return (jalview.schemabinding.version2.MapListFrom) _mapListFromList
230 * Method getMapListFrom.Returns the contents of the collection in an Array.
232 * Note: Just in case the collection contents are changing in another thread,
233 * we pass a 0-length Array of the correct type into the API call. This way we
234 * <i>know</i> that the Array returned is of exactly the correct length.
236 * @return this collection as an Array
238 public jalview.schemabinding.version2.MapListFrom[] getMapListFrom()
240 jalview.schemabinding.version2.MapListFrom[] array = new jalview.schemabinding.version2.MapListFrom[0];
241 return (jalview.schemabinding.version2.MapListFrom[]) this._mapListFromList
246 * Method getMapListFromCount.
248 * @return the size of this collection
250 public int getMapListFromCount()
252 return this._mapListFromList.size();
256 * Method getMapListTo.
259 * @throws java.lang.IndexOutOfBoundsException
260 * if the index given is outside the bounds of the collection
261 * @return the value of the jalview.schemabinding.version2.MapListTo at the
264 public jalview.schemabinding.version2.MapListTo getMapListTo(
265 final int index) throws java.lang.IndexOutOfBoundsException
267 // check bounds for index
268 if (index < 0 || index >= this._mapListToList.size())
270 throw new IndexOutOfBoundsException("getMapListTo: Index value '"
271 + index + "' not in range [0.."
272 + (this._mapListToList.size() - 1) + "]");
275 return (jalview.schemabinding.version2.MapListTo) _mapListToList
280 * Method getMapListTo.Returns the contents of the collection in an Array.
282 * Note: Just in case the collection contents are changing in another thread,
283 * we pass a 0-length Array of the correct type into the API call. This way we
284 * <i>know</i> that the Array returned is of exactly the correct length.
286 * @return this collection as an Array
288 public jalview.schemabinding.version2.MapListTo[] getMapListTo()
290 jalview.schemabinding.version2.MapListTo[] array = new jalview.schemabinding.version2.MapListTo[0];
291 return (jalview.schemabinding.version2.MapListTo[]) this._mapListToList
296 * Method getMapListToCount.
298 * @return the size of this collection
300 public int getMapListToCount()
302 return this._mapListToList.size();
306 * Returns the value of field 'mapToUnit'. The field 'mapToUnit' has the
307 * following description: number of dictionary symbol widths involved in each
308 * mapped position on this sequence (for example, 3 for a dna sequence exon
309 * region that is being mapped to a protein sequence). This is optional, since
310 * the unit can be usually be inferred from the dictionary type of each
311 * sequence involved in the mapping.
313 * @return the value of field 'MapToUnit'.
315 public long getMapToUnit()
317 return this._mapToUnit;
321 * Method hasMapFromUnit.
323 * @return true if at least one MapFromUnit has been added
325 public boolean hasMapFromUnit()
327 return this._has_mapFromUnit;
331 * Method hasMapToUnit.
333 * @return true if at least one MapToUnit has been added
335 public boolean hasMapToUnit()
337 return this._has_mapToUnit;
343 * @return true if this object is valid according to the schema
345 public boolean isValid()
350 } catch (org.exolab.castor.xml.ValidationException vex)
361 * @throws org.exolab.castor.xml.MarshalException
362 * if object is null or if any SAXException is thrown during
364 * @throws org.exolab.castor.xml.ValidationException
365 * if this object is an invalid instance according to the schema
367 public void marshal(final java.io.Writer out)
368 throws org.exolab.castor.xml.MarshalException,
369 org.exolab.castor.xml.ValidationException
371 Marshaller.marshal(this, out);
378 * @throws java.io.IOException
379 * if an IOException occurs during marshaling
380 * @throws org.exolab.castor.xml.ValidationException
381 * if this object is an invalid instance according to the schema
382 * @throws org.exolab.castor.xml.MarshalException
383 * if object is null or if any SAXException is thrown during
386 public void marshal(final org.xml.sax.ContentHandler handler)
387 throws java.io.IOException,
388 org.exolab.castor.xml.MarshalException,
389 org.exolab.castor.xml.ValidationException
391 Marshaller.marshal(this, handler);
396 public void removeAllMapListFrom()
398 this._mapListFromList.clear();
403 public void removeAllMapListTo()
405 this._mapListToList.clear();
409 * Method removeMapListFrom.
411 * @param vMapListFrom
412 * @return true if the object was removed from the collection.
414 public boolean removeMapListFrom(
415 final jalview.schemabinding.version2.MapListFrom vMapListFrom)
417 boolean removed = _mapListFromList.remove(vMapListFrom);
422 * Method removeMapListFromAt.
425 * @return the element removed from the collection
427 public jalview.schemabinding.version2.MapListFrom removeMapListFromAt(
430 java.lang.Object obj = this._mapListFromList.remove(index);
431 return (jalview.schemabinding.version2.MapListFrom) obj;
435 * Method removeMapListTo.
438 * @return true if the object was removed from the collection.
440 public boolean removeMapListTo(
441 final jalview.schemabinding.version2.MapListTo vMapListTo)
443 boolean removed = _mapListToList.remove(vMapListTo);
448 * Method removeMapListToAt.
451 * @return the element removed from the collection
453 public jalview.schemabinding.version2.MapListTo removeMapListToAt(
456 java.lang.Object obj = this._mapListToList.remove(index);
457 return (jalview.schemabinding.version2.MapListTo) obj;
461 * Sets the value of field 'mapFromUnit'. The field 'mapFromUnit' has the
462 * following description: number of dictionary symbol widths involved in each
463 * mapped position on this sequence (for example, 3 for a dna sequence exon
464 * region that is being mapped to a protein sequence). This is optional, since
465 * the unit can be usually be inferred from the dictionary type of each
466 * sequence involved in the mapping.
469 * the value of field 'mapFromUnit'.
471 public void setMapFromUnit(final long mapFromUnit)
473 this._mapFromUnit = mapFromUnit;
474 this._has_mapFromUnit = true;
481 * @param vMapListFrom
482 * @throws java.lang.IndexOutOfBoundsException
483 * if the index given is outside the bounds of the collection
485 public void setMapListFrom(final int index,
486 final jalview.schemabinding.version2.MapListFrom vMapListFrom)
487 throws java.lang.IndexOutOfBoundsException
489 // check bounds for index
490 if (index < 0 || index >= this._mapListFromList.size())
492 throw new IndexOutOfBoundsException("setMapListFrom: Index value '"
493 + index + "' not in range [0.."
494 + (this._mapListFromList.size() - 1) + "]");
497 this._mapListFromList.set(index, vMapListFrom);
503 * @param vMapListFromArray
505 public void setMapListFrom(
506 final jalview.schemabinding.version2.MapListFrom[] vMapListFromArray)
509 _mapListFromList.clear();
511 for (int i = 0; i < vMapListFromArray.length; i++)
513 this._mapListFromList.add(vMapListFromArray[i]);
522 * @throws java.lang.IndexOutOfBoundsException
523 * if the index given is outside the bounds of the collection
525 public void setMapListTo(final int index,
526 final jalview.schemabinding.version2.MapListTo vMapListTo)
527 throws java.lang.IndexOutOfBoundsException
529 // check bounds for index
530 if (index < 0 || index >= this._mapListToList.size())
532 throw new IndexOutOfBoundsException("setMapListTo: Index value '"
533 + index + "' not in range [0.."
534 + (this._mapListToList.size() - 1) + "]");
537 this._mapListToList.set(index, vMapListTo);
543 * @param vMapListToArray
545 public void setMapListTo(
546 final jalview.schemabinding.version2.MapListTo[] vMapListToArray)
549 _mapListToList.clear();
551 for (int i = 0; i < vMapListToArray.length; i++)
553 this._mapListToList.add(vMapListToArray[i]);
558 * Sets the value of field 'mapToUnit'. The field 'mapToUnit' has the
559 * following description: number of dictionary symbol widths involved in each
560 * mapped position on this sequence (for example, 3 for a dna sequence exon
561 * region that is being mapped to a protein sequence). This is optional, since
562 * the unit can be usually be inferred from the dictionary type of each
563 * sequence involved in the mapping.
566 * the value of field 'mapToUnit'.
568 public void setMapToUnit(final long mapToUnit)
570 this._mapToUnit = mapToUnit;
571 this._has_mapToUnit = true;
578 * @throws org.exolab.castor.xml.MarshalException
579 * if object is null or if any SAXException is thrown during
581 * @throws org.exolab.castor.xml.ValidationException
582 * if this object is an invalid instance according to the schema
583 * @return the unmarshaled jalview.schemabinding.version2.MapListType
585 public static jalview.schemabinding.version2.MapListType unmarshal(
586 final java.io.Reader reader)
587 throws org.exolab.castor.xml.MarshalException,
588 org.exolab.castor.xml.ValidationException
590 return (jalview.schemabinding.version2.MapListType) Unmarshaller
591 .unmarshal(jalview.schemabinding.version2.MapListType.class,
598 * @throws org.exolab.castor.xml.ValidationException
599 * if this object is an invalid instance according to the schema
601 public void validate() throws org.exolab.castor.xml.ValidationException
603 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
604 validator.validate(this);