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