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;
31 * @version $Revision$ $Date$
33 public class SequenceSet implements java.io.Serializable
36 // --------------------------/
37 // - Class/Member Variables -/
38 // --------------------------/
43 private java.lang.String _gapChar;
46 * reference to set where jalview will gather the dataset sequences for all
47 * sequences in the set.
50 private java.lang.String _datasetId;
53 * Field _sequenceList.
55 private java.util.Vector _sequenceList;
58 * Field _annotationList.
60 private java.util.Vector _annotationList;
63 * Field _sequenceSetPropertiesList.
65 private java.util.Vector _sequenceSetPropertiesList;
68 * Field _alcodonFrameList.
70 private java.util.Vector _alcodonFrameList;
79 this._sequenceList = new java.util.Vector();
80 this._annotationList = new java.util.Vector();
81 this._sequenceSetPropertiesList = new java.util.Vector();
82 this._alcodonFrameList = new java.util.Vector();
92 * @param vAlcodonFrame
93 * @throws java.lang.IndexOutOfBoundsException
94 * if the index given is outside the bounds of the collection
96 public void addAlcodonFrame(
97 final jalview.schemabinding.version2.AlcodonFrame vAlcodonFrame)
98 throws java.lang.IndexOutOfBoundsException
100 this._alcodonFrameList.addElement(vAlcodonFrame);
107 * @param vAlcodonFrame
108 * @throws java.lang.IndexOutOfBoundsException
109 * if the index given is outside the bounds of the collection
111 public void addAlcodonFrame(final int index,
112 final jalview.schemabinding.version2.AlcodonFrame vAlcodonFrame)
113 throws java.lang.IndexOutOfBoundsException
115 this._alcodonFrameList.add(index, vAlcodonFrame);
122 * @throws java.lang.IndexOutOfBoundsException
123 * if the index given is outside the bounds of the collection
125 public void addAnnotation(
126 final jalview.schemabinding.version2.Annotation vAnnotation)
127 throws java.lang.IndexOutOfBoundsException
129 this._annotationList.addElement(vAnnotation);
137 * @throws java.lang.IndexOutOfBoundsException
138 * if the index given is outside the bounds of the collection
140 public void addAnnotation(final int index,
141 final jalview.schemabinding.version2.Annotation vAnnotation)
142 throws java.lang.IndexOutOfBoundsException
144 this._annotationList.add(index, vAnnotation);
151 * @throws java.lang.IndexOutOfBoundsException
152 * if the index given is outside the bounds of the collection
154 public void addSequence(
155 final jalview.schemabinding.version2.Sequence vSequence)
156 throws java.lang.IndexOutOfBoundsException
158 this._sequenceList.addElement(vSequence);
166 * @throws java.lang.IndexOutOfBoundsException
167 * if the index given is outside the bounds of the collection
169 public void addSequence(final int index,
170 final jalview.schemabinding.version2.Sequence vSequence)
171 throws java.lang.IndexOutOfBoundsException
173 this._sequenceList.add(index, vSequence);
179 * @param vSequenceSetProperties
180 * @throws java.lang.IndexOutOfBoundsException
181 * if the index given is outside the bounds of the collection
183 public void addSequenceSetProperties(
184 final jalview.schemabinding.version2.SequenceSetProperties vSequenceSetProperties)
185 throws java.lang.IndexOutOfBoundsException
187 this._sequenceSetPropertiesList.addElement(vSequenceSetProperties);
194 * @param vSequenceSetProperties
195 * @throws java.lang.IndexOutOfBoundsException
196 * if the index given is outside the bounds of the collection
198 public void addSequenceSetProperties(
200 final jalview.schemabinding.version2.SequenceSetProperties vSequenceSetProperties)
201 throws java.lang.IndexOutOfBoundsException
203 this._sequenceSetPropertiesList.add(index, vSequenceSetProperties);
207 * Method enumerateAlcodonFrame.
209 * @return an Enumeration over all jalview.schemabinding.version2.AlcodonFrame
212 public java.util.Enumeration enumerateAlcodonFrame()
214 return this._alcodonFrameList.elements();
218 * Method enumerateAnnotation.
220 * @return an Enumeration over all jalview.schemabinding.version2.Annotation
223 public java.util.Enumeration enumerateAnnotation()
225 return this._annotationList.elements();
229 * Method enumerateSequence.
231 * @return an Enumeration over all jalview.schemabinding.version2.Sequence
234 public java.util.Enumeration enumerateSequence()
236 return this._sequenceList.elements();
240 * Method enumerateSequenceSetProperties.
242 * @return an Enumeration over all
243 * jalview.schemabinding.version2.SequenceSetProperties elements
245 public java.util.Enumeration enumerateSequenceSetProperties()
247 return this._sequenceSetPropertiesList.elements();
251 * Method getAlcodonFrame.
254 * @throws java.lang.IndexOutOfBoundsException
255 * if the index given is outside the bounds of the collection
256 * @return the value of the jalview.schemabinding.version2.AlcodonFrame at the
259 public jalview.schemabinding.version2.AlcodonFrame getAlcodonFrame(
260 final int index) throws java.lang.IndexOutOfBoundsException
262 // check bounds for index
263 if (index < 0 || index >= this._alcodonFrameList.size())
265 throw new IndexOutOfBoundsException("getAlcodonFrame: Index value '"
266 + index + "' not in range [0.."
267 + (this._alcodonFrameList.size() - 1) + "]");
270 return (jalview.schemabinding.version2.AlcodonFrame) _alcodonFrameList
275 * Method getAlcodonFrame.Returns the contents of the collection in an Array.
277 * Note: Just in case the collection contents are changing in another thread,
278 * we pass a 0-length Array of the correct type into the API call. This way we
279 * <i>know</i> that the Array returned is of exactly the correct length.
281 * @return this collection as an Array
283 public jalview.schemabinding.version2.AlcodonFrame[] getAlcodonFrame()
285 jalview.schemabinding.version2.AlcodonFrame[] array = new jalview.schemabinding.version2.AlcodonFrame[0];
286 return (jalview.schemabinding.version2.AlcodonFrame[]) this._alcodonFrameList
291 * Method getAlcodonFrameCount.
293 * @return the size of this collection
295 public int getAlcodonFrameCount()
297 return this._alcodonFrameList.size();
301 * Method getAnnotation.
304 * @throws java.lang.IndexOutOfBoundsException
305 * if the index given is outside the bounds of the collection
306 * @return the value of the jalview.schemabinding.version2.Annotation at the
309 public jalview.schemabinding.version2.Annotation getAnnotation(
310 final int index) throws java.lang.IndexOutOfBoundsException
312 // check bounds for index
313 if (index < 0 || index >= this._annotationList.size())
315 throw new IndexOutOfBoundsException("getAnnotation: Index value '"
316 + index + "' not in range [0.."
317 + (this._annotationList.size() - 1) + "]");
320 return (jalview.schemabinding.version2.Annotation) _annotationList
325 * Method getAnnotation.Returns the contents of the collection in an Array.
327 * Note: Just in case the collection contents are changing in another thread,
328 * we pass a 0-length Array of the correct type into the API call. This way we
329 * <i>know</i> that the Array returned is of exactly the correct length.
331 * @return this collection as an Array
333 public jalview.schemabinding.version2.Annotation[] getAnnotation()
335 jalview.schemabinding.version2.Annotation[] array = new jalview.schemabinding.version2.Annotation[0];
336 return (jalview.schemabinding.version2.Annotation[]) this._annotationList
341 * Method getAnnotationCount.
343 * @return the size of this collection
345 public int getAnnotationCount()
347 return this._annotationList.size();
351 * Returns the value of field 'datasetId'. The field 'datasetId' has the
352 * following description: reference to set where jalview will gather the
353 * dataset sequences for all sequences in the set.
356 * @return the value of field 'DatasetId'.
358 public java.lang.String getDatasetId()
360 return this._datasetId;
364 * Returns the value of field 'gapChar'.
366 * @return the value of field 'GapChar'.
368 public java.lang.String getGapChar()
370 return this._gapChar;
374 * Method getSequence.
377 * @throws java.lang.IndexOutOfBoundsException
378 * if the index given is outside the bounds of the collection
379 * @return the value of the jalview.schemabinding.version2.Sequence at the
382 public jalview.schemabinding.version2.Sequence getSequence(final int index)
383 throws java.lang.IndexOutOfBoundsException
385 // check bounds for index
386 if (index < 0 || index >= this._sequenceList.size())
388 throw new IndexOutOfBoundsException("getSequence: Index value '"
389 + index + "' not in range [0.."
390 + (this._sequenceList.size() - 1) + "]");
393 return (jalview.schemabinding.version2.Sequence) _sequenceList
398 * Method getSequence.Returns the contents of the collection in an Array.
400 * Note: Just in case the collection contents are changing in another thread,
401 * we pass a 0-length Array of the correct type into the API call. This way we
402 * <i>know</i> that the Array returned is of exactly the correct length.
404 * @return this collection as an Array
406 public jalview.schemabinding.version2.Sequence[] getSequence()
408 jalview.schemabinding.version2.Sequence[] array = new jalview.schemabinding.version2.Sequence[0];
409 return (jalview.schemabinding.version2.Sequence[]) this._sequenceList
414 * Method getSequenceCount.
416 * @return the size of this collection
418 public int getSequenceCount()
420 return this._sequenceList.size();
424 * Method getSequenceSetProperties.
427 * @throws java.lang.IndexOutOfBoundsException
428 * if the index given is outside the bounds of the collection
429 * @return the value of the
430 * jalview.schemabinding.version2.SequenceSetProperties at the given
433 public jalview.schemabinding.version2.SequenceSetProperties getSequenceSetProperties(
434 final int index) throws java.lang.IndexOutOfBoundsException
436 // check bounds for index
437 if (index < 0 || index >= this._sequenceSetPropertiesList.size())
439 throw new IndexOutOfBoundsException(
440 "getSequenceSetProperties: Index value '" + index
441 + "' not in range [0.."
442 + (this._sequenceSetPropertiesList.size() - 1) + "]");
445 return (jalview.schemabinding.version2.SequenceSetProperties) _sequenceSetPropertiesList
450 * Method getSequenceSetProperties.Returns the contents of the collection in
453 * Note: Just in case the collection contents are changing in another thread,
454 * we pass a 0-length Array of the correct type into the API call. This way we
455 * <i>know</i> that the Array returned is of exactly the correct length.
457 * @return this collection as an Array
459 public jalview.schemabinding.version2.SequenceSetProperties[] getSequenceSetProperties()
461 jalview.schemabinding.version2.SequenceSetProperties[] array = new jalview.schemabinding.version2.SequenceSetProperties[0];
462 return (jalview.schemabinding.version2.SequenceSetProperties[]) this._sequenceSetPropertiesList
467 * Method getSequenceSetPropertiesCount.
469 * @return the size of this collection
471 public int getSequenceSetPropertiesCount()
473 return this._sequenceSetPropertiesList.size();
479 * @return true if this object is valid according to the schema
481 public boolean isValid()
486 } catch (org.exolab.castor.xml.ValidationException vex)
497 * @throws org.exolab.castor.xml.MarshalException
498 * if object is null or if any SAXException is thrown during
500 * @throws org.exolab.castor.xml.ValidationException
501 * if this object is an invalid instance according to the schema
503 public void marshal(final java.io.Writer out)
504 throws org.exolab.castor.xml.MarshalException,
505 org.exolab.castor.xml.ValidationException
507 Marshaller.marshal(this, out);
514 * @throws java.io.IOException
515 * if an IOException occurs during marshaling
516 * @throws org.exolab.castor.xml.ValidationException
517 * if this object is an invalid instance according to the schema
518 * @throws org.exolab.castor.xml.MarshalException
519 * if object is null or if any SAXException is thrown during
522 public void marshal(final org.xml.sax.ContentHandler handler)
523 throws java.io.IOException,
524 org.exolab.castor.xml.MarshalException,
525 org.exolab.castor.xml.ValidationException
527 Marshaller.marshal(this, handler);
531 * Method removeAlcodonFrame.
533 * @param vAlcodonFrame
534 * @return true if the object was removed from the collection.
536 public boolean removeAlcodonFrame(
537 final jalview.schemabinding.version2.AlcodonFrame vAlcodonFrame)
539 boolean removed = _alcodonFrameList.remove(vAlcodonFrame);
544 * Method removeAlcodonFrameAt.
547 * @return the element removed from the collection
549 public jalview.schemabinding.version2.AlcodonFrame removeAlcodonFrameAt(
552 java.lang.Object obj = this._alcodonFrameList.remove(index);
553 return (jalview.schemabinding.version2.AlcodonFrame) obj;
558 public void removeAllAlcodonFrame()
560 this._alcodonFrameList.clear();
565 public void removeAllAnnotation()
567 this._annotationList.clear();
572 public void removeAllSequence()
574 this._sequenceList.clear();
579 public void removeAllSequenceSetProperties()
581 this._sequenceSetPropertiesList.clear();
585 * Method removeAnnotation.
588 * @return true if the object was removed from the collection.
590 public boolean removeAnnotation(
591 final jalview.schemabinding.version2.Annotation vAnnotation)
593 boolean removed = _annotationList.remove(vAnnotation);
598 * Method removeAnnotationAt.
601 * @return the element removed from the collection
603 public jalview.schemabinding.version2.Annotation removeAnnotationAt(
606 java.lang.Object obj = this._annotationList.remove(index);
607 return (jalview.schemabinding.version2.Annotation) obj;
611 * Method removeSequence.
614 * @return true if the object was removed from the collection.
616 public boolean removeSequence(
617 final jalview.schemabinding.version2.Sequence vSequence)
619 boolean removed = _sequenceList.remove(vSequence);
624 * Method removeSequenceAt.
627 * @return the element removed from the collection
629 public jalview.schemabinding.version2.Sequence removeSequenceAt(
632 java.lang.Object obj = this._sequenceList.remove(index);
633 return (jalview.schemabinding.version2.Sequence) obj;
637 * Method removeSequenceSetProperties.
639 * @param vSequenceSetProperties
640 * @return true if the object was removed from the collection.
642 public boolean removeSequenceSetProperties(
643 final jalview.schemabinding.version2.SequenceSetProperties vSequenceSetProperties)
645 boolean removed = _sequenceSetPropertiesList
646 .remove(vSequenceSetProperties);
651 * Method removeSequenceSetPropertiesAt.
654 * @return the element removed from the collection
656 public jalview.schemabinding.version2.SequenceSetProperties removeSequenceSetPropertiesAt(
659 java.lang.Object obj = this._sequenceSetPropertiesList.remove(index);
660 return (jalview.schemabinding.version2.SequenceSetProperties) obj;
667 * @param vAlcodonFrame
668 * @throws java.lang.IndexOutOfBoundsException
669 * if the index given is outside the bounds of the collection
671 public void setAlcodonFrame(final int index,
672 final jalview.schemabinding.version2.AlcodonFrame vAlcodonFrame)
673 throws java.lang.IndexOutOfBoundsException
675 // check bounds for index
676 if (index < 0 || index >= this._alcodonFrameList.size())
678 throw new IndexOutOfBoundsException("setAlcodonFrame: Index value '"
679 + index + "' not in range [0.."
680 + (this._alcodonFrameList.size() - 1) + "]");
683 this._alcodonFrameList.set(index, vAlcodonFrame);
689 * @param vAlcodonFrameArray
691 public void setAlcodonFrame(
692 final jalview.schemabinding.version2.AlcodonFrame[] vAlcodonFrameArray)
695 _alcodonFrameList.clear();
697 for (int i = 0; i < vAlcodonFrameArray.length; i++)
699 this._alcodonFrameList.add(vAlcodonFrameArray[i]);
708 * @throws java.lang.IndexOutOfBoundsException
709 * if the index given is outside the bounds of the collection
711 public void setAnnotation(final int index,
712 final jalview.schemabinding.version2.Annotation vAnnotation)
713 throws java.lang.IndexOutOfBoundsException
715 // check bounds for index
716 if (index < 0 || index >= this._annotationList.size())
718 throw new IndexOutOfBoundsException("setAnnotation: Index value '"
719 + index + "' not in range [0.."
720 + (this._annotationList.size() - 1) + "]");
723 this._annotationList.set(index, vAnnotation);
729 * @param vAnnotationArray
731 public void setAnnotation(
732 final jalview.schemabinding.version2.Annotation[] vAnnotationArray)
735 _annotationList.clear();
737 for (int i = 0; i < vAnnotationArray.length; i++)
739 this._annotationList.add(vAnnotationArray[i]);
744 * Sets the value of field 'datasetId'. The field 'datasetId' has the
745 * following description: reference to set where jalview will gather the
746 * dataset sequences for all sequences in the set.
750 * the value of field 'datasetId'.
752 public void setDatasetId(final java.lang.String datasetId)
754 this._datasetId = datasetId;
758 * Sets the value of field 'gapChar'.
761 * the value of field 'gapChar'.
763 public void setGapChar(final java.lang.String gapChar)
765 this._gapChar = gapChar;
773 * @throws java.lang.IndexOutOfBoundsException
774 * if the index given is outside the bounds of the collection
776 public void setSequence(final int index,
777 final jalview.schemabinding.version2.Sequence vSequence)
778 throws java.lang.IndexOutOfBoundsException
780 // check bounds for index
781 if (index < 0 || index >= this._sequenceList.size())
783 throw new IndexOutOfBoundsException("setSequence: Index value '"
784 + index + "' not in range [0.."
785 + (this._sequenceList.size() - 1) + "]");
788 this._sequenceList.set(index, vSequence);
794 * @param vSequenceArray
796 public void setSequence(
797 final jalview.schemabinding.version2.Sequence[] vSequenceArray)
800 _sequenceList.clear();
802 for (int i = 0; i < vSequenceArray.length; i++)
804 this._sequenceList.add(vSequenceArray[i]);
812 * @param vSequenceSetProperties
813 * @throws java.lang.IndexOutOfBoundsException
814 * if the index given is outside the bounds of the collection
816 public void setSequenceSetProperties(
818 final jalview.schemabinding.version2.SequenceSetProperties vSequenceSetProperties)
819 throws java.lang.IndexOutOfBoundsException
821 // check bounds for index
822 if (index < 0 || index >= this._sequenceSetPropertiesList.size())
824 throw new IndexOutOfBoundsException(
825 "setSequenceSetProperties: Index value '" + index
826 + "' not in range [0.."
827 + (this._sequenceSetPropertiesList.size() - 1) + "]");
830 this._sequenceSetPropertiesList.set(index, vSequenceSetProperties);
836 * @param vSequenceSetPropertiesArray
838 public void setSequenceSetProperties(
839 final jalview.schemabinding.version2.SequenceSetProperties[] vSequenceSetPropertiesArray)
842 _sequenceSetPropertiesList.clear();
844 for (int i = 0; i < vSequenceSetPropertiesArray.length; i++)
846 this._sequenceSetPropertiesList.add(vSequenceSetPropertiesArray[i]);
854 * @throws org.exolab.castor.xml.MarshalException
855 * if object is null or if any SAXException is thrown during
857 * @throws org.exolab.castor.xml.ValidationException
858 * if this object is an invalid instance according to the schema
859 * @return the unmarshaled jalview.schemabinding.version2.SequenceSet
861 public static jalview.schemabinding.version2.SequenceSet unmarshal(
862 final java.io.Reader reader)
863 throws org.exolab.castor.xml.MarshalException,
864 org.exolab.castor.xml.ValidationException
866 return (jalview.schemabinding.version2.SequenceSet) Unmarshaller
867 .unmarshal(jalview.schemabinding.version2.SequenceSet.class,
874 * @throws org.exolab.castor.xml.ValidationException
875 * if this object is an invalid instance according to the schema
877 public void validate() throws org.exolab.castor.xml.ValidationException
879 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
880 validator.validate(this);