2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)
\r
3 * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
\r
5 * This program is free software; you can redistribute it and/or
\r
6 * modify it under the terms of the GNU General Public License
\r
7 * as published by the Free Software Foundation; either version 2
\r
8 * of the License, or (at your option) any later version.
\r
10 * This program is distributed in the hope that it will be useful,
\r
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 * GNU General Public License for more details.
\r
15 * You should have received a copy of the GNU General Public License
\r
16 * along with this program; if not, write to the Free Software
\r
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
\r
19 package jalview.schemabinding.version2;
\r
21 // ---------------------------------/
\r
22 // - Imported classes and packages -/
\r
23 // ---------------------------------/
\r
25 import org.exolab.castor.xml.Marshaller;
\r
26 import org.exolab.castor.xml.Unmarshaller;
\r
29 * developed after mapRangeType from
\r
30 * http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes
\r
32 * This effectively represents a java.util.MapList object
\r
35 * @version $Revision$ $Date$
\r
37 public class MapListType implements java.io.Serializable
\r
40 // --------------------------/
\r
41 // - Class/Member Variables -/
\r
42 // --------------------------/
\r
45 * number of dictionary symbol widths involved in each mapped position on this
\r
46 * sequence (for example, 3 for a dna sequence exon region that is being
\r
47 * mapped to a protein sequence). This is optional, since the unit can be
\r
48 * usually be inferred from the dictionary type of each sequence involved in
\r
51 private long _mapFromUnit;
\r
54 * keeps track of state for field: _mapFromUnit
\r
56 private boolean _has_mapFromUnit;
\r
59 * number of dictionary symbol widths involved in each mapped position on this
\r
60 * sequence (for example, 3 for a dna sequence exon region that is being
\r
61 * mapped to a protein sequence). This is optional, since the unit can be
\r
62 * usually be inferred from the dictionary type of each sequence involved in
\r
65 private long _mapToUnit;
\r
68 * keeps track of state for field: _mapToUnit
\r
70 private boolean _has_mapToUnit;
\r
73 * a region from start to end inclusive
\r
75 private java.util.Vector _mapListFromList;
\r
78 * a region from start to end inclusive
\r
80 private java.util.Vector _mapListToList;
\r
82 // ----------------/
\r
83 // - Constructors -/
\r
84 // ----------------/
\r
86 public MapListType()
\r
89 this._mapListFromList = new java.util.Vector();
\r
90 this._mapListToList = new java.util.Vector();
\r
100 * @param vMapListFrom
\r
101 * @throws java.lang.IndexOutOfBoundsException
\r
102 * if the index given is outside the bounds of the collection
\r
104 public void addMapListFrom(
\r
105 final jalview.schemabinding.version2.MapListFrom vMapListFrom)
\r
106 throws java.lang.IndexOutOfBoundsException
\r
108 this._mapListFromList.addElement(vMapListFrom);
\r
115 * @param vMapListFrom
\r
116 * @throws java.lang.IndexOutOfBoundsException
\r
117 * if the index given is outside the bounds of the collection
\r
119 public void addMapListFrom(final int index,
\r
120 final jalview.schemabinding.version2.MapListFrom vMapListFrom)
\r
121 throws java.lang.IndexOutOfBoundsException
\r
123 this._mapListFromList.add(index, vMapListFrom);
\r
129 * @param vMapListTo
\r
130 * @throws java.lang.IndexOutOfBoundsException
\r
131 * if the index given is outside the bounds of the collection
\r
133 public void addMapListTo(
\r
134 final jalview.schemabinding.version2.MapListTo vMapListTo)
\r
135 throws java.lang.IndexOutOfBoundsException
\r
137 this._mapListToList.addElement(vMapListTo);
\r
144 * @param vMapListTo
\r
145 * @throws java.lang.IndexOutOfBoundsException
\r
146 * if the index given is outside the bounds of the collection
\r
148 public void addMapListTo(final int index,
\r
149 final jalview.schemabinding.version2.MapListTo vMapListTo)
\r
150 throws java.lang.IndexOutOfBoundsException
\r
152 this._mapListToList.add(index, vMapListTo);
\r
157 public void deleteMapFromUnit()
\r
159 this._has_mapFromUnit = false;
\r
164 public void deleteMapToUnit()
\r
166 this._has_mapToUnit = false;
\r
170 * Method enumerateMapListFrom.
\r
172 * @return an Enumeration over all jalview.schemabinding.version2.MapListFrom
\r
175 public java.util.Enumeration enumerateMapListFrom()
\r
177 return this._mapListFromList.elements();
\r
181 * Method enumerateMapListTo.
\r
183 * @return an Enumeration over all jalview.schemabinding.version2.MapListTo
\r
186 public java.util.Enumeration enumerateMapListTo()
\r
188 return this._mapListToList.elements();
\r
192 * Returns the value of field 'mapFromUnit'. The field 'mapFromUnit' has the
\r
193 * following description: number of dictionary symbol widths involved in each
\r
194 * mapped position on this sequence (for example, 3 for a dna sequence exon
\r
195 * region that is being mapped to a protein sequence). This is optional, since
\r
196 * the unit can be usually be inferred from the dictionary type of each
\r
197 * sequence involved in the mapping.
\r
199 * @return the value of field 'MapFromUnit'.
\r
201 public long getMapFromUnit()
\r
203 return this._mapFromUnit;
\r
207 * Method getMapListFrom.
\r
210 * @throws java.lang.IndexOutOfBoundsException
\r
211 * if the index given is outside the bounds of the collection
\r
212 * @return the value of the jalview.schemabinding.version2.MapListFrom at the
\r
215 public jalview.schemabinding.version2.MapListFrom getMapListFrom(
\r
216 final int index) throws java.lang.IndexOutOfBoundsException
\r
218 // check bounds for index
\r
219 if (index < 0 || index >= this._mapListFromList.size())
\r
221 throw new IndexOutOfBoundsException("getMapListFrom: Index value '"
\r
222 + index + "' not in range [0.."
\r
223 + (this._mapListFromList.size() - 1) + "]");
\r
226 return (jalview.schemabinding.version2.MapListFrom) _mapListFromList
\r
231 * Method getMapListFrom.Returns the contents of the collection in an Array.
\r
233 * Note: Just in case the collection contents are changing in another thread,
\r
234 * we pass a 0-length Array of the correct type into the API call. This way we
\r
235 * <i>know</i> that the Array returned is of exactly the correct length.
\r
237 * @return this collection as an Array
\r
239 public jalview.schemabinding.version2.MapListFrom[] getMapListFrom()
\r
241 jalview.schemabinding.version2.MapListFrom[] array = new jalview.schemabinding.version2.MapListFrom[0];
\r
242 return (jalview.schemabinding.version2.MapListFrom[]) this._mapListFromList
\r
247 * Method getMapListFromCount.
\r
249 * @return the size of this collection
\r
251 public int getMapListFromCount()
\r
253 return this._mapListFromList.size();
\r
257 * Method getMapListTo.
\r
260 * @throws java.lang.IndexOutOfBoundsException
\r
261 * if the index given is outside the bounds of the collection
\r
262 * @return the value of the jalview.schemabinding.version2.MapListTo at the
\r
265 public jalview.schemabinding.version2.MapListTo getMapListTo(
\r
266 final int index) throws java.lang.IndexOutOfBoundsException
\r
268 // check bounds for index
\r
269 if (index < 0 || index >= this._mapListToList.size())
\r
271 throw new IndexOutOfBoundsException("getMapListTo: Index value '"
\r
272 + index + "' not in range [0.."
\r
273 + (this._mapListToList.size() - 1) + "]");
\r
276 return (jalview.schemabinding.version2.MapListTo) _mapListToList
\r
281 * Method getMapListTo.Returns the contents of the collection in an Array.
\r
283 * Note: Just in case the collection contents are changing in another thread,
\r
284 * we pass a 0-length Array of the correct type into the API call. This way we
\r
285 * <i>know</i> that the Array returned is of exactly the correct length.
\r
287 * @return this collection as an Array
\r
289 public jalview.schemabinding.version2.MapListTo[] getMapListTo()
\r
291 jalview.schemabinding.version2.MapListTo[] array = new jalview.schemabinding.version2.MapListTo[0];
\r
292 return (jalview.schemabinding.version2.MapListTo[]) this._mapListToList
\r
297 * Method getMapListToCount.
\r
299 * @return the size of this collection
\r
301 public int getMapListToCount()
\r
303 return this._mapListToList.size();
\r
307 * Returns the value of field 'mapToUnit'. The field 'mapToUnit' has the
\r
308 * following description: number of dictionary symbol widths involved in each
\r
309 * mapped position on this sequence (for example, 3 for a dna sequence exon
\r
310 * region that is being mapped to a protein sequence). This is optional, since
\r
311 * the unit can be usually be inferred from the dictionary type of each
\r
312 * sequence involved in the mapping.
\r
314 * @return the value of field 'MapToUnit'.
\r
316 public long getMapToUnit()
\r
318 return this._mapToUnit;
\r
322 * Method hasMapFromUnit.
\r
324 * @return true if at least one MapFromUnit has been added
\r
326 public boolean hasMapFromUnit()
\r
328 return this._has_mapFromUnit;
\r
332 * Method hasMapToUnit.
\r
334 * @return true if at least one MapToUnit has been added
\r
336 public boolean hasMapToUnit()
\r
338 return this._has_mapToUnit;
\r
344 * @return true if this object is valid according to the schema
\r
346 public boolean isValid()
\r
351 } catch (org.exolab.castor.xml.ValidationException vex)
\r
362 * @throws org.exolab.castor.xml.MarshalException
\r
363 * if object is null or if any SAXException is thrown during
\r
365 * @throws org.exolab.castor.xml.ValidationException
\r
366 * if this object is an invalid instance according to the
\r
369 public void marshal(final java.io.Writer out)
\r
370 throws org.exolab.castor.xml.MarshalException,
\r
371 org.exolab.castor.xml.ValidationException
\r
373 Marshaller.marshal(this, out);
\r
380 * @throws java.io.IOException
\r
381 * if an IOException occurs during marshaling
\r
382 * @throws org.exolab.castor.xml.ValidationException
\r
383 * if this object is an invalid instance according to the
\r
385 * @throws org.exolab.castor.xml.MarshalException
\r
386 * if object is null or if any SAXException is thrown during
\r
389 public void marshal(final org.xml.sax.ContentHandler handler)
\r
390 throws java.io.IOException,
\r
391 org.exolab.castor.xml.MarshalException,
\r
392 org.exolab.castor.xml.ValidationException
\r
394 Marshaller.marshal(this, handler);
\r
399 public void removeAllMapListFrom()
\r
401 this._mapListFromList.clear();
\r
406 public void removeAllMapListTo()
\r
408 this._mapListToList.clear();
\r
412 * Method removeMapListFrom.
\r
414 * @param vMapListFrom
\r
415 * @return true if the object was removed from the collection.
\r
417 public boolean removeMapListFrom(
\r
418 final jalview.schemabinding.version2.MapListFrom vMapListFrom)
\r
420 boolean removed = _mapListFromList.remove(vMapListFrom);
\r
425 * Method removeMapListFromAt.
\r
428 * @return the element removed from the collection
\r
430 public jalview.schemabinding.version2.MapListFrom removeMapListFromAt(
\r
433 java.lang.Object obj = this._mapListFromList.remove(index);
\r
434 return (jalview.schemabinding.version2.MapListFrom) obj;
\r
438 * Method removeMapListTo.
\r
440 * @param vMapListTo
\r
441 * @return true if the object was removed from the collection.
\r
443 public boolean removeMapListTo(
\r
444 final jalview.schemabinding.version2.MapListTo vMapListTo)
\r
446 boolean removed = _mapListToList.remove(vMapListTo);
\r
451 * Method removeMapListToAt.
\r
454 * @return the element removed from the collection
\r
456 public jalview.schemabinding.version2.MapListTo removeMapListToAt(
\r
459 java.lang.Object obj = this._mapListToList.remove(index);
\r
460 return (jalview.schemabinding.version2.MapListTo) obj;
\r
464 * Sets the value of field 'mapFromUnit'. The field 'mapFromUnit' has the
\r
465 * following description: number of dictionary symbol widths involved in each
\r
466 * mapped position on this sequence (for example, 3 for a dna sequence exon
\r
467 * region that is being mapped to a protein sequence). This is optional, since
\r
468 * the unit can be usually be inferred from the dictionary type of each
\r
469 * sequence involved in the mapping.
\r
471 * @param mapFromUnit
\r
472 * the value of field 'mapFromUnit'.
\r
474 public void setMapFromUnit(final long mapFromUnit)
\r
476 this._mapFromUnit = mapFromUnit;
\r
477 this._has_mapFromUnit = true;
\r
484 * @param vMapListFrom
\r
485 * @throws java.lang.IndexOutOfBoundsException
\r
486 * if the index given is outside the bounds of the collection
\r
488 public void setMapListFrom(final int index,
\r
489 final jalview.schemabinding.version2.MapListFrom vMapListFrom)
\r
490 throws java.lang.IndexOutOfBoundsException
\r
492 // check bounds for index
\r
493 if (index < 0 || index >= this._mapListFromList.size())
\r
495 throw new IndexOutOfBoundsException("setMapListFrom: Index value '"
\r
496 + index + "' not in range [0.."
\r
497 + (this._mapListFromList.size() - 1) + "]");
\r
500 this._mapListFromList.set(index, vMapListFrom);
\r
506 * @param vMapListFromArray
\r
508 public void setMapListFrom(
\r
509 final jalview.schemabinding.version2.MapListFrom[] vMapListFromArray)
\r
512 _mapListFromList.clear();
\r
514 for (int i = 0; i < vMapListFromArray.length; i++)
\r
516 this._mapListFromList.add(vMapListFromArray[i]);
\r
524 * @param vMapListTo
\r
525 * @throws java.lang.IndexOutOfBoundsException
\r
526 * if the index given is outside the bounds of the collection
\r
528 public void setMapListTo(final int index,
\r
529 final jalview.schemabinding.version2.MapListTo vMapListTo)
\r
530 throws java.lang.IndexOutOfBoundsException
\r
532 // check bounds for index
\r
533 if (index < 0 || index >= this._mapListToList.size())
\r
535 throw new IndexOutOfBoundsException("setMapListTo: Index value '"
\r
536 + index + "' not in range [0.."
\r
537 + (this._mapListToList.size() - 1) + "]");
\r
540 this._mapListToList.set(index, vMapListTo);
\r
546 * @param vMapListToArray
\r
548 public void setMapListTo(
\r
549 final jalview.schemabinding.version2.MapListTo[] vMapListToArray)
\r
552 _mapListToList.clear();
\r
554 for (int i = 0; i < vMapListToArray.length; i++)
\r
556 this._mapListToList.add(vMapListToArray[i]);
\r
561 * Sets the value of field 'mapToUnit'. The field 'mapToUnit' has the
\r
562 * following description: number of dictionary symbol widths involved in each
\r
563 * mapped position on this sequence (for example, 3 for a dna sequence exon
\r
564 * region that is being mapped to a protein sequence). This is optional, since
\r
565 * the unit can be usually be inferred from the dictionary type of each
\r
566 * sequence involved in the mapping.
\r
569 * the value of field 'mapToUnit'.
\r
571 public void setMapToUnit(final long mapToUnit)
\r
573 this._mapToUnit = mapToUnit;
\r
574 this._has_mapToUnit = true;
\r
578 * Method unmarshal.
\r
581 * @throws org.exolab.castor.xml.MarshalException
\r
582 * if object is null or if any SAXException is thrown during
\r
584 * @throws org.exolab.castor.xml.ValidationException
\r
585 * if this object is an invalid instance according to the
\r
587 * @return the unmarshaled jalview.schemabinding.version2.MapListType
\r
589 public static jalview.schemabinding.version2.MapListType unmarshal(
\r
590 final java.io.Reader reader)
\r
591 throws org.exolab.castor.xml.MarshalException,
\r
592 org.exolab.castor.xml.ValidationException
\r
594 return (jalview.schemabinding.version2.MapListType) Unmarshaller
\r
595 .unmarshal(jalview.schemabinding.version2.MapListType.class,
\r
602 * @throws org.exolab.castor.xml.ValidationException
\r
603 * if this object is an invalid instance according to the
\r
606 public void validate() throws org.exolab.castor.xml.ValidationException
\r
608 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
\r
609 validator.validate(this);
\r