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 org.exolab.castor.xml.Marshaller;
28 import org.exolab.castor.xml.Unmarshaller;
33 * @version $Revision$ $Date$
35 public class SequenceSet implements java.io.Serializable
38 // --------------------------/
39 // - Class/Member Variables -/
40 // --------------------------/
45 private java.lang.String _gapChar;
48 * reference to set where jalview will gather the dataset sequences for all
49 * sequences in the set.
52 private java.lang.String _datasetId;
55 * Field _sequenceList.
57 private java.util.Vector _sequenceList;
60 * Field _annotationList.
62 private java.util.Vector _annotationList;
65 * Field _sequenceSetPropertiesList.
67 private java.util.Vector _sequenceSetPropertiesList;
70 * Field _alcodonFrameList.
72 private java.util.Vector _alcodonFrameList;
81 this._sequenceList = new java.util.Vector();
82 this._annotationList = new java.util.Vector();
83 this._sequenceSetPropertiesList = new java.util.Vector();
84 this._alcodonFrameList = new java.util.Vector();
94 * @param vAlcodonFrame
95 * @throws java.lang.IndexOutOfBoundsException
96 * if the index given is outside the bounds of the collection
98 public void addAlcodonFrame(
99 final jalview.schemabinding.version2.AlcodonFrame vAlcodonFrame)
100 throws java.lang.IndexOutOfBoundsException
102 this._alcodonFrameList.addElement(vAlcodonFrame);
109 * @param vAlcodonFrame
110 * @throws java.lang.IndexOutOfBoundsException
111 * if the index given is outside the bounds of the collection
113 public void addAlcodonFrame(final int index,
114 final jalview.schemabinding.version2.AlcodonFrame vAlcodonFrame)
115 throws java.lang.IndexOutOfBoundsException
117 this._alcodonFrameList.add(index, vAlcodonFrame);
124 * @throws java.lang.IndexOutOfBoundsException
125 * if the index given is outside the bounds of the collection
127 public void addAnnotation(
128 final jalview.schemabinding.version2.Annotation vAnnotation)
129 throws java.lang.IndexOutOfBoundsException
131 this._annotationList.addElement(vAnnotation);
139 * @throws java.lang.IndexOutOfBoundsException
140 * if the index given is outside the bounds of the collection
142 public void addAnnotation(final int index,
143 final jalview.schemabinding.version2.Annotation vAnnotation)
144 throws java.lang.IndexOutOfBoundsException
146 this._annotationList.add(index, vAnnotation);
153 * @throws java.lang.IndexOutOfBoundsException
154 * if the index given is outside the bounds of the collection
156 public void addSequence(
157 final jalview.schemabinding.version2.Sequence vSequence)
158 throws java.lang.IndexOutOfBoundsException
160 this._sequenceList.addElement(vSequence);
168 * @throws java.lang.IndexOutOfBoundsException
169 * if the index given is outside the bounds of the collection
171 public void addSequence(final int index,
172 final jalview.schemabinding.version2.Sequence vSequence)
173 throws java.lang.IndexOutOfBoundsException
175 this._sequenceList.add(index, vSequence);
181 * @param vSequenceSetProperties
182 * @throws java.lang.IndexOutOfBoundsException
183 * if the index given is outside the bounds of the collection
185 public void addSequenceSetProperties(
186 final jalview.schemabinding.version2.SequenceSetProperties vSequenceSetProperties)
187 throws java.lang.IndexOutOfBoundsException
189 this._sequenceSetPropertiesList.addElement(vSequenceSetProperties);
196 * @param vSequenceSetProperties
197 * @throws java.lang.IndexOutOfBoundsException
198 * if the index given is outside the bounds of the collection
200 public void addSequenceSetProperties(
202 final jalview.schemabinding.version2.SequenceSetProperties vSequenceSetProperties)
203 throws java.lang.IndexOutOfBoundsException
205 this._sequenceSetPropertiesList.add(index, vSequenceSetProperties);
209 * Method enumerateAlcodonFrame.
211 * @return an Enumeration over all jalview.schemabinding.version2.AlcodonFrame
214 public java.util.Enumeration enumerateAlcodonFrame()
216 return this._alcodonFrameList.elements();
220 * Method enumerateAnnotation.
222 * @return an Enumeration over all jalview.schemabinding.version2.Annotation
225 public java.util.Enumeration enumerateAnnotation()
227 return this._annotationList.elements();
231 * Method enumerateSequence.
233 * @return an Enumeration over all jalview.schemabinding.version2.Sequence
236 public java.util.Enumeration enumerateSequence()
238 return this._sequenceList.elements();
242 * Method enumerateSequenceSetProperties.
244 * @return an Enumeration over all
245 * jalview.schemabinding.version2.SequenceSetProperties elements
247 public java.util.Enumeration enumerateSequenceSetProperties()
249 return this._sequenceSetPropertiesList.elements();
253 * Method getAlcodonFrame.
256 * @throws java.lang.IndexOutOfBoundsException
257 * if the index given is outside the bounds of the collection
258 * @return the value of the jalview.schemabinding.version2.AlcodonFrame at the
261 public jalview.schemabinding.version2.AlcodonFrame getAlcodonFrame(
262 final int index) throws java.lang.IndexOutOfBoundsException
264 // check bounds for index
265 if (index < 0 || index >= this._alcodonFrameList.size())
267 throw new IndexOutOfBoundsException("getAlcodonFrame: Index value '"
268 + index + "' not in range [0.."
269 + (this._alcodonFrameList.size() - 1) + "]");
272 return (jalview.schemabinding.version2.AlcodonFrame) _alcodonFrameList
277 * Method getAlcodonFrame.Returns the contents of the collection in an Array.
279 * Note: Just in case the collection contents are changing in another thread,
280 * we pass a 0-length Array of the correct type into the API call. This way we
281 * <i>know</i> that the Array returned is of exactly the correct length.
283 * @return this collection as an Array
285 public jalview.schemabinding.version2.AlcodonFrame[] getAlcodonFrame()
287 jalview.schemabinding.version2.AlcodonFrame[] array = new jalview.schemabinding.version2.AlcodonFrame[0];
288 return (jalview.schemabinding.version2.AlcodonFrame[]) this._alcodonFrameList
293 * Method getAlcodonFrameCount.
295 * @return the size of this collection
297 public int getAlcodonFrameCount()
299 return this._alcodonFrameList.size();
303 * Method getAnnotation.
306 * @throws java.lang.IndexOutOfBoundsException
307 * if the index given is outside the bounds of the collection
308 * @return the value of the jalview.schemabinding.version2.Annotation at the
311 public jalview.schemabinding.version2.Annotation getAnnotation(
312 final int index) throws java.lang.IndexOutOfBoundsException
314 // check bounds for index
315 if (index < 0 || index >= this._annotationList.size())
317 throw new IndexOutOfBoundsException("getAnnotation: Index value '"
318 + index + "' not in range [0.."
319 + (this._annotationList.size() - 1) + "]");
322 return (jalview.schemabinding.version2.Annotation) _annotationList
327 * Method getAnnotation.Returns the contents of the collection in an Array.
329 * Note: Just in case the collection contents are changing in another thread,
330 * we pass a 0-length Array of the correct type into the API call. This way we
331 * <i>know</i> that the Array returned is of exactly the correct length.
333 * @return this collection as an Array
335 public jalview.schemabinding.version2.Annotation[] getAnnotation()
337 jalview.schemabinding.version2.Annotation[] array = new jalview.schemabinding.version2.Annotation[0];
338 return (jalview.schemabinding.version2.Annotation[]) this._annotationList
343 * Method getAnnotationCount.
345 * @return the size of this collection
347 public int getAnnotationCount()
349 return this._annotationList.size();
353 * Returns the value of field 'datasetId'. The field 'datasetId' has the
354 * following description: reference to set where jalview will gather the
355 * dataset sequences for all sequences in the set.
358 * @return the value of field 'DatasetId'.
360 public java.lang.String getDatasetId()
362 return this._datasetId;
366 * Returns the value of field 'gapChar'.
368 * @return the value of field 'GapChar'.
370 public java.lang.String getGapChar()
372 return this._gapChar;
376 * Method getSequence.
379 * @throws java.lang.IndexOutOfBoundsException
380 * if the index given is outside the bounds of the collection
381 * @return the value of the jalview.schemabinding.version2.Sequence at the
384 public jalview.schemabinding.version2.Sequence getSequence(final int index)
385 throws java.lang.IndexOutOfBoundsException
387 // check bounds for index
388 if (index < 0 || index >= this._sequenceList.size())
390 throw new IndexOutOfBoundsException("getSequence: Index value '"
391 + index + "' not in range [0.."
392 + (this._sequenceList.size() - 1) + "]");
395 return (jalview.schemabinding.version2.Sequence) _sequenceList
400 * Method getSequence.Returns the contents of the collection in an Array.
402 * Note: Just in case the collection contents are changing in another thread,
403 * we pass a 0-length Array of the correct type into the API call. This way we
404 * <i>know</i> that the Array returned is of exactly the correct length.
406 * @return this collection as an Array
408 public jalview.schemabinding.version2.Sequence[] getSequence()
410 jalview.schemabinding.version2.Sequence[] array = new jalview.schemabinding.version2.Sequence[0];
411 return (jalview.schemabinding.version2.Sequence[]) this._sequenceList
416 * Method getSequenceCount.
418 * @return the size of this collection
420 public int getSequenceCount()
422 return this._sequenceList.size();
426 * Method getSequenceSetProperties.
429 * @throws java.lang.IndexOutOfBoundsException
430 * if the index given is outside the bounds of the collection
431 * @return the value of the
432 * jalview.schemabinding.version2.SequenceSetProperties at the given
435 public jalview.schemabinding.version2.SequenceSetProperties getSequenceSetProperties(
436 final int index) throws java.lang.IndexOutOfBoundsException
438 // check bounds for index
439 if (index < 0 || index >= this._sequenceSetPropertiesList.size())
441 throw new IndexOutOfBoundsException(
442 "getSequenceSetProperties: Index value '" + index
443 + "' not in range [0.."
444 + (this._sequenceSetPropertiesList.size() - 1) + "]");
447 return (jalview.schemabinding.version2.SequenceSetProperties) _sequenceSetPropertiesList
452 * Method getSequenceSetProperties.Returns the contents of the collection in
455 * Note: Just in case the collection contents are changing in another thread,
456 * we pass a 0-length Array of the correct type into the API call. This way we
457 * <i>know</i> that the Array returned is of exactly the correct length.
459 * @return this collection as an Array
461 public jalview.schemabinding.version2.SequenceSetProperties[] getSequenceSetProperties()
463 jalview.schemabinding.version2.SequenceSetProperties[] array = new jalview.schemabinding.version2.SequenceSetProperties[0];
464 return (jalview.schemabinding.version2.SequenceSetProperties[]) this._sequenceSetPropertiesList
469 * Method getSequenceSetPropertiesCount.
471 * @return the size of this collection
473 public int getSequenceSetPropertiesCount()
475 return this._sequenceSetPropertiesList.size();
481 * @return true if this object is valid according to the schema
483 public boolean isValid()
488 } catch (org.exolab.castor.xml.ValidationException vex)
499 * @throws org.exolab.castor.xml.MarshalException
500 * if object is null or if any SAXException is thrown during
502 * @throws org.exolab.castor.xml.ValidationException
503 * if this object is an invalid instance according to the schema
505 public void marshal(final java.io.Writer out)
506 throws org.exolab.castor.xml.MarshalException,
507 org.exolab.castor.xml.ValidationException
509 Marshaller.marshal(this, out);
516 * @throws java.io.IOException
517 * if an IOException occurs during marshaling
518 * @throws org.exolab.castor.xml.ValidationException
519 * if this object is an invalid instance according to the schema
520 * @throws org.exolab.castor.xml.MarshalException
521 * if object is null or if any SAXException is thrown during
524 public void marshal(final org.xml.sax.ContentHandler handler)
525 throws java.io.IOException,
526 org.exolab.castor.xml.MarshalException,
527 org.exolab.castor.xml.ValidationException
529 Marshaller.marshal(this, handler);
533 * Method removeAlcodonFrame.
535 * @param vAlcodonFrame
536 * @return true if the object was removed from the collection.
538 public boolean removeAlcodonFrame(
539 final jalview.schemabinding.version2.AlcodonFrame vAlcodonFrame)
541 boolean removed = _alcodonFrameList.remove(vAlcodonFrame);
546 * Method removeAlcodonFrameAt.
549 * @return the element removed from the collection
551 public jalview.schemabinding.version2.AlcodonFrame removeAlcodonFrameAt(
554 java.lang.Object obj = this._alcodonFrameList.remove(index);
555 return (jalview.schemabinding.version2.AlcodonFrame) obj;
560 public void removeAllAlcodonFrame()
562 this._alcodonFrameList.clear();
567 public void removeAllAnnotation()
569 this._annotationList.clear();
574 public void removeAllSequence()
576 this._sequenceList.clear();
581 public void removeAllSequenceSetProperties()
583 this._sequenceSetPropertiesList.clear();
587 * Method removeAnnotation.
590 * @return true if the object was removed from the collection.
592 public boolean removeAnnotation(
593 final jalview.schemabinding.version2.Annotation vAnnotation)
595 boolean removed = _annotationList.remove(vAnnotation);
600 * Method removeAnnotationAt.
603 * @return the element removed from the collection
605 public jalview.schemabinding.version2.Annotation removeAnnotationAt(
608 java.lang.Object obj = this._annotationList.remove(index);
609 return (jalview.schemabinding.version2.Annotation) obj;
613 * Method removeSequence.
616 * @return true if the object was removed from the collection.
618 public boolean removeSequence(
619 final jalview.schemabinding.version2.Sequence vSequence)
621 boolean removed = _sequenceList.remove(vSequence);
626 * Method removeSequenceAt.
629 * @return the element removed from the collection
631 public jalview.schemabinding.version2.Sequence removeSequenceAt(
634 java.lang.Object obj = this._sequenceList.remove(index);
635 return (jalview.schemabinding.version2.Sequence) obj;
639 * Method removeSequenceSetProperties.
641 * @param vSequenceSetProperties
642 * @return true if the object was removed from the collection.
644 public boolean removeSequenceSetProperties(
645 final jalview.schemabinding.version2.SequenceSetProperties vSequenceSetProperties)
647 boolean removed = _sequenceSetPropertiesList
648 .remove(vSequenceSetProperties);
653 * Method removeSequenceSetPropertiesAt.
656 * @return the element removed from the collection
658 public jalview.schemabinding.version2.SequenceSetProperties removeSequenceSetPropertiesAt(
661 java.lang.Object obj = this._sequenceSetPropertiesList.remove(index);
662 return (jalview.schemabinding.version2.SequenceSetProperties) obj;
669 * @param vAlcodonFrame
670 * @throws java.lang.IndexOutOfBoundsException
671 * if the index given is outside the bounds of the collection
673 public void setAlcodonFrame(final int index,
674 final jalview.schemabinding.version2.AlcodonFrame vAlcodonFrame)
675 throws java.lang.IndexOutOfBoundsException
677 // check bounds for index
678 if (index < 0 || index >= this._alcodonFrameList.size())
680 throw new IndexOutOfBoundsException("setAlcodonFrame: Index value '"
681 + index + "' not in range [0.."
682 + (this._alcodonFrameList.size() - 1) + "]");
685 this._alcodonFrameList.set(index, vAlcodonFrame);
691 * @param vAlcodonFrameArray
693 public void setAlcodonFrame(
694 final jalview.schemabinding.version2.AlcodonFrame[] vAlcodonFrameArray)
697 _alcodonFrameList.clear();
699 for (int i = 0; i < vAlcodonFrameArray.length; i++)
701 this._alcodonFrameList.add(vAlcodonFrameArray[i]);
710 * @throws java.lang.IndexOutOfBoundsException
711 * if the index given is outside the bounds of the collection
713 public void setAnnotation(final int index,
714 final jalview.schemabinding.version2.Annotation vAnnotation)
715 throws java.lang.IndexOutOfBoundsException
717 // check bounds for index
718 if (index < 0 || index >= this._annotationList.size())
720 throw new IndexOutOfBoundsException("setAnnotation: Index value '"
721 + index + "' not in range [0.."
722 + (this._annotationList.size() - 1) + "]");
725 this._annotationList.set(index, vAnnotation);
731 * @param vAnnotationArray
733 public void setAnnotation(
734 final jalview.schemabinding.version2.Annotation[] vAnnotationArray)
737 _annotationList.clear();
739 for (int i = 0; i < vAnnotationArray.length; i++)
741 this._annotationList.add(vAnnotationArray[i]);
746 * Sets the value of field 'datasetId'. The field 'datasetId' has the
747 * following description: reference to set where jalview will gather the
748 * dataset sequences for all sequences in the set.
752 * the value of field 'datasetId'.
754 public void setDatasetId(final java.lang.String datasetId)
756 this._datasetId = datasetId;
760 * Sets the value of field 'gapChar'.
763 * the value of field 'gapChar'.
765 public void setGapChar(final java.lang.String gapChar)
767 this._gapChar = gapChar;
775 * @throws java.lang.IndexOutOfBoundsException
776 * if the index given is outside the bounds of the collection
778 public void setSequence(final int index,
779 final jalview.schemabinding.version2.Sequence vSequence)
780 throws java.lang.IndexOutOfBoundsException
782 // check bounds for index
783 if (index < 0 || index >= this._sequenceList.size())
785 throw new IndexOutOfBoundsException("setSequence: Index value '"
786 + index + "' not in range [0.."
787 + (this._sequenceList.size() - 1) + "]");
790 this._sequenceList.set(index, vSequence);
796 * @param vSequenceArray
798 public void setSequence(
799 final jalview.schemabinding.version2.Sequence[] vSequenceArray)
802 _sequenceList.clear();
804 for (int i = 0; i < vSequenceArray.length; i++)
806 this._sequenceList.add(vSequenceArray[i]);
814 * @param vSequenceSetProperties
815 * @throws java.lang.IndexOutOfBoundsException
816 * if the index given is outside the bounds of the collection
818 public void setSequenceSetProperties(
820 final jalview.schemabinding.version2.SequenceSetProperties vSequenceSetProperties)
821 throws java.lang.IndexOutOfBoundsException
823 // check bounds for index
824 if (index < 0 || index >= this._sequenceSetPropertiesList.size())
826 throw new IndexOutOfBoundsException(
827 "setSequenceSetProperties: Index value '" + index
828 + "' not in range [0.."
829 + (this._sequenceSetPropertiesList.size() - 1) + "]");
832 this._sequenceSetPropertiesList.set(index, vSequenceSetProperties);
838 * @param vSequenceSetPropertiesArray
840 public void setSequenceSetProperties(
841 final jalview.schemabinding.version2.SequenceSetProperties[] vSequenceSetPropertiesArray)
844 _sequenceSetPropertiesList.clear();
846 for (int i = 0; i < vSequenceSetPropertiesArray.length; i++)
848 this._sequenceSetPropertiesList.add(vSequenceSetPropertiesArray[i]);
856 * @throws org.exolab.castor.xml.MarshalException
857 * if object is null or if any SAXException is thrown during
859 * @throws org.exolab.castor.xml.ValidationException
860 * if this object is an invalid instance according to the schema
861 * @return the unmarshaled jalview.schemabinding.version2.SequenceSet
863 public static jalview.schemabinding.version2.SequenceSet unmarshal(
864 final java.io.Reader reader)
865 throws org.exolab.castor.xml.MarshalException,
866 org.exolab.castor.xml.ValidationException
868 return (jalview.schemabinding.version2.SequenceSet) Unmarshaller
869 .unmarshal(jalview.schemabinding.version2.SequenceSet.class,
876 * @throws org.exolab.castor.xml.ValidationException
877 * if this object is an invalid instance according to the schema
879 public void validate() throws org.exolab.castor.xml.ValidationException
881 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
882 validator.validate(this);