2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
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 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/>.
17 * The Jalview Authors are detailed in the 'AUTHORS' file.
19 package jalview.schemabinding.version2;
21 //---------------------------------/
22 //- Imported classes and packages -/
23 //---------------------------------/
25 import org.exolab.castor.xml.Marshaller;
26 import org.exolab.castor.xml.Unmarshaller;
29 * developed after mapRangeType from
30 * http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes
32 * This effectively represents a java.util.MapList object
35 * @version $Revision$ $Date$
37 public class MapListType implements java.io.Serializable
40 // --------------------------/
41 // - Class/Member Variables -/
42 // --------------------------/
45 * number of dictionary symbol widths involved in each mapped position on this
46 * sequence (for example, 3 for a dna sequence exon region that is being
47 * mapped to a protein sequence). This is optional, since the unit can be
48 * usually be inferred from the dictionary type of each sequence involved in
51 private long _mapFromUnit;
54 * keeps track of state for field: _mapFromUnit
56 private boolean _has_mapFromUnit;
59 * number of dictionary symbol widths involved in each mapped position on this
60 * sequence (for example, 3 for a dna sequence exon region that is being
61 * mapped to a protein sequence). This is optional, since the unit can be
62 * usually be inferred from the dictionary type of each sequence involved in
65 private long _mapToUnit;
68 * keeps track of state for field: _mapToUnit
70 private boolean _has_mapToUnit;
73 * a region from start to end inclusive
75 private java.util.Vector _mapListFromList;
78 * a region from start to end inclusive
80 private java.util.Vector _mapListToList;
89 this._mapListFromList = new java.util.Vector();
90 this._mapListToList = new java.util.Vector();
100 * @param vMapListFrom
101 * @throws java.lang.IndexOutOfBoundsException
102 * if the index given is outside the bounds of the collection
104 public void addMapListFrom(
105 final jalview.schemabinding.version2.MapListFrom vMapListFrom)
106 throws java.lang.IndexOutOfBoundsException
108 this._mapListFromList.addElement(vMapListFrom);
115 * @param vMapListFrom
116 * @throws java.lang.IndexOutOfBoundsException
117 * if the index given is outside the bounds of the collection
119 public void addMapListFrom(final int index,
120 final jalview.schemabinding.version2.MapListFrom vMapListFrom)
121 throws java.lang.IndexOutOfBoundsException
123 this._mapListFromList.add(index, vMapListFrom);
130 * @throws java.lang.IndexOutOfBoundsException
131 * if the index given is outside the bounds of the collection
133 public void addMapListTo(
134 final jalview.schemabinding.version2.MapListTo vMapListTo)
135 throws java.lang.IndexOutOfBoundsException
137 this._mapListToList.addElement(vMapListTo);
145 * @throws java.lang.IndexOutOfBoundsException
146 * if the index given is outside the bounds of the collection
148 public void addMapListTo(final int index,
149 final jalview.schemabinding.version2.MapListTo vMapListTo)
150 throws java.lang.IndexOutOfBoundsException
152 this._mapListToList.add(index, vMapListTo);
157 public void deleteMapFromUnit()
159 this._has_mapFromUnit = false;
164 public void deleteMapToUnit()
166 this._has_mapToUnit = false;
170 * Method enumerateMapListFrom.
172 * @return an Enumeration over all jalview.schemabinding.version2.MapListFrom
175 public java.util.Enumeration enumerateMapListFrom()
177 return this._mapListFromList.elements();
181 * Method enumerateMapListTo.
183 * @return an Enumeration over all jalview.schemabinding.version2.MapListTo
186 public java.util.Enumeration enumerateMapListTo()
188 return this._mapListToList.elements();
192 * Returns the value of field 'mapFromUnit'. The field 'mapFromUnit' has the
193 * following description: number of dictionary symbol widths involved in each
194 * mapped position on this sequence (for example, 3 for a dna sequence exon
195 * region that is being mapped to a protein sequence). This is optional, since
196 * the unit can be usually be inferred from the dictionary type of each
197 * sequence involved in the mapping.
199 * @return the value of field 'MapFromUnit'.
201 public long getMapFromUnit()
203 return this._mapFromUnit;
207 * Method getMapListFrom.
210 * @throws java.lang.IndexOutOfBoundsException
211 * if the index given is outside the bounds of the collection
212 * @return the value of the jalview.schemabinding.version2.MapListFrom at the
215 public jalview.schemabinding.version2.MapListFrom getMapListFrom(
216 final int index) throws java.lang.IndexOutOfBoundsException
218 // check bounds for index
219 if (index < 0 || index >= this._mapListFromList.size())
221 throw new IndexOutOfBoundsException("getMapListFrom: Index value '"
222 + index + "' not in range [0.."
223 + (this._mapListFromList.size() - 1) + "]");
226 return (jalview.schemabinding.version2.MapListFrom) _mapListFromList
231 * Method getMapListFrom.Returns the contents of the collection in an Array.
233 * Note: Just in case the collection contents are changing in another thread,
234 * we pass a 0-length Array of the correct type into the API call. This way we
235 * <i>know</i> that the Array returned is of exactly the correct length.
237 * @return this collection as an Array
239 public jalview.schemabinding.version2.MapListFrom[] getMapListFrom()
241 jalview.schemabinding.version2.MapListFrom[] array = new jalview.schemabinding.version2.MapListFrom[0];
242 return (jalview.schemabinding.version2.MapListFrom[]) this._mapListFromList
247 * Method getMapListFromCount.
249 * @return the size of this collection
251 public int getMapListFromCount()
253 return this._mapListFromList.size();
257 * Method getMapListTo.
260 * @throws java.lang.IndexOutOfBoundsException
261 * if the index given is outside the bounds of the collection
262 * @return the value of the jalview.schemabinding.version2.MapListTo at the
265 public jalview.schemabinding.version2.MapListTo getMapListTo(
266 final int index) throws java.lang.IndexOutOfBoundsException
268 // check bounds for index
269 if (index < 0 || index >= this._mapListToList.size())
271 throw new IndexOutOfBoundsException("getMapListTo: Index value '"
272 + index + "' not in range [0.."
273 + (this._mapListToList.size() - 1) + "]");
276 return (jalview.schemabinding.version2.MapListTo) _mapListToList
281 * Method getMapListTo.Returns the contents of the collection in an Array.
283 * Note: Just in case the collection contents are changing in another thread,
284 * we pass a 0-length Array of the correct type into the API call. This way we
285 * <i>know</i> that the Array returned is of exactly the correct length.
287 * @return this collection as an Array
289 public jalview.schemabinding.version2.MapListTo[] getMapListTo()
291 jalview.schemabinding.version2.MapListTo[] array = new jalview.schemabinding.version2.MapListTo[0];
292 return (jalview.schemabinding.version2.MapListTo[]) this._mapListToList
297 * Method getMapListToCount.
299 * @return the size of this collection
301 public int getMapListToCount()
303 return this._mapListToList.size();
307 * Returns the value of field 'mapToUnit'. The field 'mapToUnit' has the
308 * following description: number of dictionary symbol widths involved in each
309 * mapped position on this sequence (for example, 3 for a dna sequence exon
310 * region that is being mapped to a protein sequence). This is optional, since
311 * the unit can be usually be inferred from the dictionary type of each
312 * sequence involved in the mapping.
314 * @return the value of field 'MapToUnit'.
316 public long getMapToUnit()
318 return this._mapToUnit;
322 * Method hasMapFromUnit.
324 * @return true if at least one MapFromUnit has been added
326 public boolean hasMapFromUnit()
328 return this._has_mapFromUnit;
332 * Method hasMapToUnit.
334 * @return true if at least one MapToUnit has been added
336 public boolean hasMapToUnit()
338 return this._has_mapToUnit;
344 * @return true if this object is valid according to the schema
346 public boolean isValid()
351 } catch (org.exolab.castor.xml.ValidationException vex)
362 * @throws org.exolab.castor.xml.MarshalException
363 * if object is null or if any SAXException is thrown during
365 * @throws org.exolab.castor.xml.ValidationException
366 * if this object is an invalid instance according to the schema
368 public void marshal(final java.io.Writer out)
369 throws org.exolab.castor.xml.MarshalException,
370 org.exolab.castor.xml.ValidationException
372 Marshaller.marshal(this, out);
379 * @throws java.io.IOException
380 * if an IOException occurs during marshaling
381 * @throws org.exolab.castor.xml.ValidationException
382 * if this object is an invalid instance according to the schema
383 * @throws org.exolab.castor.xml.MarshalException
384 * if object is null or if any SAXException is thrown during
387 public void marshal(final org.xml.sax.ContentHandler handler)
388 throws java.io.IOException,
389 org.exolab.castor.xml.MarshalException,
390 org.exolab.castor.xml.ValidationException
392 Marshaller.marshal(this, handler);
397 public void removeAllMapListFrom()
399 this._mapListFromList.clear();
404 public void removeAllMapListTo()
406 this._mapListToList.clear();
410 * Method removeMapListFrom.
412 * @param vMapListFrom
413 * @return true if the object was removed from the collection.
415 public boolean removeMapListFrom(
416 final jalview.schemabinding.version2.MapListFrom vMapListFrom)
418 boolean removed = _mapListFromList.remove(vMapListFrom);
423 * Method removeMapListFromAt.
426 * @return the element removed from the collection
428 public jalview.schemabinding.version2.MapListFrom removeMapListFromAt(
431 java.lang.Object obj = this._mapListFromList.remove(index);
432 return (jalview.schemabinding.version2.MapListFrom) obj;
436 * Method removeMapListTo.
439 * @return true if the object was removed from the collection.
441 public boolean removeMapListTo(
442 final jalview.schemabinding.version2.MapListTo vMapListTo)
444 boolean removed = _mapListToList.remove(vMapListTo);
449 * Method removeMapListToAt.
452 * @return the element removed from the collection
454 public jalview.schemabinding.version2.MapListTo removeMapListToAt(
457 java.lang.Object obj = this._mapListToList.remove(index);
458 return (jalview.schemabinding.version2.MapListTo) obj;
462 * Sets the value of field 'mapFromUnit'. The field 'mapFromUnit' has the
463 * following description: number of dictionary symbol widths involved in each
464 * mapped position on this sequence (for example, 3 for a dna sequence exon
465 * region that is being mapped to a protein sequence). This is optional, since
466 * the unit can be usually be inferred from the dictionary type of each
467 * sequence involved in the mapping.
470 * the value of field 'mapFromUnit'.
472 public void setMapFromUnit(final long mapFromUnit)
474 this._mapFromUnit = mapFromUnit;
475 this._has_mapFromUnit = true;
482 * @param vMapListFrom
483 * @throws java.lang.IndexOutOfBoundsException
484 * if the index given is outside the bounds of the collection
486 public void setMapListFrom(final int index,
487 final jalview.schemabinding.version2.MapListFrom vMapListFrom)
488 throws java.lang.IndexOutOfBoundsException
490 // check bounds for index
491 if (index < 0 || index >= this._mapListFromList.size())
493 throw new IndexOutOfBoundsException("setMapListFrom: Index value '"
494 + index + "' not in range [0.."
495 + (this._mapListFromList.size() - 1) + "]");
498 this._mapListFromList.set(index, vMapListFrom);
504 * @param vMapListFromArray
506 public void setMapListFrom(
507 final jalview.schemabinding.version2.MapListFrom[] vMapListFromArray)
510 _mapListFromList.clear();
512 for (int i = 0; i < vMapListFromArray.length; i++)
514 this._mapListFromList.add(vMapListFromArray[i]);
523 * @throws java.lang.IndexOutOfBoundsException
524 * if the index given is outside the bounds of the collection
526 public void setMapListTo(final int index,
527 final jalview.schemabinding.version2.MapListTo vMapListTo)
528 throws java.lang.IndexOutOfBoundsException
530 // check bounds for index
531 if (index < 0 || index >= this._mapListToList.size())
533 throw new IndexOutOfBoundsException("setMapListTo: Index value '"
534 + index + "' not in range [0.."
535 + (this._mapListToList.size() - 1) + "]");
538 this._mapListToList.set(index, vMapListTo);
544 * @param vMapListToArray
546 public void setMapListTo(
547 final jalview.schemabinding.version2.MapListTo[] vMapListToArray)
550 _mapListToList.clear();
552 for (int i = 0; i < vMapListToArray.length; i++)
554 this._mapListToList.add(vMapListToArray[i]);
559 * Sets the value of field 'mapToUnit'. The field 'mapToUnit' has the
560 * following description: number of dictionary symbol widths involved in each
561 * mapped position on this sequence (for example, 3 for a dna sequence exon
562 * region that is being mapped to a protein sequence). This is optional, since
563 * the unit can be usually be inferred from the dictionary type of each
564 * sequence involved in the mapping.
567 * the value of field 'mapToUnit'.
569 public void setMapToUnit(final long mapToUnit)
571 this._mapToUnit = mapToUnit;
572 this._has_mapToUnit = true;
579 * @throws org.exolab.castor.xml.MarshalException
580 * if object is null or if any SAXException is thrown during
582 * @throws org.exolab.castor.xml.ValidationException
583 * if this object is an invalid instance according to the schema
584 * @return the unmarshaled jalview.schemabinding.version2.MapListType
586 public static jalview.schemabinding.version2.MapListType unmarshal(
587 final java.io.Reader reader)
588 throws org.exolab.castor.xml.MarshalException,
589 org.exolab.castor.xml.ValidationException
591 return (jalview.schemabinding.version2.MapListType) Unmarshaller
592 .unmarshal(jalview.schemabinding.version2.MapListType.class,
599 * @throws org.exolab.castor.xml.ValidationException
600 * if this object is an invalid instance according to the schema
602 public void validate() throws org.exolab.castor.xml.ValidationException
604 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
605 validator.validate(this);