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 jalview.util.MessageManager;
29 import org.exolab.castor.xml.Marshaller;
30 import org.exolab.castor.xml.Unmarshaller;
33 * developed after mapRangeType from
34 * http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes
36 * This effectively represents a java.util.MapList object
39 * @version $Revision$ $Date$
41 public class MapListType implements java.io.Serializable
44 // --------------------------/
45 // - Class/Member Variables -/
46 // --------------------------/
49 * number of dictionary symbol widths involved in each mapped position on this
50 * sequence (for example, 3 for a dna sequence exon region that is being
51 * mapped to a protein sequence). This is optional, since the unit can be
52 * usually be inferred from the dictionary type of each sequence involved in
55 private long _mapFromUnit;
58 * keeps track of state for field: _mapFromUnit
60 private boolean _has_mapFromUnit;
63 * number of dictionary symbol widths involved in each mapped position on this
64 * sequence (for example, 3 for a dna sequence exon region that is being
65 * mapped to a protein sequence). This is optional, since the unit can be
66 * usually be inferred from the dictionary type of each sequence involved in
69 private long _mapToUnit;
72 * keeps track of state for field: _mapToUnit
74 private boolean _has_mapToUnit;
77 * a region from start to end inclusive
79 private java.util.Vector _mapListFromList;
82 * a region from start to end inclusive
84 private java.util.Vector _mapListToList;
93 this._mapListFromList = new java.util.Vector();
94 this._mapListToList = new java.util.Vector();
104 * @param vMapListFrom
105 * @throws java.lang.IndexOutOfBoundsException
106 * if the index given is outside the bounds of the collection
108 public void addMapListFrom(
109 final jalview.schemabinding.version2.MapListFrom vMapListFrom)
110 throws java.lang.IndexOutOfBoundsException
112 this._mapListFromList.addElement(vMapListFrom);
119 * @param vMapListFrom
120 * @throws java.lang.IndexOutOfBoundsException
121 * if the index given is outside the bounds of the collection
123 public void addMapListFrom(final int index,
124 final jalview.schemabinding.version2.MapListFrom vMapListFrom)
125 throws java.lang.IndexOutOfBoundsException
127 this._mapListFromList.add(index, vMapListFrom);
134 * @throws java.lang.IndexOutOfBoundsException
135 * if the index given is outside the bounds of the collection
137 public void addMapListTo(
138 final jalview.schemabinding.version2.MapListTo vMapListTo)
139 throws java.lang.IndexOutOfBoundsException
141 this._mapListToList.addElement(vMapListTo);
149 * @throws java.lang.IndexOutOfBoundsException
150 * if the index given is outside the bounds of the collection
152 public void addMapListTo(final int index,
153 final jalview.schemabinding.version2.MapListTo vMapListTo)
154 throws java.lang.IndexOutOfBoundsException
156 this._mapListToList.add(index, vMapListTo);
161 public void deleteMapFromUnit()
163 this._has_mapFromUnit = false;
168 public void deleteMapToUnit()
170 this._has_mapToUnit = false;
174 * Method enumerateMapListFrom.
176 * @return an Enumeration over all jalview.schemabinding.version2.MapListFrom
179 public java.util.Enumeration enumerateMapListFrom()
181 return this._mapListFromList.elements();
185 * Method enumerateMapListTo.
187 * @return an Enumeration over all jalview.schemabinding.version2.MapListTo
190 public java.util.Enumeration enumerateMapListTo()
192 return this._mapListToList.elements();
196 * Returns the value of field 'mapFromUnit'. The field 'mapFromUnit' has the
197 * following description: number of dictionary symbol widths involved in each
198 * mapped position on this sequence (for example, 3 for a dna sequence exon
199 * region that is being mapped to a protein sequence). This is optional, since
200 * the unit can be usually be inferred from the dictionary type of each
201 * sequence involved in the mapping.
203 * @return the value of field 'MapFromUnit'.
205 public long getMapFromUnit()
207 return this._mapFromUnit;
211 * Method getMapListFrom.
214 * @throws java.lang.IndexOutOfBoundsException
215 * if the index given is outside the bounds of the collection
216 * @return the value of the jalview.schemabinding.version2.MapListFrom at the
219 public jalview.schemabinding.version2.MapListFrom getMapListFrom(
220 final int index) throws java.lang.IndexOutOfBoundsException
222 // check bounds for index
223 if (index < 0 || index >= this._mapListFromList.size())
225 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
227 Integer.valueOf(index).toString(),
228 Integer.valueOf((this._mapListFromList.size() - 1)).toString()
232 return (jalview.schemabinding.version2.MapListFrom) _mapListFromList
237 * Method getMapListFrom.Returns the contents of the collection in an Array.
239 * Note: Just in case the collection contents are changing in another thread,
240 * we pass a 0-length Array of the correct type into the API call. This way we
241 * <i>know</i> that the Array returned is of exactly the correct length.
243 * @return this collection as an Array
245 public jalview.schemabinding.version2.MapListFrom[] getMapListFrom()
247 jalview.schemabinding.version2.MapListFrom[] array = new jalview.schemabinding.version2.MapListFrom[0];
248 return (jalview.schemabinding.version2.MapListFrom[]) this._mapListFromList
253 * Method getMapListFromCount.
255 * @return the size of this collection
257 public int getMapListFromCount()
259 return this._mapListFromList.size();
263 * Method getMapListTo.
266 * @throws java.lang.IndexOutOfBoundsException
267 * if the index given is outside the bounds of the collection
268 * @return the value of the jalview.schemabinding.version2.MapListTo at the
271 public jalview.schemabinding.version2.MapListTo getMapListTo(
272 final int index) throws java.lang.IndexOutOfBoundsException
274 // check bounds for index
275 if (index < 0 || index >= this._mapListToList.size())
277 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
279 Integer.valueOf(index).toString(),
280 Integer.valueOf((this._mapListToList.size() - 1)).toString()
284 return (jalview.schemabinding.version2.MapListTo) _mapListToList
289 * Method getMapListTo.Returns the contents of the collection in an Array.
291 * Note: Just in case the collection contents are changing in another thread,
292 * we pass a 0-length Array of the correct type into the API call. This way we
293 * <i>know</i> that the Array returned is of exactly the correct length.
295 * @return this collection as an Array
297 public jalview.schemabinding.version2.MapListTo[] getMapListTo()
299 jalview.schemabinding.version2.MapListTo[] array = new jalview.schemabinding.version2.MapListTo[0];
300 return (jalview.schemabinding.version2.MapListTo[]) this._mapListToList
305 * Method getMapListToCount.
307 * @return the size of this collection
309 public int getMapListToCount()
311 return this._mapListToList.size();
315 * Returns the value of field 'mapToUnit'. The field 'mapToUnit' has the
316 * following description: number of dictionary symbol widths involved in each
317 * mapped position on this sequence (for example, 3 for a dna sequence exon
318 * region that is being mapped to a protein sequence). This is optional, since
319 * the unit can be usually be inferred from the dictionary type of each
320 * sequence involved in the mapping.
322 * @return the value of field 'MapToUnit'.
324 public long getMapToUnit()
326 return this._mapToUnit;
330 * Method hasMapFromUnit.
332 * @return true if at least one MapFromUnit has been added
334 public boolean hasMapFromUnit()
336 return this._has_mapFromUnit;
340 * Method hasMapToUnit.
342 * @return true if at least one MapToUnit has been added
344 public boolean hasMapToUnit()
346 return this._has_mapToUnit;
352 * @return true if this object is valid according to the schema
354 public boolean isValid()
359 } catch (org.exolab.castor.xml.ValidationException vex)
370 * @throws org.exolab.castor.xml.MarshalException
371 * if object is null or if any SAXException is thrown during
373 * @throws org.exolab.castor.xml.ValidationException
374 * if this object is an invalid instance according to the schema
376 public void marshal(final java.io.Writer out)
377 throws org.exolab.castor.xml.MarshalException,
378 org.exolab.castor.xml.ValidationException
380 Marshaller.marshal(this, out);
387 * @throws java.io.IOException
388 * if an IOException occurs during marshaling
389 * @throws org.exolab.castor.xml.ValidationException
390 * if this object is an invalid instance according to the schema
391 * @throws org.exolab.castor.xml.MarshalException
392 * if object is null or if any SAXException is thrown during
395 public void marshal(final org.xml.sax.ContentHandler handler)
396 throws java.io.IOException,
397 org.exolab.castor.xml.MarshalException,
398 org.exolab.castor.xml.ValidationException
400 Marshaller.marshal(this, handler);
405 public void removeAllMapListFrom()
407 this._mapListFromList.clear();
412 public void removeAllMapListTo()
414 this._mapListToList.clear();
418 * Method removeMapListFrom.
420 * @param vMapListFrom
421 * @return true if the object was removed from the collection.
423 public boolean removeMapListFrom(
424 final jalview.schemabinding.version2.MapListFrom vMapListFrom)
426 boolean removed = _mapListFromList.remove(vMapListFrom);
431 * Method removeMapListFromAt.
434 * @return the element removed from the collection
436 public jalview.schemabinding.version2.MapListFrom removeMapListFromAt(
439 java.lang.Object obj = this._mapListFromList.remove(index);
440 return (jalview.schemabinding.version2.MapListFrom) obj;
444 * Method removeMapListTo.
447 * @return true if the object was removed from the collection.
449 public boolean removeMapListTo(
450 final jalview.schemabinding.version2.MapListTo vMapListTo)
452 boolean removed = _mapListToList.remove(vMapListTo);
457 * Method removeMapListToAt.
460 * @return the element removed from the collection
462 public jalview.schemabinding.version2.MapListTo removeMapListToAt(
465 java.lang.Object obj = this._mapListToList.remove(index);
466 return (jalview.schemabinding.version2.MapListTo) obj;
470 * Sets the value of field 'mapFromUnit'. The field 'mapFromUnit' has the
471 * following description: number of dictionary symbol widths involved in each
472 * mapped position on this sequence (for example, 3 for a dna sequence exon
473 * region that is being mapped to a protein sequence). This is optional, since
474 * the unit can be usually be inferred from the dictionary type of each
475 * sequence involved in the mapping.
478 * the value of field 'mapFromUnit'.
480 public void setMapFromUnit(final long mapFromUnit)
482 this._mapFromUnit = mapFromUnit;
483 this._has_mapFromUnit = true;
490 * @param vMapListFrom
491 * @throws java.lang.IndexOutOfBoundsException
492 * if the index given is outside the bounds of the collection
494 public void setMapListFrom(final int index,
495 final jalview.schemabinding.version2.MapListFrom vMapListFrom)
496 throws java.lang.IndexOutOfBoundsException
498 // check bounds for index
499 if (index < 0 || index >= this._mapListFromList.size())
501 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
503 Integer.valueOf(index).toString(),
504 Integer.valueOf((this._mapListFromList.size() - 1)).toString()
508 this._mapListFromList.set(index, vMapListFrom);
514 * @param vMapListFromArray
516 public void setMapListFrom(
517 final jalview.schemabinding.version2.MapListFrom[] vMapListFromArray)
520 _mapListFromList.clear();
522 for (int i = 0; i < vMapListFromArray.length; i++)
524 this._mapListFromList.add(vMapListFromArray[i]);
533 * @throws java.lang.IndexOutOfBoundsException
534 * if the index given is outside the bounds of the collection
536 public void setMapListTo(final int index,
537 final jalview.schemabinding.version2.MapListTo vMapListTo)
538 throws java.lang.IndexOutOfBoundsException
540 // check bounds for index
541 if (index < 0 || index >= this._mapListToList.size())
543 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
545 Integer.valueOf(index).toString(),
546 Integer.valueOf((this._mapListToList.size() - 1)).toString()
550 this._mapListToList.set(index, vMapListTo);
556 * @param vMapListToArray
558 public void setMapListTo(
559 final jalview.schemabinding.version2.MapListTo[] vMapListToArray)
562 _mapListToList.clear();
564 for (int i = 0; i < vMapListToArray.length; i++)
566 this._mapListToList.add(vMapListToArray[i]);
571 * Sets the value of field 'mapToUnit'. The field 'mapToUnit' has the
572 * following description: number of dictionary symbol widths involved in each
573 * mapped position on this sequence (for example, 3 for a dna sequence exon
574 * region that is being mapped to a protein sequence). This is optional, since
575 * the unit can be usually be inferred from the dictionary type of each
576 * sequence involved in the mapping.
579 * the value of field 'mapToUnit'.
581 public void setMapToUnit(final long mapToUnit)
583 this._mapToUnit = mapToUnit;
584 this._has_mapToUnit = true;
591 * @throws org.exolab.castor.xml.MarshalException
592 * if object is null or if any SAXException is thrown during
594 * @throws org.exolab.castor.xml.ValidationException
595 * if this object is an invalid instance according to the schema
596 * @return the unmarshaled jalview.schemabinding.version2.MapListType
598 public static jalview.schemabinding.version2.MapListType unmarshal(
599 final java.io.Reader reader)
600 throws org.exolab.castor.xml.MarshalException,
601 org.exolab.castor.xml.ValidationException
603 return (jalview.schemabinding.version2.MapListType) Unmarshaller
604 .unmarshal(jalview.schemabinding.version2.MapListType.class,
611 * @throws org.exolab.castor.xml.ValidationException
612 * if this object is an invalid instance according to the schema
614 public void validate() throws org.exolab.castor.xml.ValidationException
616 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
617 validator.validate(this);