2 * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)
\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
\r
47 * sequences for all 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
77 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
93 * @param vAlcodonFrame
\r
94 * @throws java.lang.IndexOutOfBoundsException if the index
\r
95 * given is outside the bounds of the collection
\r
97 public void addAlcodonFrame(
\r
98 final jalview.schemabinding.version2.AlcodonFrame vAlcodonFrame)
\r
99 throws java.lang.IndexOutOfBoundsException {
\r
100 this._alcodonFrameList.addElement(vAlcodonFrame);
\r
107 * @param vAlcodonFrame
\r
108 * @throws java.lang.IndexOutOfBoundsException if the index
\r
109 * given is outside the bounds of the collection
\r
111 public void addAlcodonFrame(
\r
113 final jalview.schemabinding.version2.AlcodonFrame vAlcodonFrame)
\r
114 throws java.lang.IndexOutOfBoundsException {
\r
115 this._alcodonFrameList.add(index, vAlcodonFrame);
\r
121 * @param vAnnotation
\r
122 * @throws java.lang.IndexOutOfBoundsException if the index
\r
123 * 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
128 this._annotationList.addElement(vAnnotation);
\r
135 * @param vAnnotation
\r
136 * @throws java.lang.IndexOutOfBoundsException if the index
\r
137 * given is outside the bounds of the collection
\r
139 public void addAnnotation(
\r
141 final jalview.schemabinding.version2.Annotation vAnnotation)
\r
142 throws java.lang.IndexOutOfBoundsException {
\r
143 this._annotationList.add(index, vAnnotation);
\r
150 * @throws java.lang.IndexOutOfBoundsException if the index
\r
151 * given is outside the bounds of the collection
\r
153 public void addSequence(
\r
154 final jalview.schemabinding.version2.Sequence vSequence)
\r
155 throws java.lang.IndexOutOfBoundsException {
\r
156 this._sequenceList.addElement(vSequence);
\r
164 * @throws java.lang.IndexOutOfBoundsException if the index
\r
165 * given is outside the bounds of the collection
\r
167 public void addSequence(
\r
169 final jalview.schemabinding.version2.Sequence vSequence)
\r
170 throws java.lang.IndexOutOfBoundsException {
\r
171 this._sequenceList.add(index, vSequence);
\r
177 * @param vSequenceSetProperties
\r
178 * @throws java.lang.IndexOutOfBoundsException if the index
\r
179 * given is outside the bounds of the collection
\r
181 public void addSequenceSetProperties(
\r
182 final jalview.schemabinding.version2.SequenceSetProperties vSequenceSetProperties)
\r
183 throws java.lang.IndexOutOfBoundsException {
\r
184 this._sequenceSetPropertiesList.addElement(vSequenceSetProperties);
\r
191 * @param vSequenceSetProperties
\r
192 * @throws java.lang.IndexOutOfBoundsException if the index
\r
193 * given is outside the bounds of the collection
\r
195 public void addSequenceSetProperties(
\r
197 final jalview.schemabinding.version2.SequenceSetProperties vSequenceSetProperties)
\r
198 throws java.lang.IndexOutOfBoundsException {
\r
199 this._sequenceSetPropertiesList.add(index, vSequenceSetProperties);
\r
203 * Method enumerateAlcodonFrame.
\r
205 * @return an Enumeration over all
\r
206 * jalview.schemabinding.version2.AlcodonFrame elements
\r
208 public java.util.Enumeration enumerateAlcodonFrame(
\r
210 return this._alcodonFrameList.elements();
\r
214 * Method enumerateAnnotation.
\r
216 * @return an Enumeration over all
\r
217 * jalview.schemabinding.version2.Annotation elements
\r
219 public java.util.Enumeration enumerateAnnotation(
\r
221 return this._annotationList.elements();
\r
225 * Method enumerateSequence.
\r
227 * @return an Enumeration over all
\r
228 * jalview.schemabinding.version2.Sequence elements
\r
230 public java.util.Enumeration enumerateSequence(
\r
232 return this._sequenceList.elements();
\r
236 * Method enumerateSequenceSetProperties.
\r
238 * @return an Enumeration over all
\r
239 * jalview.schemabinding.version2.SequenceSetProperties elements
\r
241 public java.util.Enumeration enumerateSequenceSetProperties(
\r
243 return this._sequenceSetPropertiesList.elements();
\r
247 * Method getAlcodonFrame.
\r
250 * @throws java.lang.IndexOutOfBoundsException if the index
\r
251 * given is outside the bounds of the collection
\r
252 * @return the value of the
\r
253 * jalview.schemabinding.version2.AlcodonFrame at the given inde
\r
255 public jalview.schemabinding.version2.AlcodonFrame getAlcodonFrame(
\r
257 throws java.lang.IndexOutOfBoundsException {
\r
258 // check bounds for index
\r
259 if (index < 0 || index >= this._alcodonFrameList.size()) {
\r
260 throw new IndexOutOfBoundsException("getAlcodonFrame: Index value '" + index + "' not in range [0.." + (this._alcodonFrameList.size() - 1) + "]");
\r
263 return (jalview.schemabinding.version2.AlcodonFrame) _alcodonFrameList.get(index);
\r
267 * Method getAlcodonFrame.Returns the contents of the
\r
268 * collection in an Array. <p>Note: Just in case the
\r
269 * collection contents are changing in another thread, we pass
\r
270 * a 0-length Array of the correct type into the API call.
\r
271 * This way we <i>know</i> that the Array returned is of
\r
272 * exactly the correct length.
\r
274 * @return this collection as an Array
\r
276 public jalview.schemabinding.version2.AlcodonFrame[] getAlcodonFrame(
\r
278 jalview.schemabinding.version2.AlcodonFrame[] array = new jalview.schemabinding.version2.AlcodonFrame[0];
\r
279 return (jalview.schemabinding.version2.AlcodonFrame[]) this._alcodonFrameList.toArray(array);
\r
283 * Method getAlcodonFrameCount.
\r
285 * @return the size of this collection
\r
287 public int getAlcodonFrameCount(
\r
289 return this._alcodonFrameList.size();
\r
293 * Method getAnnotation.
\r
296 * @throws java.lang.IndexOutOfBoundsException if the index
\r
297 * given is outside the bounds of the collection
\r
298 * @return the value of the
\r
299 * jalview.schemabinding.version2.Annotation at the given index
\r
301 public jalview.schemabinding.version2.Annotation getAnnotation(
\r
303 throws java.lang.IndexOutOfBoundsException {
\r
304 // check bounds for index
\r
305 if (index < 0 || index >= this._annotationList.size()) {
\r
306 throw new IndexOutOfBoundsException("getAnnotation: Index value '" + index + "' not in range [0.." + (this._annotationList.size() - 1) + "]");
\r
309 return (jalview.schemabinding.version2.Annotation) _annotationList.get(index);
\r
313 * Method getAnnotation.Returns the contents of the collection
\r
314 * in an Array. <p>Note: Just in case the collection contents
\r
315 * are changing in another thread, we pass a 0-length Array of
\r
316 * the correct type into the API call. This way we <i>know</i>
\r
317 * that the Array returned is of exactly the correct length.
\r
319 * @return this collection as an Array
\r
321 public jalview.schemabinding.version2.Annotation[] getAnnotation(
\r
323 jalview.schemabinding.version2.Annotation[] array = new jalview.schemabinding.version2.Annotation[0];
\r
324 return (jalview.schemabinding.version2.Annotation[]) this._annotationList.toArray(array);
\r
328 * Method getAnnotationCount.
\r
330 * @return the size of this collection
\r
332 public int getAnnotationCount(
\r
334 return this._annotationList.size();
\r
338 * Returns the value of field 'datasetId'. The field
\r
339 * 'datasetId' has the following description: reference to set
\r
340 * where jalview will gather the dataset sequences for all
\r
341 * sequences in the set.
\r
344 * @return the value of field 'DatasetId'.
\r
346 public java.lang.String getDatasetId(
\r
348 return this._datasetId;
\r
352 * Returns the value of field 'gapChar'.
\r
354 * @return the value of field 'GapChar'.
\r
356 public java.lang.String getGapChar(
\r
358 return this._gapChar;
\r
362 * Method getSequence.
\r
365 * @throws java.lang.IndexOutOfBoundsException if the index
\r
366 * given is outside the bounds of the collection
\r
367 * @return the value of the
\r
368 * jalview.schemabinding.version2.Sequence at the given index
\r
370 public jalview.schemabinding.version2.Sequence getSequence(
\r
372 throws java.lang.IndexOutOfBoundsException {
\r
373 // check bounds for index
\r
374 if (index < 0 || index >= this._sequenceList.size()) {
\r
375 throw new IndexOutOfBoundsException("getSequence: Index value '" + index + "' not in range [0.." + (this._sequenceList.size() - 1) + "]");
\r
378 return (jalview.schemabinding.version2.Sequence) _sequenceList.get(index);
\r
382 * Method getSequence.Returns the contents of the collection in
\r
383 * an Array. <p>Note: Just in case the collection contents
\r
384 * are changing in another thread, we pass a 0-length Array of
\r
385 * the correct type into the API call. This way we <i>know</i>
\r
386 * that the Array returned is of exactly the correct length.
\r
388 * @return this collection as an Array
\r
390 public jalview.schemabinding.version2.Sequence[] getSequence(
\r
392 jalview.schemabinding.version2.Sequence[] array = new jalview.schemabinding.version2.Sequence[0];
\r
393 return (jalview.schemabinding.version2.Sequence[]) this._sequenceList.toArray(array);
\r
397 * Method getSequenceCount.
\r
399 * @return the size of this collection
\r
401 public int getSequenceCount(
\r
403 return this._sequenceList.size();
\r
407 * Method getSequenceSetProperties.
\r
410 * @throws java.lang.IndexOutOfBoundsException if the index
\r
411 * given is outside the bounds of the collection
\r
412 * @return the value of the
\r
413 * jalview.schemabinding.version2.SequenceSetProperties at the
\r
416 public jalview.schemabinding.version2.SequenceSetProperties getSequenceSetProperties(
\r
418 throws java.lang.IndexOutOfBoundsException {
\r
419 // check bounds for index
\r
420 if (index < 0 || index >= this._sequenceSetPropertiesList.size()) {
\r
421 throw new IndexOutOfBoundsException("getSequenceSetProperties: Index value '" + index + "' not in range [0.." + (this._sequenceSetPropertiesList.size() - 1) + "]");
\r
424 return (jalview.schemabinding.version2.SequenceSetProperties) _sequenceSetPropertiesList.get(index);
\r
428 * Method getSequenceSetProperties.Returns the contents of the
\r
429 * collection in an Array. <p>Note: Just in case the
\r
430 * collection contents are changing in another thread, we pass
\r
431 * a 0-length Array of the correct type into the API call.
\r
432 * This way we <i>know</i> that the Array returned is of
\r
433 * exactly the correct length.
\r
435 * @return this collection as an Array
\r
437 public jalview.schemabinding.version2.SequenceSetProperties[] getSequenceSetProperties(
\r
439 jalview.schemabinding.version2.SequenceSetProperties[] array = new jalview.schemabinding.version2.SequenceSetProperties[0];
\r
440 return (jalview.schemabinding.version2.SequenceSetProperties[]) this._sequenceSetPropertiesList.toArray(array);
\r
444 * Method getSequenceSetPropertiesCount.
\r
446 * @return the size of this collection
\r
448 public int getSequenceSetPropertiesCount(
\r
450 return this._sequenceSetPropertiesList.size();
\r
456 * @return true if this object is valid according to the schema
\r
458 public boolean isValid(
\r
462 } catch (org.exolab.castor.xml.ValidationException vex) {
\r
472 * @throws org.exolab.castor.xml.MarshalException if object is
\r
473 * null or if any SAXException is thrown during marshaling
\r
474 * @throws org.exolab.castor.xml.ValidationException if this
\r
475 * object is an invalid instance according to the schema
\r
477 public void marshal(
\r
478 final java.io.Writer out)
\r
479 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
\r
480 Marshaller.marshal(this, out);
\r
487 * @throws java.io.IOException if an IOException occurs during
\r
489 * @throws org.exolab.castor.xml.ValidationException if this
\r
490 * object is an invalid instance according to the schema
\r
491 * @throws org.exolab.castor.xml.MarshalException if object is
\r
492 * null or if any SAXException is thrown during marshaling
\r
494 public void marshal(
\r
495 final org.xml.sax.ContentHandler handler)
\r
496 throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
\r
497 Marshaller.marshal(this, handler);
\r
501 * Method removeAlcodonFrame.
\r
503 * @param vAlcodonFrame
\r
504 * @return true if the object was removed from the collection.
\r
506 public boolean removeAlcodonFrame(
\r
507 final jalview.schemabinding.version2.AlcodonFrame vAlcodonFrame) {
\r
508 boolean removed = _alcodonFrameList.remove(vAlcodonFrame);
\r
513 * Method removeAlcodonFrameAt.
\r
516 * @return the element removed from the collection
\r
518 public jalview.schemabinding.version2.AlcodonFrame removeAlcodonFrameAt(
\r
520 java.lang.Object obj = this._alcodonFrameList.remove(index);
\r
521 return (jalview.schemabinding.version2.AlcodonFrame) obj;
\r
526 public void removeAllAlcodonFrame(
\r
528 this._alcodonFrameList.clear();
\r
533 public void removeAllAnnotation(
\r
535 this._annotationList.clear();
\r
540 public void removeAllSequence(
\r
542 this._sequenceList.clear();
\r
547 public void removeAllSequenceSetProperties(
\r
549 this._sequenceSetPropertiesList.clear();
\r
553 * Method removeAnnotation.
\r
555 * @param vAnnotation
\r
556 * @return true if the object was removed from the collection.
\r
558 public boolean removeAnnotation(
\r
559 final jalview.schemabinding.version2.Annotation vAnnotation) {
\r
560 boolean removed = _annotationList.remove(vAnnotation);
\r
565 * Method removeAnnotationAt.
\r
568 * @return the element removed from the collection
\r
570 public jalview.schemabinding.version2.Annotation removeAnnotationAt(
\r
572 java.lang.Object obj = this._annotationList.remove(index);
\r
573 return (jalview.schemabinding.version2.Annotation) obj;
\r
577 * Method removeSequence.
\r
580 * @return true if the object was removed from the collection.
\r
582 public boolean removeSequence(
\r
583 final jalview.schemabinding.version2.Sequence vSequence) {
\r
584 boolean removed = _sequenceList.remove(vSequence);
\r
589 * Method removeSequenceAt.
\r
592 * @return the element removed from the collection
\r
594 public jalview.schemabinding.version2.Sequence removeSequenceAt(
\r
596 java.lang.Object obj = this._sequenceList.remove(index);
\r
597 return (jalview.schemabinding.version2.Sequence) obj;
\r
601 * Method removeSequenceSetProperties.
\r
603 * @param vSequenceSetProperties
\r
604 * @return true if the object was removed from the collection.
\r
606 public boolean removeSequenceSetProperties(
\r
607 final jalview.schemabinding.version2.SequenceSetProperties vSequenceSetProperties) {
\r
608 boolean removed = _sequenceSetPropertiesList.remove(vSequenceSetProperties);
\r
613 * Method removeSequenceSetPropertiesAt.
\r
616 * @return the element removed from the collection
\r
618 public jalview.schemabinding.version2.SequenceSetProperties removeSequenceSetPropertiesAt(
\r
620 java.lang.Object obj = this._sequenceSetPropertiesList.remove(index);
\r
621 return (jalview.schemabinding.version2.SequenceSetProperties) obj;
\r
628 * @param vAlcodonFrame
\r
629 * @throws java.lang.IndexOutOfBoundsException if the index
\r
630 * given is outside the bounds of the collection
\r
632 public void setAlcodonFrame(
\r
634 final jalview.schemabinding.version2.AlcodonFrame vAlcodonFrame)
\r
635 throws java.lang.IndexOutOfBoundsException {
\r
636 // check bounds for index
\r
637 if (index < 0 || index >= this._alcodonFrameList.size()) {
\r
638 throw new IndexOutOfBoundsException("setAlcodonFrame: Index value '" + index + "' not in range [0.." + (this._alcodonFrameList.size() - 1) + "]");
\r
641 this._alcodonFrameList.set(index, vAlcodonFrame);
\r
647 * @param vAlcodonFrameArray
\r
649 public void setAlcodonFrame(
\r
650 final jalview.schemabinding.version2.AlcodonFrame[] vAlcodonFrameArray) {
\r
652 _alcodonFrameList.clear();
\r
654 for (int i = 0; i < vAlcodonFrameArray.length; i++) {
\r
655 this._alcodonFrameList.add(vAlcodonFrameArray[i]);
\r
663 * @param vAnnotation
\r
664 * @throws java.lang.IndexOutOfBoundsException if the index
\r
665 * given is outside the bounds of the collection
\r
667 public void setAnnotation(
\r
669 final jalview.schemabinding.version2.Annotation vAnnotation)
\r
670 throws java.lang.IndexOutOfBoundsException {
\r
671 // check bounds for index
\r
672 if (index < 0 || index >= this._annotationList.size()) {
\r
673 throw new IndexOutOfBoundsException("setAnnotation: Index value '" + index + "' not in range [0.." + (this._annotationList.size() - 1) + "]");
\r
676 this._annotationList.set(index, vAnnotation);
\r
682 * @param vAnnotationArray
\r
684 public void setAnnotation(
\r
685 final jalview.schemabinding.version2.Annotation[] vAnnotationArray) {
\r
687 _annotationList.clear();
\r
689 for (int i = 0; i < vAnnotationArray.length; i++) {
\r
690 this._annotationList.add(vAnnotationArray[i]);
\r
695 * Sets the value of field 'datasetId'. The field 'datasetId'
\r
696 * has the following description: reference to set where
\r
697 * jalview will gather the dataset sequences for all sequences
\r
701 * @param datasetId the value of field 'datasetId'.
\r
703 public void setDatasetId(
\r
704 final java.lang.String datasetId) {
\r
705 this._datasetId = datasetId;
\r
709 * Sets the value of field 'gapChar'.
\r
711 * @param gapChar the value of field 'gapChar'.
\r
713 public void setGapChar(
\r
714 final java.lang.String gapChar) {
\r
715 this._gapChar = gapChar;
\r
723 * @throws java.lang.IndexOutOfBoundsException if the index
\r
724 * given is outside the bounds of the collection
\r
726 public void setSequence(
\r
728 final jalview.schemabinding.version2.Sequence vSequence)
\r
729 throws java.lang.IndexOutOfBoundsException {
\r
730 // check bounds for index
\r
731 if (index < 0 || index >= this._sequenceList.size()) {
\r
732 throw new IndexOutOfBoundsException("setSequence: Index value '" + index + "' not in range [0.." + (this._sequenceList.size() - 1) + "]");
\r
735 this._sequenceList.set(index, vSequence);
\r
741 * @param vSequenceArray
\r
743 public void setSequence(
\r
744 final jalview.schemabinding.version2.Sequence[] vSequenceArray) {
\r
746 _sequenceList.clear();
\r
748 for (int i = 0; i < vSequenceArray.length; i++) {
\r
749 this._sequenceList.add(vSequenceArray[i]);
\r
757 * @param vSequenceSetProperties
\r
758 * @throws java.lang.IndexOutOfBoundsException if the index
\r
759 * given is outside the bounds of the collection
\r
761 public void setSequenceSetProperties(
\r
763 final jalview.schemabinding.version2.SequenceSetProperties vSequenceSetProperties)
\r
764 throws java.lang.IndexOutOfBoundsException {
\r
765 // check bounds for index
\r
766 if (index < 0 || index >= this._sequenceSetPropertiesList.size()) {
\r
767 throw new IndexOutOfBoundsException("setSequenceSetProperties: Index value '" + index + "' not in range [0.." + (this._sequenceSetPropertiesList.size() - 1) + "]");
\r
770 this._sequenceSetPropertiesList.set(index, vSequenceSetProperties);
\r
776 * @param vSequenceSetPropertiesArray
\r
778 public void setSequenceSetProperties(
\r
779 final jalview.schemabinding.version2.SequenceSetProperties[] vSequenceSetPropertiesArray) {
\r
781 _sequenceSetPropertiesList.clear();
\r
783 for (int i = 0; i < vSequenceSetPropertiesArray.length; i++) {
\r
784 this._sequenceSetPropertiesList.add(vSequenceSetPropertiesArray[i]);
\r
789 * Method unmarshal.
\r
792 * @throws org.exolab.castor.xml.MarshalException if object is
\r
793 * null or if any SAXException is thrown during marshaling
\r
794 * @throws org.exolab.castor.xml.ValidationException if this
\r
795 * object is an invalid instance according to the schema
\r
796 * @return the unmarshaled
\r
797 * jalview.schemabinding.version2.SequenceSet
\r
799 public static jalview.schemabinding.version2.SequenceSet unmarshal(
\r
800 final java.io.Reader reader)
\r
801 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
\r
802 return (jalview.schemabinding.version2.SequenceSet) Unmarshaller.unmarshal(jalview.schemabinding.version2.SequenceSet.class, reader);
\r
808 * @throws org.exolab.castor.xml.ValidationException if this
\r
809 * object is an invalid instance according to the schema
\r
811 public void validate(
\r
813 throws org.exolab.castor.xml.ValidationException {
\r
814 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
\r
815 validator.validate(this);
\r