2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4.0.b2)
\r
3 * Copyright (C) 2009 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 * Class SequenceSet.
\r
31 * @version $Revision$ $Date$
\r
33 public class SequenceSet implements java.io.Serializable
\r
36 // --------------------------/
\r
37 // - Class/Member Variables -/
\r
38 // --------------------------/
\r
43 private java.lang.String _gapChar;
\r
46 * reference to set where jalview will gather the dataset sequences for all
\r
47 * sequences in the set.
\r
50 private java.lang.String _datasetId;
\r
53 * Field _sequenceList.
\r
55 private java.util.Vector _sequenceList;
\r
58 * Field _annotationList.
\r
60 private java.util.Vector _annotationList;
\r
63 * Field _sequenceSetPropertiesList.
\r
65 private java.util.Vector _sequenceSetPropertiesList;
\r
68 * Field _alcodonFrameList.
\r
70 private java.util.Vector _alcodonFrameList;
\r
72 // ----------------/
\r
73 // - Constructors -/
\r
74 // ----------------/
\r
76 public SequenceSet()
\r
79 this._sequenceList = new java.util.Vector();
\r
80 this._annotationList = new java.util.Vector();
\r
81 this._sequenceSetPropertiesList = new java.util.Vector();
\r
82 this._alcodonFrameList = new java.util.Vector();
\r
92 * @param vAlcodonFrame
\r
93 * @throws java.lang.IndexOutOfBoundsException
\r
94 * if the index given is outside the bounds of the collection
\r
96 public void addAlcodonFrame(
\r
97 final jalview.schemabinding.version2.AlcodonFrame vAlcodonFrame)
\r
98 throws java.lang.IndexOutOfBoundsException
\r
100 this._alcodonFrameList.addElement(vAlcodonFrame);
\r
107 * @param vAlcodonFrame
\r
108 * @throws java.lang.IndexOutOfBoundsException
\r
109 * if the index given is outside the bounds of the collection
\r
111 public void addAlcodonFrame(final int index,
\r
112 final jalview.schemabinding.version2.AlcodonFrame vAlcodonFrame)
\r
113 throws java.lang.IndexOutOfBoundsException
\r
115 this._alcodonFrameList.add(index, vAlcodonFrame);
\r
121 * @param vAnnotation
\r
122 * @throws java.lang.IndexOutOfBoundsException
\r
123 * if the index given is outside the bounds of the collection
\r
125 public void addAnnotation(
\r
126 final jalview.schemabinding.version2.Annotation vAnnotation)
\r
127 throws java.lang.IndexOutOfBoundsException
\r
129 this._annotationList.addElement(vAnnotation);
\r
136 * @param vAnnotation
\r
137 * @throws java.lang.IndexOutOfBoundsException
\r
138 * if the index given is outside the bounds of the collection
\r
140 public void addAnnotation(final int index,
\r
141 final jalview.schemabinding.version2.Annotation vAnnotation)
\r
142 throws java.lang.IndexOutOfBoundsException
\r
144 this._annotationList.add(index, vAnnotation);
\r
151 * @throws java.lang.IndexOutOfBoundsException
\r
152 * if the index given is outside the bounds of the collection
\r
154 public void addSequence(
\r
155 final jalview.schemabinding.version2.Sequence vSequence)
\r
156 throws java.lang.IndexOutOfBoundsException
\r
158 this._sequenceList.addElement(vSequence);
\r
166 * @throws java.lang.IndexOutOfBoundsException
\r
167 * if the index given is outside the bounds of the collection
\r
169 public void addSequence(final int index,
\r
170 final jalview.schemabinding.version2.Sequence vSequence)
\r
171 throws java.lang.IndexOutOfBoundsException
\r
173 this._sequenceList.add(index, vSequence);
\r
179 * @param vSequenceSetProperties
\r
180 * @throws java.lang.IndexOutOfBoundsException
\r
181 * if the index given is outside the bounds of the collection
\r
183 public void addSequenceSetProperties(
\r
184 final jalview.schemabinding.version2.SequenceSetProperties vSequenceSetProperties)
\r
185 throws java.lang.IndexOutOfBoundsException
\r
187 this._sequenceSetPropertiesList.addElement(vSequenceSetProperties);
\r
194 * @param vSequenceSetProperties
\r
195 * @throws java.lang.IndexOutOfBoundsException
\r
196 * if the index given is outside the bounds of the collection
\r
198 public void addSequenceSetProperties(
\r
200 final jalview.schemabinding.version2.SequenceSetProperties vSequenceSetProperties)
\r
201 throws java.lang.IndexOutOfBoundsException
\r
203 this._sequenceSetPropertiesList.add(index, vSequenceSetProperties);
\r
207 * Method enumerateAlcodonFrame.
\r
209 * @return an Enumeration over all jalview.schemabinding.version2.AlcodonFrame
\r
212 public java.util.Enumeration enumerateAlcodonFrame()
\r
214 return this._alcodonFrameList.elements();
\r
218 * Method enumerateAnnotation.
\r
220 * @return an Enumeration over all jalview.schemabinding.version2.Annotation
\r
223 public java.util.Enumeration enumerateAnnotation()
\r
225 return this._annotationList.elements();
\r
229 * Method enumerateSequence.
\r
231 * @return an Enumeration over all jalview.schemabinding.version2.Sequence
\r
234 public java.util.Enumeration enumerateSequence()
\r
236 return this._sequenceList.elements();
\r
240 * Method enumerateSequenceSetProperties.
\r
242 * @return an Enumeration over all
\r
243 * jalview.schemabinding.version2.SequenceSetProperties elements
\r
245 public java.util.Enumeration enumerateSequenceSetProperties()
\r
247 return this._sequenceSetPropertiesList.elements();
\r
251 * Method getAlcodonFrame.
\r
254 * @throws java.lang.IndexOutOfBoundsException
\r
255 * if the index given is outside the bounds of the collection
\r
256 * @return the value of the jalview.schemabinding.version2.AlcodonFrame at the
\r
259 public jalview.schemabinding.version2.AlcodonFrame getAlcodonFrame(
\r
260 final int index) throws java.lang.IndexOutOfBoundsException
\r
262 // check bounds for index
\r
263 if (index < 0 || index >= this._alcodonFrameList.size())
\r
265 throw new IndexOutOfBoundsException("getAlcodonFrame: Index value '"
\r
266 + index + "' not in range [0.."
\r
267 + (this._alcodonFrameList.size() - 1) + "]");
\r
270 return (jalview.schemabinding.version2.AlcodonFrame) _alcodonFrameList
\r
275 * Method getAlcodonFrame.Returns the contents of the collection in an Array.
\r
277 * Note: Just in case the collection contents are changing in another thread,
\r
278 * we pass a 0-length Array of the correct type into the API call. This way we
\r
279 * <i>know</i> that the Array returned is of exactly the correct length.
\r
281 * @return this collection as an Array
\r
283 public jalview.schemabinding.version2.AlcodonFrame[] getAlcodonFrame()
\r
285 jalview.schemabinding.version2.AlcodonFrame[] array = new jalview.schemabinding.version2.AlcodonFrame[0];
\r
286 return (jalview.schemabinding.version2.AlcodonFrame[]) this._alcodonFrameList
\r
291 * Method getAlcodonFrameCount.
\r
293 * @return the size of this collection
\r
295 public int getAlcodonFrameCount()
\r
297 return this._alcodonFrameList.size();
\r
301 * Method getAnnotation.
\r
304 * @throws java.lang.IndexOutOfBoundsException
\r
305 * if the index given is outside the bounds of the collection
\r
306 * @return the value of the jalview.schemabinding.version2.Annotation at the
\r
309 public jalview.schemabinding.version2.Annotation getAnnotation(
\r
310 final int index) throws java.lang.IndexOutOfBoundsException
\r
312 // check bounds for index
\r
313 if (index < 0 || index >= this._annotationList.size())
\r
315 throw new IndexOutOfBoundsException("getAnnotation: Index value '"
\r
316 + index + "' not in range [0.."
\r
317 + (this._annotationList.size() - 1) + "]");
\r
320 return (jalview.schemabinding.version2.Annotation) _annotationList
\r
325 * Method getAnnotation.Returns the contents of the collection in an Array.
\r
327 * Note: Just in case the collection contents are changing in another thread,
\r
328 * we pass a 0-length Array of the correct type into the API call. This way we
\r
329 * <i>know</i> that the Array returned is of exactly the correct length.
\r
331 * @return this collection as an Array
\r
333 public jalview.schemabinding.version2.Annotation[] getAnnotation()
\r
335 jalview.schemabinding.version2.Annotation[] array = new jalview.schemabinding.version2.Annotation[0];
\r
336 return (jalview.schemabinding.version2.Annotation[]) this._annotationList
\r
341 * Method getAnnotationCount.
\r
343 * @return the size of this collection
\r
345 public int getAnnotationCount()
\r
347 return this._annotationList.size();
\r
351 * Returns the value of field 'datasetId'. The field 'datasetId' has the
\r
352 * following description: reference to set where jalview will gather the
\r
353 * dataset sequences for all sequences in the set.
\r
356 * @return the value of field 'DatasetId'.
\r
358 public java.lang.String getDatasetId()
\r
360 return this._datasetId;
\r
364 * Returns the value of field 'gapChar'.
\r
366 * @return the value of field 'GapChar'.
\r
368 public java.lang.String getGapChar()
\r
370 return this._gapChar;
\r
374 * Method getSequence.
\r
377 * @throws java.lang.IndexOutOfBoundsException
\r
378 * if the index given is outside the bounds of the collection
\r
379 * @return the value of the jalview.schemabinding.version2.Sequence at the
\r
382 public jalview.schemabinding.version2.Sequence getSequence(final int index)
\r
383 throws java.lang.IndexOutOfBoundsException
\r
385 // check bounds for index
\r
386 if (index < 0 || index >= this._sequenceList.size())
\r
388 throw new IndexOutOfBoundsException("getSequence: Index value '"
\r
389 + index + "' not in range [0.."
\r
390 + (this._sequenceList.size() - 1) + "]");
\r
393 return (jalview.schemabinding.version2.Sequence) _sequenceList
\r
398 * Method getSequence.Returns the contents of the collection in an Array.
\r
400 * Note: Just in case the collection contents are changing in another thread,
\r
401 * we pass a 0-length Array of the correct type into the API call. This way we
\r
402 * <i>know</i> that the Array returned is of exactly the correct length.
\r
404 * @return this collection as an Array
\r
406 public jalview.schemabinding.version2.Sequence[] getSequence()
\r
408 jalview.schemabinding.version2.Sequence[] array = new jalview.schemabinding.version2.Sequence[0];
\r
409 return (jalview.schemabinding.version2.Sequence[]) this._sequenceList
\r
414 * Method getSequenceCount.
\r
416 * @return the size of this collection
\r
418 public int getSequenceCount()
\r
420 return this._sequenceList.size();
\r
424 * Method getSequenceSetProperties.
\r
427 * @throws java.lang.IndexOutOfBoundsException
\r
428 * if the index given is outside the bounds of the collection
\r
429 * @return the value of the
\r
430 * jalview.schemabinding.version2.SequenceSetProperties at the given
\r
433 public jalview.schemabinding.version2.SequenceSetProperties getSequenceSetProperties(
\r
434 final int index) throws java.lang.IndexOutOfBoundsException
\r
436 // check bounds for index
\r
437 if (index < 0 || index >= this._sequenceSetPropertiesList.size())
\r
439 throw new IndexOutOfBoundsException(
\r
440 "getSequenceSetProperties: Index value '" + index
\r
441 + "' not in range [0.."
\r
442 + (this._sequenceSetPropertiesList.size() - 1) + "]");
\r
445 return (jalview.schemabinding.version2.SequenceSetProperties) _sequenceSetPropertiesList
\r
450 * Method getSequenceSetProperties.Returns the contents of the collection in
\r
453 * Note: Just in case the collection contents are changing in another thread,
\r
454 * we pass a 0-length Array of the correct type into the API call. This way we
\r
455 * <i>know</i> that the Array returned is of exactly the correct length.
\r
457 * @return this collection as an Array
\r
459 public jalview.schemabinding.version2.SequenceSetProperties[] getSequenceSetProperties()
\r
461 jalview.schemabinding.version2.SequenceSetProperties[] array = new jalview.schemabinding.version2.SequenceSetProperties[0];
\r
462 return (jalview.schemabinding.version2.SequenceSetProperties[]) this._sequenceSetPropertiesList
\r
467 * Method getSequenceSetPropertiesCount.
\r
469 * @return the size of this collection
\r
471 public int getSequenceSetPropertiesCount()
\r
473 return this._sequenceSetPropertiesList.size();
\r
479 * @return true if this object is valid according to the schema
\r
481 public boolean isValid()
\r
486 } catch (org.exolab.castor.xml.ValidationException vex)
\r
497 * @throws org.exolab.castor.xml.MarshalException
\r
498 * if object is null or if any SAXException is thrown during
\r
500 * @throws org.exolab.castor.xml.ValidationException
\r
501 * if this object is an invalid instance according to the
\r
504 public void marshal(final java.io.Writer out)
\r
505 throws org.exolab.castor.xml.MarshalException,
\r
506 org.exolab.castor.xml.ValidationException
\r
508 Marshaller.marshal(this, out);
\r
515 * @throws java.io.IOException
\r
516 * if an IOException occurs during marshaling
\r
517 * @throws org.exolab.castor.xml.ValidationException
\r
518 * if this object is an invalid instance according to the
\r
520 * @throws org.exolab.castor.xml.MarshalException
\r
521 * if object is null or if any SAXException is thrown during
\r
524 public void marshal(final org.xml.sax.ContentHandler handler)
\r
525 throws java.io.IOException,
\r
526 org.exolab.castor.xml.MarshalException,
\r
527 org.exolab.castor.xml.ValidationException
\r
529 Marshaller.marshal(this, handler);
\r
533 * Method removeAlcodonFrame.
\r
535 * @param vAlcodonFrame
\r
536 * @return true if the object was removed from the collection.
\r
538 public boolean removeAlcodonFrame(
\r
539 final jalview.schemabinding.version2.AlcodonFrame vAlcodonFrame)
\r
541 boolean removed = _alcodonFrameList.remove(vAlcodonFrame);
\r
546 * Method removeAlcodonFrameAt.
\r
549 * @return the element removed from the collection
\r
551 public jalview.schemabinding.version2.AlcodonFrame removeAlcodonFrameAt(
\r
554 java.lang.Object obj = this._alcodonFrameList.remove(index);
\r
555 return (jalview.schemabinding.version2.AlcodonFrame) obj;
\r
560 public void removeAllAlcodonFrame()
\r
562 this._alcodonFrameList.clear();
\r
567 public void removeAllAnnotation()
\r
569 this._annotationList.clear();
\r
574 public void removeAllSequence()
\r
576 this._sequenceList.clear();
\r
581 public void removeAllSequenceSetProperties()
\r
583 this._sequenceSetPropertiesList.clear();
\r
587 * Method removeAnnotation.
\r
589 * @param vAnnotation
\r
590 * @return true if the object was removed from the collection.
\r
592 public boolean removeAnnotation(
\r
593 final jalview.schemabinding.version2.Annotation vAnnotation)
\r
595 boolean removed = _annotationList.remove(vAnnotation);
\r
600 * Method removeAnnotationAt.
\r
603 * @return the element removed from the collection
\r
605 public jalview.schemabinding.version2.Annotation removeAnnotationAt(
\r
608 java.lang.Object obj = this._annotationList.remove(index);
\r
609 return (jalview.schemabinding.version2.Annotation) obj;
\r
613 * Method removeSequence.
\r
616 * @return true if the object was removed from the collection.
\r
618 public boolean removeSequence(
\r
619 final jalview.schemabinding.version2.Sequence vSequence)
\r
621 boolean removed = _sequenceList.remove(vSequence);
\r
626 * Method removeSequenceAt.
\r
629 * @return the element removed from the collection
\r
631 public jalview.schemabinding.version2.Sequence removeSequenceAt(
\r
634 java.lang.Object obj = this._sequenceList.remove(index);
\r
635 return (jalview.schemabinding.version2.Sequence) obj;
\r
639 * Method removeSequenceSetProperties.
\r
641 * @param vSequenceSetProperties
\r
642 * @return true if the object was removed from the collection.
\r
644 public boolean removeSequenceSetProperties(
\r
645 final jalview.schemabinding.version2.SequenceSetProperties vSequenceSetProperties)
\r
647 boolean removed = _sequenceSetPropertiesList
\r
648 .remove(vSequenceSetProperties);
\r
653 * Method removeSequenceSetPropertiesAt.
\r
656 * @return the element removed from the collection
\r
658 public jalview.schemabinding.version2.SequenceSetProperties removeSequenceSetPropertiesAt(
\r
661 java.lang.Object obj = this._sequenceSetPropertiesList.remove(index);
\r
662 return (jalview.schemabinding.version2.SequenceSetProperties) obj;
\r
669 * @param vAlcodonFrame
\r
670 * @throws java.lang.IndexOutOfBoundsException
\r
671 * if the index given is outside the bounds of the collection
\r
673 public void setAlcodonFrame(final int index,
\r
674 final jalview.schemabinding.version2.AlcodonFrame vAlcodonFrame)
\r
675 throws java.lang.IndexOutOfBoundsException
\r
677 // check bounds for index
\r
678 if (index < 0 || index >= this._alcodonFrameList.size())
\r
680 throw new IndexOutOfBoundsException("setAlcodonFrame: Index value '"
\r
681 + index + "' not in range [0.."
\r
682 + (this._alcodonFrameList.size() - 1) + "]");
\r
685 this._alcodonFrameList.set(index, vAlcodonFrame);
\r
691 * @param vAlcodonFrameArray
\r
693 public void setAlcodonFrame(
\r
694 final jalview.schemabinding.version2.AlcodonFrame[] vAlcodonFrameArray)
\r
697 _alcodonFrameList.clear();
\r
699 for (int i = 0; i < vAlcodonFrameArray.length; i++)
\r
701 this._alcodonFrameList.add(vAlcodonFrameArray[i]);
\r
709 * @param vAnnotation
\r
710 * @throws java.lang.IndexOutOfBoundsException
\r
711 * if the index given is outside the bounds of the collection
\r
713 public void setAnnotation(final int index,
\r
714 final jalview.schemabinding.version2.Annotation vAnnotation)
\r
715 throws java.lang.IndexOutOfBoundsException
\r
717 // check bounds for index
\r
718 if (index < 0 || index >= this._annotationList.size())
\r
720 throw new IndexOutOfBoundsException("setAnnotation: Index value '"
\r
721 + index + "' not in range [0.."
\r
722 + (this._annotationList.size() - 1) + "]");
\r
725 this._annotationList.set(index, vAnnotation);
\r
731 * @param vAnnotationArray
\r
733 public void setAnnotation(
\r
734 final jalview.schemabinding.version2.Annotation[] vAnnotationArray)
\r
737 _annotationList.clear();
\r
739 for (int i = 0; i < vAnnotationArray.length; i++)
\r
741 this._annotationList.add(vAnnotationArray[i]);
\r
746 * Sets the value of field 'datasetId'. The field 'datasetId' has the
\r
747 * following description: reference to set where jalview will gather the
\r
748 * dataset sequences for all sequences in the set.
\r
752 * the value of field 'datasetId'.
\r
754 public void setDatasetId(final java.lang.String datasetId)
\r
756 this._datasetId = datasetId;
\r
760 * Sets the value of field 'gapChar'.
\r
763 * the value of field 'gapChar'.
\r
765 public void setGapChar(final java.lang.String gapChar)
\r
767 this._gapChar = gapChar;
\r
775 * @throws java.lang.IndexOutOfBoundsException
\r
776 * if the index given is outside the bounds of the collection
\r
778 public void setSequence(final int index,
\r
779 final jalview.schemabinding.version2.Sequence vSequence)
\r
780 throws java.lang.IndexOutOfBoundsException
\r
782 // check bounds for index
\r
783 if (index < 0 || index >= this._sequenceList.size())
\r
785 throw new IndexOutOfBoundsException("setSequence: Index value '"
\r
786 + index + "' not in range [0.."
\r
787 + (this._sequenceList.size() - 1) + "]");
\r
790 this._sequenceList.set(index, vSequence);
\r
796 * @param vSequenceArray
\r
798 public void setSequence(
\r
799 final jalview.schemabinding.version2.Sequence[] vSequenceArray)
\r
802 _sequenceList.clear();
\r
804 for (int i = 0; i < vSequenceArray.length; i++)
\r
806 this._sequenceList.add(vSequenceArray[i]);
\r
814 * @param vSequenceSetProperties
\r
815 * @throws java.lang.IndexOutOfBoundsException
\r
816 * if the index given is outside the bounds of the collection
\r
818 public void setSequenceSetProperties(
\r
820 final jalview.schemabinding.version2.SequenceSetProperties vSequenceSetProperties)
\r
821 throws java.lang.IndexOutOfBoundsException
\r
823 // check bounds for index
\r
824 if (index < 0 || index >= this._sequenceSetPropertiesList.size())
\r
826 throw new IndexOutOfBoundsException(
\r
827 "setSequenceSetProperties: Index value '" + index
\r
828 + "' not in range [0.."
\r
829 + (this._sequenceSetPropertiesList.size() - 1) + "]");
\r
832 this._sequenceSetPropertiesList.set(index, vSequenceSetProperties);
\r
838 * @param vSequenceSetPropertiesArray
\r
840 public void setSequenceSetProperties(
\r
841 final jalview.schemabinding.version2.SequenceSetProperties[] vSequenceSetPropertiesArray)
\r
844 _sequenceSetPropertiesList.clear();
\r
846 for (int i = 0; i < vSequenceSetPropertiesArray.length; i++)
\r
848 this._sequenceSetPropertiesList.add(vSequenceSetPropertiesArray[i]);
\r
853 * Method unmarshal.
\r
856 * @throws org.exolab.castor.xml.MarshalException
\r
857 * if object is null or if any SAXException is thrown during
\r
859 * @throws org.exolab.castor.xml.ValidationException
\r
860 * if this object is an invalid instance according to the
\r
862 * @return the unmarshaled jalview.schemabinding.version2.SequenceSet
\r
864 public static jalview.schemabinding.version2.SequenceSet unmarshal(
\r
865 final java.io.Reader reader)
\r
866 throws org.exolab.castor.xml.MarshalException,
\r
867 org.exolab.castor.xml.ValidationException
\r
869 return (jalview.schemabinding.version2.SequenceSet) Unmarshaller
\r
870 .unmarshal(jalview.schemabinding.version2.SequenceSet.class,
\r
877 * @throws org.exolab.castor.xml.ValidationException
\r
878 * if this object is an invalid instance according to the
\r
881 public void validate() throws org.exolab.castor.xml.ValidationException
\r
883 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
\r
884 validator.validate(this);
\r