2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ 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 jalview.util.MessageManager;
29 import org.exolab.castor.xml.Marshaller;
30 import org.exolab.castor.xml.Unmarshaller;
35 * @version $Revision$ $Date$
37 public class SequenceSet implements java.io.Serializable
40 // --------------------------/
41 // - Class/Member Variables -/
42 // --------------------------/
47 private java.lang.String _gapChar;
50 * reference to set where jalview will gather the dataset sequences for all
51 * sequences in the set.
54 private java.lang.String _datasetId;
57 * Field _sequenceList.
59 private java.util.Vector _sequenceList;
62 * Field _annotationList.
64 private java.util.Vector _annotationList;
67 * Field _sequenceSetPropertiesList.
69 private java.util.Vector _sequenceSetPropertiesList;
72 * Field _alcodonFrameList.
74 private java.util.Vector _alcodonFrameList;
83 this._sequenceList = new java.util.Vector();
84 this._annotationList = new java.util.Vector();
85 this._sequenceSetPropertiesList = new java.util.Vector();
86 this._alcodonFrameList = new java.util.Vector();
96 * @param vAlcodonFrame
97 * @throws java.lang.IndexOutOfBoundsException
98 * if the index given is outside the bounds of the collection
100 public void addAlcodonFrame(
101 final jalview.schemabinding.version2.AlcodonFrame vAlcodonFrame)
102 throws java.lang.IndexOutOfBoundsException
104 this._alcodonFrameList.addElement(vAlcodonFrame);
111 * @param vAlcodonFrame
112 * @throws java.lang.IndexOutOfBoundsException
113 * if the index given is outside the bounds of the collection
115 public void addAlcodonFrame(final int index,
116 final jalview.schemabinding.version2.AlcodonFrame vAlcodonFrame)
117 throws java.lang.IndexOutOfBoundsException
119 this._alcodonFrameList.add(index, vAlcodonFrame);
126 * @throws java.lang.IndexOutOfBoundsException
127 * if the index given is outside the bounds of the collection
129 public void addAnnotation(
130 final jalview.schemabinding.version2.Annotation vAnnotation)
131 throws java.lang.IndexOutOfBoundsException
133 this._annotationList.addElement(vAnnotation);
141 * @throws java.lang.IndexOutOfBoundsException
142 * if the index given is outside the bounds of the collection
144 public void addAnnotation(final int index,
145 final jalview.schemabinding.version2.Annotation vAnnotation)
146 throws java.lang.IndexOutOfBoundsException
148 this._annotationList.add(index, vAnnotation);
155 * @throws java.lang.IndexOutOfBoundsException
156 * if the index given is outside the bounds of the collection
158 public void addSequence(
159 final jalview.schemabinding.version2.Sequence vSequence)
160 throws java.lang.IndexOutOfBoundsException
162 this._sequenceList.addElement(vSequence);
170 * @throws java.lang.IndexOutOfBoundsException
171 * if the index given is outside the bounds of the collection
173 public void addSequence(final int index,
174 final jalview.schemabinding.version2.Sequence vSequence)
175 throws java.lang.IndexOutOfBoundsException
177 this._sequenceList.add(index, vSequence);
183 * @param vSequenceSetProperties
184 * @throws java.lang.IndexOutOfBoundsException
185 * if the index given is outside the bounds of the collection
187 public void addSequenceSetProperties(
188 final jalview.schemabinding.version2.SequenceSetProperties vSequenceSetProperties)
189 throws java.lang.IndexOutOfBoundsException
191 this._sequenceSetPropertiesList.addElement(vSequenceSetProperties);
198 * @param vSequenceSetProperties
199 * @throws java.lang.IndexOutOfBoundsException
200 * if the index given is outside the bounds of the collection
202 public void addSequenceSetProperties(
204 final jalview.schemabinding.version2.SequenceSetProperties vSequenceSetProperties)
205 throws java.lang.IndexOutOfBoundsException
207 this._sequenceSetPropertiesList.add(index, vSequenceSetProperties);
211 * Method enumerateAlcodonFrame.
213 * @return an Enumeration over all jalview.schemabinding.version2.AlcodonFrame
216 public java.util.Enumeration enumerateAlcodonFrame()
218 return this._alcodonFrameList.elements();
222 * Method enumerateAnnotation.
224 * @return an Enumeration over all jalview.schemabinding.version2.Annotation
227 public java.util.Enumeration enumerateAnnotation()
229 return this._annotationList.elements();
233 * Method enumerateSequence.
235 * @return an Enumeration over all jalview.schemabinding.version2.Sequence
238 public java.util.Enumeration enumerateSequence()
240 return this._sequenceList.elements();
244 * Method enumerateSequenceSetProperties.
246 * @return an Enumeration over all
247 * jalview.schemabinding.version2.SequenceSetProperties elements
249 public java.util.Enumeration enumerateSequenceSetProperties()
251 return this._sequenceSetPropertiesList.elements();
255 * Method getAlcodonFrame.
258 * @throws java.lang.IndexOutOfBoundsException
259 * if the index given is outside the bounds of the collection
260 * @return the value of the jalview.schemabinding.version2.AlcodonFrame at the
263 public jalview.schemabinding.version2.AlcodonFrame getAlcodonFrame(
264 final int index) throws java.lang.IndexOutOfBoundsException
266 // check bounds for index
267 if (index < 0 || index >= this._alcodonFrameList.size())
269 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
271 Integer.valueOf(index).toString(),
272 Integer.valueOf((this._alcodonFrameList.size() - 1)).toString()
276 return (jalview.schemabinding.version2.AlcodonFrame) _alcodonFrameList
281 * Method getAlcodonFrame.Returns the contents of the collection in an Array.
283 * Note: Just in case the collection contents are changing in another thread,
284 * we pass a 0-length Array of the correct type into the API call. This way we
285 * <i>know</i> that the Array returned is of exactly the correct length.
287 * @return this collection as an Array
289 public jalview.schemabinding.version2.AlcodonFrame[] getAlcodonFrame()
291 jalview.schemabinding.version2.AlcodonFrame[] array = new jalview.schemabinding.version2.AlcodonFrame[0];
292 return (jalview.schemabinding.version2.AlcodonFrame[]) this._alcodonFrameList
297 * Method getAlcodonFrameCount.
299 * @return the size of this collection
301 public int getAlcodonFrameCount()
303 return this._alcodonFrameList.size();
307 * Method getAnnotation.
310 * @throws java.lang.IndexOutOfBoundsException
311 * if the index given is outside the bounds of the collection
312 * @return the value of the jalview.schemabinding.version2.Annotation at the
315 public jalview.schemabinding.version2.Annotation getAnnotation(
316 final int index) throws java.lang.IndexOutOfBoundsException
318 // check bounds for index
319 if (index < 0 || index >= this._annotationList.size())
321 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
323 Integer.valueOf(index).toString(),
324 Integer.valueOf((this._alcodonFrameList.size() - 1)).toString()
328 return (jalview.schemabinding.version2.Annotation) _annotationList
333 * Method getAnnotation.Returns the contents of the collection in an Array.
335 * Note: Just in case the collection contents are changing in another thread,
336 * we pass a 0-length Array of the correct type into the API call. This way we
337 * <i>know</i> that the Array returned is of exactly the correct length.
339 * @return this collection as an Array
341 public jalview.schemabinding.version2.Annotation[] getAnnotation()
343 jalview.schemabinding.version2.Annotation[] array = new jalview.schemabinding.version2.Annotation[0];
344 return (jalview.schemabinding.version2.Annotation[]) this._annotationList
349 * Method getAnnotationCount.
351 * @return the size of this collection
353 public int getAnnotationCount()
355 return this._annotationList.size();
359 * Returns the value of field 'datasetId'. The field 'datasetId' has the
360 * following description: reference to set where jalview will gather the
361 * dataset sequences for all sequences in the set.
364 * @return the value of field 'DatasetId'.
366 public java.lang.String getDatasetId()
368 return this._datasetId;
372 * Returns the value of field 'gapChar'.
374 * @return the value of field 'GapChar'.
376 public java.lang.String getGapChar()
378 return this._gapChar;
382 * Method getSequence.
385 * @throws java.lang.IndexOutOfBoundsException
386 * if the index given is outside the bounds of the collection
387 * @return the value of the jalview.schemabinding.version2.Sequence at the
390 public jalview.schemabinding.version2.Sequence getSequence(final int index)
391 throws java.lang.IndexOutOfBoundsException
393 // check bounds for index
394 if (index < 0 || index >= this._sequenceList.size())
396 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
398 Integer.valueOf(index).toString(),
399 Integer.valueOf((this._sequenceList.size() - 1)).toString()
403 return (jalview.schemabinding.version2.Sequence) _sequenceList
408 * Method getSequence.Returns the contents of the collection in an Array.
410 * Note: Just in case the collection contents are changing in another thread,
411 * we pass a 0-length Array of the correct type into the API call. This way we
412 * <i>know</i> that the Array returned is of exactly the correct length.
414 * @return this collection as an Array
416 public jalview.schemabinding.version2.Sequence[] getSequence()
418 jalview.schemabinding.version2.Sequence[] array = new jalview.schemabinding.version2.Sequence[0];
419 return (jalview.schemabinding.version2.Sequence[]) this._sequenceList
424 * Method getSequenceCount.
426 * @return the size of this collection
428 public int getSequenceCount()
430 return this._sequenceList.size();
434 * Method getSequenceSetProperties.
437 * @throws java.lang.IndexOutOfBoundsException
438 * if the index given is outside the bounds of the collection
439 * @return the value of the
440 * jalview.schemabinding.version2.SequenceSetProperties at the given
443 public jalview.schemabinding.version2.SequenceSetProperties getSequenceSetProperties(
444 final int index) throws java.lang.IndexOutOfBoundsException
446 // check bounds for index
447 if (index < 0 || index >= this._sequenceSetPropertiesList.size())
449 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
450 "getSequenceSetProperties",
451 Integer.valueOf(index).toString(),
452 Integer.valueOf((this._sequenceSetPropertiesList.size() - 1)).toString()
456 return (jalview.schemabinding.version2.SequenceSetProperties) _sequenceSetPropertiesList
461 * Method getSequenceSetProperties.Returns the contents of the collection in
464 * Note: Just in case the collection contents are changing in another thread,
465 * we pass a 0-length Array of the correct type into the API call. This way we
466 * <i>know</i> that the Array returned is of exactly the correct length.
468 * @return this collection as an Array
470 public jalview.schemabinding.version2.SequenceSetProperties[] getSequenceSetProperties()
472 jalview.schemabinding.version2.SequenceSetProperties[] array = new jalview.schemabinding.version2.SequenceSetProperties[0];
473 return (jalview.schemabinding.version2.SequenceSetProperties[]) this._sequenceSetPropertiesList
478 * Method getSequenceSetPropertiesCount.
480 * @return the size of this collection
482 public int getSequenceSetPropertiesCount()
484 return this._sequenceSetPropertiesList.size();
490 * @return true if this object is valid according to the schema
492 public boolean isValid()
497 } catch (org.exolab.castor.xml.ValidationException vex)
508 * @throws org.exolab.castor.xml.MarshalException
509 * if object is null or if any SAXException is thrown during
511 * @throws org.exolab.castor.xml.ValidationException
512 * if this object is an invalid instance according to the schema
514 public void marshal(final java.io.Writer out)
515 throws org.exolab.castor.xml.MarshalException,
516 org.exolab.castor.xml.ValidationException
518 Marshaller.marshal(this, out);
525 * @throws java.io.IOException
526 * if an IOException occurs during marshaling
527 * @throws org.exolab.castor.xml.ValidationException
528 * if this object is an invalid instance according to the schema
529 * @throws org.exolab.castor.xml.MarshalException
530 * if object is null or if any SAXException is thrown during
533 public void marshal(final org.xml.sax.ContentHandler handler)
534 throws java.io.IOException,
535 org.exolab.castor.xml.MarshalException,
536 org.exolab.castor.xml.ValidationException
538 Marshaller.marshal(this, handler);
542 * Method removeAlcodonFrame.
544 * @param vAlcodonFrame
545 * @return true if the object was removed from the collection.
547 public boolean removeAlcodonFrame(
548 final jalview.schemabinding.version2.AlcodonFrame vAlcodonFrame)
550 boolean removed = _alcodonFrameList.remove(vAlcodonFrame);
555 * Method removeAlcodonFrameAt.
558 * @return the element removed from the collection
560 public jalview.schemabinding.version2.AlcodonFrame removeAlcodonFrameAt(
563 java.lang.Object obj = this._alcodonFrameList.remove(index);
564 return (jalview.schemabinding.version2.AlcodonFrame) obj;
569 public void removeAllAlcodonFrame()
571 this._alcodonFrameList.clear();
576 public void removeAllAnnotation()
578 this._annotationList.clear();
583 public void removeAllSequence()
585 this._sequenceList.clear();
590 public void removeAllSequenceSetProperties()
592 this._sequenceSetPropertiesList.clear();
596 * Method removeAnnotation.
599 * @return true if the object was removed from the collection.
601 public boolean removeAnnotation(
602 final jalview.schemabinding.version2.Annotation vAnnotation)
604 boolean removed = _annotationList.remove(vAnnotation);
609 * Method removeAnnotationAt.
612 * @return the element removed from the collection
614 public jalview.schemabinding.version2.Annotation removeAnnotationAt(
617 java.lang.Object obj = this._annotationList.remove(index);
618 return (jalview.schemabinding.version2.Annotation) obj;
622 * Method removeSequence.
625 * @return true if the object was removed from the collection.
627 public boolean removeSequence(
628 final jalview.schemabinding.version2.Sequence vSequence)
630 boolean removed = _sequenceList.remove(vSequence);
635 * Method removeSequenceAt.
638 * @return the element removed from the collection
640 public jalview.schemabinding.version2.Sequence removeSequenceAt(
643 java.lang.Object obj = this._sequenceList.remove(index);
644 return (jalview.schemabinding.version2.Sequence) obj;
648 * Method removeSequenceSetProperties.
650 * @param vSequenceSetProperties
651 * @return true if the object was removed from the collection.
653 public boolean removeSequenceSetProperties(
654 final jalview.schemabinding.version2.SequenceSetProperties vSequenceSetProperties)
656 boolean removed = _sequenceSetPropertiesList
657 .remove(vSequenceSetProperties);
662 * Method removeSequenceSetPropertiesAt.
665 * @return the element removed from the collection
667 public jalview.schemabinding.version2.SequenceSetProperties removeSequenceSetPropertiesAt(
670 java.lang.Object obj = this._sequenceSetPropertiesList.remove(index);
671 return (jalview.schemabinding.version2.SequenceSetProperties) obj;
678 * @param vAlcodonFrame
679 * @throws java.lang.IndexOutOfBoundsException
680 * if the index given is outside the bounds of the collection
682 public void setAlcodonFrame(final int index,
683 final jalview.schemabinding.version2.AlcodonFrame vAlcodonFrame)
684 throws java.lang.IndexOutOfBoundsException
686 // check bounds for index
687 if (index < 0 || index >= this._alcodonFrameList.size())
689 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
691 Integer.valueOf(index).toString(),
692 Integer.valueOf((this._alcodonFrameList.size() - 1)).toString()
696 this._alcodonFrameList.set(index, vAlcodonFrame);
702 * @param vAlcodonFrameArray
704 public void setAlcodonFrame(
705 final jalview.schemabinding.version2.AlcodonFrame[] vAlcodonFrameArray)
708 _alcodonFrameList.clear();
710 for (int i = 0; i < vAlcodonFrameArray.length; i++)
712 this._alcodonFrameList.add(vAlcodonFrameArray[i]);
721 * @throws java.lang.IndexOutOfBoundsException
722 * if the index given is outside the bounds of the collection
724 public void setAnnotation(final int index,
725 final jalview.schemabinding.version2.Annotation vAnnotation)
726 throws java.lang.IndexOutOfBoundsException
728 // check bounds for index
729 if (index < 0 || index >= this._annotationList.size())
731 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
733 Integer.valueOf(index).toString(),
734 Integer.valueOf((this._annotationList.size() - 1)).toString()
738 this._annotationList.set(index, vAnnotation);
744 * @param vAnnotationArray
746 public void setAnnotation(
747 final jalview.schemabinding.version2.Annotation[] vAnnotationArray)
750 _annotationList.clear();
752 for (int i = 0; i < vAnnotationArray.length; i++)
754 this._annotationList.add(vAnnotationArray[i]);
759 * Sets the value of field 'datasetId'. The field 'datasetId' has the
760 * following description: reference to set where jalview will gather the
761 * dataset sequences for all sequences in the set.
765 * the value of field 'datasetId'.
767 public void setDatasetId(final java.lang.String datasetId)
769 this._datasetId = datasetId;
773 * Sets the value of field 'gapChar'.
776 * the value of field 'gapChar'.
778 public void setGapChar(final java.lang.String gapChar)
780 this._gapChar = gapChar;
788 * @throws java.lang.IndexOutOfBoundsException
789 * if the index given is outside the bounds of the collection
791 public void setSequence(final int index,
792 final jalview.schemabinding.version2.Sequence vSequence)
793 throws java.lang.IndexOutOfBoundsException
795 // check bounds for index
796 if (index < 0 || index >= this._sequenceList.size())
798 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
800 Integer.valueOf(index).toString(),
801 Integer.valueOf((this._sequenceList.size() - 1)).toString()
805 this._sequenceList.set(index, vSequence);
811 * @param vSequenceArray
813 public void setSequence(
814 final jalview.schemabinding.version2.Sequence[] vSequenceArray)
817 _sequenceList.clear();
819 for (int i = 0; i < vSequenceArray.length; i++)
821 this._sequenceList.add(vSequenceArray[i]);
829 * @param vSequenceSetProperties
830 * @throws java.lang.IndexOutOfBoundsException
831 * if the index given is outside the bounds of the collection
833 public void setSequenceSetProperties(
835 final jalview.schemabinding.version2.SequenceSetProperties vSequenceSetProperties)
836 throws java.lang.IndexOutOfBoundsException
838 // check bounds for index
839 if (index < 0 || index >= this._sequenceSetPropertiesList.size())
841 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
842 "setSequenceSetProperties",
843 Integer.valueOf(index).toString(),
844 Integer.valueOf((this._sequenceSetPropertiesList.size() - 1)).toString()
848 this._sequenceSetPropertiesList.set(index, vSequenceSetProperties);
854 * @param vSequenceSetPropertiesArray
856 public void setSequenceSetProperties(
857 final jalview.schemabinding.version2.SequenceSetProperties[] vSequenceSetPropertiesArray)
860 _sequenceSetPropertiesList.clear();
862 for (int i = 0; i < vSequenceSetPropertiesArray.length; i++)
864 this._sequenceSetPropertiesList.add(vSequenceSetPropertiesArray[i]);
872 * @throws org.exolab.castor.xml.MarshalException
873 * if object is null or if any SAXException is thrown during
875 * @throws org.exolab.castor.xml.ValidationException
876 * if this object is an invalid instance according to the schema
877 * @return the unmarshaled jalview.schemabinding.version2.SequenceSet
879 public static jalview.schemabinding.version2.SequenceSet unmarshal(
880 final java.io.Reader reader)
881 throws org.exolab.castor.xml.MarshalException,
882 org.exolab.castor.xml.ValidationException
884 return (jalview.schemabinding.version2.SequenceSet) Unmarshaller
885 .unmarshal(jalview.schemabinding.version2.SequenceSet.class,
892 * @throws org.exolab.castor.xml.ValidationException
893 * if this object is an invalid instance according to the schema
895 public void validate() throws org.exolab.castor.xml.ValidationException
897 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
898 validator.validate(this);