2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.5)
\r
3 * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
\r
5 * This file is part of Jalview.
\r
7 * Jalview is free software: you can redistribute it and/or
\r
8 * modify it under the terms of the GNU General Public License
\r
9 * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
\r
11 * Jalview is distributed in the hope that it will be useful, but
\r
12 * WITHOUT ANY WARRANTY; without even the implied warranty
\r
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
\r
14 * PURPOSE. See the GNU General Public License for more details.
\r
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
\r
18 package jalview.schemabinding.version2;
\r
20 //---------------------------------/
\r
21 //- Imported classes and packages -/
\r
22 //---------------------------------/
\r
24 import org.exolab.castor.xml.Marshaller;
\r
25 import org.exolab.castor.xml.Unmarshaller;
\r
28 * Class SequenceSet.
\r
30 * @version $Revision$ $Date$
\r
32 public class SequenceSet implements java.io.Serializable
\r
35 // --------------------------/
\r
36 // - Class/Member Variables -/
\r
37 // --------------------------/
\r
42 private java.lang.String _gapChar;
\r
45 * reference to set where jalview will gather the dataset sequences for all
\r
46 * sequences in the set.
\r
49 private java.lang.String _datasetId;
\r
52 * Field _sequenceList.
\r
54 private java.util.Vector _sequenceList;
\r
57 * Field _annotationList.
\r
59 private java.util.Vector _annotationList;
\r
62 * Field _sequenceSetPropertiesList.
\r
64 private java.util.Vector _sequenceSetPropertiesList;
\r
67 * Field _alcodonFrameList.
\r
69 private java.util.Vector _alcodonFrameList;
\r
71 // ----------------/
\r
72 // - Constructors -/
\r
73 // ----------------/
\r
75 public SequenceSet()
\r
78 this._sequenceList = new java.util.Vector();
\r
79 this._annotationList = new java.util.Vector();
\r
80 this._sequenceSetPropertiesList = new java.util.Vector();
\r
81 this._alcodonFrameList = new java.util.Vector();
\r
91 * @param vAlcodonFrame
\r
92 * @throws java.lang.IndexOutOfBoundsException
\r
93 * if the index given is outside the bounds of the collection
\r
95 public void addAlcodonFrame(
\r
96 final jalview.schemabinding.version2.AlcodonFrame vAlcodonFrame)
\r
97 throws java.lang.IndexOutOfBoundsException
\r
99 this._alcodonFrameList.addElement(vAlcodonFrame);
\r
106 * @param vAlcodonFrame
\r
107 * @throws java.lang.IndexOutOfBoundsException
\r
108 * if the index given is outside the bounds of the collection
\r
110 public void addAlcodonFrame(final int index,
\r
111 final jalview.schemabinding.version2.AlcodonFrame vAlcodonFrame)
\r
112 throws java.lang.IndexOutOfBoundsException
\r
114 this._alcodonFrameList.add(index, vAlcodonFrame);
\r
120 * @param vAnnotation
\r
121 * @throws java.lang.IndexOutOfBoundsException
\r
122 * if the index given is outside the bounds of the collection
\r
124 public void addAnnotation(
\r
125 final jalview.schemabinding.version2.Annotation vAnnotation)
\r
126 throws java.lang.IndexOutOfBoundsException
\r
128 this._annotationList.addElement(vAnnotation);
\r
135 * @param vAnnotation
\r
136 * @throws java.lang.IndexOutOfBoundsException
\r
137 * if the index given is outside the bounds of the collection
\r
139 public void addAnnotation(final int index,
\r
140 final jalview.schemabinding.version2.Annotation vAnnotation)
\r
141 throws java.lang.IndexOutOfBoundsException
\r
143 this._annotationList.add(index, vAnnotation);
\r
150 * @throws java.lang.IndexOutOfBoundsException
\r
151 * if the index 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
157 this._sequenceList.addElement(vSequence);
\r
165 * @throws java.lang.IndexOutOfBoundsException
\r
166 * if the index given is outside the bounds of the collection
\r
168 public void addSequence(final int index,
\r
169 final jalview.schemabinding.version2.Sequence vSequence)
\r
170 throws java.lang.IndexOutOfBoundsException
\r
172 this._sequenceList.add(index, vSequence);
\r
178 * @param vSequenceSetProperties
\r
179 * @throws java.lang.IndexOutOfBoundsException
\r
180 * if the index given is outside the bounds of the collection
\r
182 public void addSequenceSetProperties(
\r
183 final jalview.schemabinding.version2.SequenceSetProperties vSequenceSetProperties)
\r
184 throws java.lang.IndexOutOfBoundsException
\r
186 this._sequenceSetPropertiesList.addElement(vSequenceSetProperties);
\r
193 * @param vSequenceSetProperties
\r
194 * @throws java.lang.IndexOutOfBoundsException
\r
195 * if the index given is outside the bounds of the collection
\r
197 public void addSequenceSetProperties(
\r
199 final jalview.schemabinding.version2.SequenceSetProperties vSequenceSetProperties)
\r
200 throws java.lang.IndexOutOfBoundsException
\r
202 this._sequenceSetPropertiesList.add(index, vSequenceSetProperties);
\r
206 * Method enumerateAlcodonFrame.
\r
208 * @return an Enumeration over all jalview.schemabinding.version2.AlcodonFrame
\r
211 public java.util.Enumeration enumerateAlcodonFrame()
\r
213 return this._alcodonFrameList.elements();
\r
217 * Method enumerateAnnotation.
\r
219 * @return an Enumeration over all jalview.schemabinding.version2.Annotation
\r
222 public java.util.Enumeration enumerateAnnotation()
\r
224 return this._annotationList.elements();
\r
228 * Method enumerateSequence.
\r
230 * @return an Enumeration over all jalview.schemabinding.version2.Sequence
\r
233 public java.util.Enumeration enumerateSequence()
\r
235 return this._sequenceList.elements();
\r
239 * Method enumerateSequenceSetProperties.
\r
241 * @return an Enumeration over all
\r
242 * jalview.schemabinding.version2.SequenceSetProperties elements
\r
244 public java.util.Enumeration enumerateSequenceSetProperties()
\r
246 return this._sequenceSetPropertiesList.elements();
\r
250 * Method getAlcodonFrame.
\r
253 * @throws java.lang.IndexOutOfBoundsException
\r
254 * if the index given is outside the bounds of the collection
\r
255 * @return the value of the jalview.schemabinding.version2.AlcodonFrame at the
\r
258 public jalview.schemabinding.version2.AlcodonFrame getAlcodonFrame(
\r
259 final int index) throws java.lang.IndexOutOfBoundsException
\r
261 // check bounds for index
\r
262 if (index < 0 || index >= this._alcodonFrameList.size())
\r
264 throw new IndexOutOfBoundsException("getAlcodonFrame: Index value '"
\r
265 + index + "' not in range [0.."
\r
266 + (this._alcodonFrameList.size() - 1) + "]");
\r
269 return (jalview.schemabinding.version2.AlcodonFrame) _alcodonFrameList
\r
274 * Method getAlcodonFrame.Returns the contents of the collection in an Array.
\r
276 * Note: Just in case the collection contents are changing in another thread,
\r
277 * we pass a 0-length Array of the correct type into the API call. This way we
\r
278 * <i>know</i> that the Array returned is of exactly the correct length.
\r
280 * @return this collection as an Array
\r
282 public jalview.schemabinding.version2.AlcodonFrame[] getAlcodonFrame()
\r
284 jalview.schemabinding.version2.AlcodonFrame[] array = new jalview.schemabinding.version2.AlcodonFrame[0];
\r
285 return (jalview.schemabinding.version2.AlcodonFrame[]) this._alcodonFrameList
\r
290 * Method getAlcodonFrameCount.
\r
292 * @return the size of this collection
\r
294 public int getAlcodonFrameCount()
\r
296 return this._alcodonFrameList.size();
\r
300 * Method getAnnotation.
\r
303 * @throws java.lang.IndexOutOfBoundsException
\r
304 * if the index given is outside the bounds of the collection
\r
305 * @return the value of the jalview.schemabinding.version2.Annotation at the
\r
308 public jalview.schemabinding.version2.Annotation getAnnotation(
\r
309 final int index) throws java.lang.IndexOutOfBoundsException
\r
311 // check bounds for index
\r
312 if (index < 0 || index >= this._annotationList.size())
\r
314 throw new IndexOutOfBoundsException("getAnnotation: Index value '"
\r
315 + index + "' not in range [0.."
\r
316 + (this._annotationList.size() - 1) + "]");
\r
319 return (jalview.schemabinding.version2.Annotation) _annotationList
\r
324 * Method getAnnotation.Returns the contents of the collection in an Array.
\r
326 * Note: Just in case the collection contents are changing in another thread,
\r
327 * we pass a 0-length Array of the correct type into the API call. This way we
\r
328 * <i>know</i> that the Array returned is of exactly the correct length.
\r
330 * @return this collection as an Array
\r
332 public jalview.schemabinding.version2.Annotation[] getAnnotation()
\r
334 jalview.schemabinding.version2.Annotation[] array = new jalview.schemabinding.version2.Annotation[0];
\r
335 return (jalview.schemabinding.version2.Annotation[]) this._annotationList
\r
340 * Method getAnnotationCount.
\r
342 * @return the size of this collection
\r
344 public int getAnnotationCount()
\r
346 return this._annotationList.size();
\r
350 * Returns the value of field 'datasetId'. The field 'datasetId' has the
\r
351 * following description: reference to set where jalview will gather the
\r
352 * dataset sequences for all sequences in the set.
\r
355 * @return the value of field 'DatasetId'.
\r
357 public java.lang.String getDatasetId()
\r
359 return this._datasetId;
\r
363 * Returns the value of field 'gapChar'.
\r
365 * @return the value of field 'GapChar'.
\r
367 public java.lang.String getGapChar()
\r
369 return this._gapChar;
\r
373 * Method getSequence.
\r
376 * @throws java.lang.IndexOutOfBoundsException
\r
377 * if the index given is outside the bounds of the collection
\r
378 * @return the value of the jalview.schemabinding.version2.Sequence at the
\r
381 public jalview.schemabinding.version2.Sequence getSequence(final int index)
\r
382 throws java.lang.IndexOutOfBoundsException
\r
384 // check bounds for index
\r
385 if (index < 0 || index >= this._sequenceList.size())
\r
387 throw new IndexOutOfBoundsException("getSequence: Index value '"
\r
388 + index + "' not in range [0.."
\r
389 + (this._sequenceList.size() - 1) + "]");
\r
392 return (jalview.schemabinding.version2.Sequence) _sequenceList
\r
397 * Method getSequence.Returns the contents of the collection in an Array.
\r
399 * Note: Just in case the collection contents are changing in another thread,
\r
400 * we pass a 0-length Array of the correct type into the API call. This way we
\r
401 * <i>know</i> that the Array returned is of exactly the correct length.
\r
403 * @return this collection as an Array
\r
405 public jalview.schemabinding.version2.Sequence[] getSequence()
\r
407 jalview.schemabinding.version2.Sequence[] array = new jalview.schemabinding.version2.Sequence[0];
\r
408 return (jalview.schemabinding.version2.Sequence[]) this._sequenceList
\r
413 * Method getSequenceCount.
\r
415 * @return the size of this collection
\r
417 public int getSequenceCount()
\r
419 return this._sequenceList.size();
\r
423 * Method getSequenceSetProperties.
\r
426 * @throws java.lang.IndexOutOfBoundsException
\r
427 * if the index given is outside the bounds of the collection
\r
428 * @return the value of the
\r
429 * jalview.schemabinding.version2.SequenceSetProperties at the given
\r
432 public jalview.schemabinding.version2.SequenceSetProperties getSequenceSetProperties(
\r
433 final int index) throws java.lang.IndexOutOfBoundsException
\r
435 // check bounds for index
\r
436 if (index < 0 || index >= this._sequenceSetPropertiesList.size())
\r
438 throw new IndexOutOfBoundsException(
\r
439 "getSequenceSetProperties: Index value '" + index
\r
440 + "' not in range [0.."
\r
441 + (this._sequenceSetPropertiesList.size() - 1) + "]");
\r
444 return (jalview.schemabinding.version2.SequenceSetProperties) _sequenceSetPropertiesList
\r
449 * Method getSequenceSetProperties.Returns the contents of the collection in
\r
452 * Note: Just in case the collection contents are changing in another thread,
\r
453 * we pass a 0-length Array of the correct type into the API call. This way we
\r
454 * <i>know</i> that the Array returned is of exactly the correct length.
\r
456 * @return this collection as an Array
\r
458 public jalview.schemabinding.version2.SequenceSetProperties[] getSequenceSetProperties()
\r
460 jalview.schemabinding.version2.SequenceSetProperties[] array = new jalview.schemabinding.version2.SequenceSetProperties[0];
\r
461 return (jalview.schemabinding.version2.SequenceSetProperties[]) this._sequenceSetPropertiesList
\r
466 * Method getSequenceSetPropertiesCount.
\r
468 * @return the size of this collection
\r
470 public int getSequenceSetPropertiesCount()
\r
472 return this._sequenceSetPropertiesList.size();
\r
478 * @return true if this object is valid according to the schema
\r
480 public boolean isValid()
\r
485 } catch (org.exolab.castor.xml.ValidationException vex)
\r
496 * @throws org.exolab.castor.xml.MarshalException
\r
497 * if object is null or if any SAXException is thrown during
\r
499 * @throws org.exolab.castor.xml.ValidationException
\r
500 * if this object is an invalid instance according to the schema
\r
502 public void marshal(final java.io.Writer out)
\r
503 throws org.exolab.castor.xml.MarshalException,
\r
504 org.exolab.castor.xml.ValidationException
\r
506 Marshaller.marshal(this, out);
\r
513 * @throws java.io.IOException
\r
514 * if an IOException occurs during marshaling
\r
515 * @throws org.exolab.castor.xml.ValidationException
\r
516 * if this object is an invalid instance according to the schema
\r
517 * @throws org.exolab.castor.xml.MarshalException
\r
518 * if object is null or if any SAXException is thrown during
\r
521 public void marshal(final org.xml.sax.ContentHandler handler)
\r
522 throws java.io.IOException,
\r
523 org.exolab.castor.xml.MarshalException,
\r
524 org.exolab.castor.xml.ValidationException
\r
526 Marshaller.marshal(this, handler);
\r
530 * Method removeAlcodonFrame.
\r
532 * @param vAlcodonFrame
\r
533 * @return true if the object was removed from the collection.
\r
535 public boolean removeAlcodonFrame(
\r
536 final jalview.schemabinding.version2.AlcodonFrame vAlcodonFrame)
\r
538 boolean removed = _alcodonFrameList.remove(vAlcodonFrame);
\r
543 * Method removeAlcodonFrameAt.
\r
546 * @return the element removed from the collection
\r
548 public jalview.schemabinding.version2.AlcodonFrame removeAlcodonFrameAt(
\r
551 java.lang.Object obj = this._alcodonFrameList.remove(index);
\r
552 return (jalview.schemabinding.version2.AlcodonFrame) obj;
\r
557 public void removeAllAlcodonFrame()
\r
559 this._alcodonFrameList.clear();
\r
564 public void removeAllAnnotation()
\r
566 this._annotationList.clear();
\r
571 public void removeAllSequence()
\r
573 this._sequenceList.clear();
\r
578 public void removeAllSequenceSetProperties()
\r
580 this._sequenceSetPropertiesList.clear();
\r
584 * Method removeAnnotation.
\r
586 * @param vAnnotation
\r
587 * @return true if the object was removed from the collection.
\r
589 public boolean removeAnnotation(
\r
590 final jalview.schemabinding.version2.Annotation vAnnotation)
\r
592 boolean removed = _annotationList.remove(vAnnotation);
\r
597 * Method removeAnnotationAt.
\r
600 * @return the element removed from the collection
\r
602 public jalview.schemabinding.version2.Annotation removeAnnotationAt(
\r
605 java.lang.Object obj = this._annotationList.remove(index);
\r
606 return (jalview.schemabinding.version2.Annotation) obj;
\r
610 * Method removeSequence.
\r
613 * @return true if the object was removed from the collection.
\r
615 public boolean removeSequence(
\r
616 final jalview.schemabinding.version2.Sequence vSequence)
\r
618 boolean removed = _sequenceList.remove(vSequence);
\r
623 * Method removeSequenceAt.
\r
626 * @return the element removed from the collection
\r
628 public jalview.schemabinding.version2.Sequence removeSequenceAt(
\r
631 java.lang.Object obj = this._sequenceList.remove(index);
\r
632 return (jalview.schemabinding.version2.Sequence) obj;
\r
636 * Method removeSequenceSetProperties.
\r
638 * @param vSequenceSetProperties
\r
639 * @return true if the object was removed from the collection.
\r
641 public boolean removeSequenceSetProperties(
\r
642 final jalview.schemabinding.version2.SequenceSetProperties vSequenceSetProperties)
\r
644 boolean removed = _sequenceSetPropertiesList
\r
645 .remove(vSequenceSetProperties);
\r
650 * Method removeSequenceSetPropertiesAt.
\r
653 * @return the element removed from the collection
\r
655 public jalview.schemabinding.version2.SequenceSetProperties removeSequenceSetPropertiesAt(
\r
658 java.lang.Object obj = this._sequenceSetPropertiesList.remove(index);
\r
659 return (jalview.schemabinding.version2.SequenceSetProperties) obj;
\r
666 * @param vAlcodonFrame
\r
667 * @throws java.lang.IndexOutOfBoundsException
\r
668 * if the index given is outside the bounds of the collection
\r
670 public void setAlcodonFrame(final int index,
\r
671 final jalview.schemabinding.version2.AlcodonFrame vAlcodonFrame)
\r
672 throws java.lang.IndexOutOfBoundsException
\r
674 // check bounds for index
\r
675 if (index < 0 || index >= this._alcodonFrameList.size())
\r
677 throw new IndexOutOfBoundsException("setAlcodonFrame: Index value '"
\r
678 + index + "' not in range [0.."
\r
679 + (this._alcodonFrameList.size() - 1) + "]");
\r
682 this._alcodonFrameList.set(index, vAlcodonFrame);
\r
688 * @param vAlcodonFrameArray
\r
690 public void setAlcodonFrame(
\r
691 final jalview.schemabinding.version2.AlcodonFrame[] vAlcodonFrameArray)
\r
694 _alcodonFrameList.clear();
\r
696 for (int i = 0; i < vAlcodonFrameArray.length; i++)
\r
698 this._alcodonFrameList.add(vAlcodonFrameArray[i]);
\r
706 * @param vAnnotation
\r
707 * @throws java.lang.IndexOutOfBoundsException
\r
708 * if the index given is outside the bounds of the collection
\r
710 public void setAnnotation(final int index,
\r
711 final jalview.schemabinding.version2.Annotation vAnnotation)
\r
712 throws java.lang.IndexOutOfBoundsException
\r
714 // check bounds for index
\r
715 if (index < 0 || index >= this._annotationList.size())
\r
717 throw new IndexOutOfBoundsException("setAnnotation: Index value '"
\r
718 + index + "' not in range [0.."
\r
719 + (this._annotationList.size() - 1) + "]");
\r
722 this._annotationList.set(index, vAnnotation);
\r
728 * @param vAnnotationArray
\r
730 public void setAnnotation(
\r
731 final jalview.schemabinding.version2.Annotation[] vAnnotationArray)
\r
734 _annotationList.clear();
\r
736 for (int i = 0; i < vAnnotationArray.length; i++)
\r
738 this._annotationList.add(vAnnotationArray[i]);
\r
743 * Sets the value of field 'datasetId'. The field 'datasetId' has the
\r
744 * following description: reference to set where jalview will gather the
\r
745 * dataset sequences for all sequences in the set.
\r
749 * the value of field 'datasetId'.
\r
751 public void setDatasetId(final java.lang.String datasetId)
\r
753 this._datasetId = datasetId;
\r
757 * Sets the value of field 'gapChar'.
\r
760 * the value of field 'gapChar'.
\r
762 public void setGapChar(final java.lang.String gapChar)
\r
764 this._gapChar = gapChar;
\r
772 * @throws java.lang.IndexOutOfBoundsException
\r
773 * if the index given is outside the bounds of the collection
\r
775 public void setSequence(final int index,
\r
776 final jalview.schemabinding.version2.Sequence vSequence)
\r
777 throws java.lang.IndexOutOfBoundsException
\r
779 // check bounds for index
\r
780 if (index < 0 || index >= this._sequenceList.size())
\r
782 throw new IndexOutOfBoundsException("setSequence: Index value '"
\r
783 + index + "' not in range [0.."
\r
784 + (this._sequenceList.size() - 1) + "]");
\r
787 this._sequenceList.set(index, vSequence);
\r
793 * @param vSequenceArray
\r
795 public void setSequence(
\r
796 final jalview.schemabinding.version2.Sequence[] vSequenceArray)
\r
799 _sequenceList.clear();
\r
801 for (int i = 0; i < vSequenceArray.length; i++)
\r
803 this._sequenceList.add(vSequenceArray[i]);
\r
811 * @param vSequenceSetProperties
\r
812 * @throws java.lang.IndexOutOfBoundsException
\r
813 * if the index given is outside the bounds of the collection
\r
815 public void setSequenceSetProperties(
\r
817 final jalview.schemabinding.version2.SequenceSetProperties vSequenceSetProperties)
\r
818 throws java.lang.IndexOutOfBoundsException
\r
820 // check bounds for index
\r
821 if (index < 0 || index >= this._sequenceSetPropertiesList.size())
\r
823 throw new IndexOutOfBoundsException(
\r
824 "setSequenceSetProperties: Index value '" + index
\r
825 + "' not in range [0.."
\r
826 + (this._sequenceSetPropertiesList.size() - 1) + "]");
\r
829 this._sequenceSetPropertiesList.set(index, vSequenceSetProperties);
\r
835 * @param vSequenceSetPropertiesArray
\r
837 public void setSequenceSetProperties(
\r
838 final jalview.schemabinding.version2.SequenceSetProperties[] vSequenceSetPropertiesArray)
\r
841 _sequenceSetPropertiesList.clear();
\r
843 for (int i = 0; i < vSequenceSetPropertiesArray.length; i++)
\r
845 this._sequenceSetPropertiesList.add(vSequenceSetPropertiesArray[i]);
\r
850 * Method unmarshal.
\r
853 * @throws org.exolab.castor.xml.MarshalException
\r
854 * if object is null or if any SAXException is thrown during
\r
856 * @throws org.exolab.castor.xml.ValidationException
\r
857 * if this object is an invalid instance according to the schema
\r
858 * @return the unmarshaled jalview.schemabinding.version2.SequenceSet
\r
860 public static jalview.schemabinding.version2.SequenceSet unmarshal(
\r
861 final java.io.Reader reader)
\r
862 throws org.exolab.castor.xml.MarshalException,
\r
863 org.exolab.castor.xml.ValidationException
\r
865 return (jalview.schemabinding.version2.SequenceSet) Unmarshaller
\r
866 .unmarshal(jalview.schemabinding.version2.SequenceSet.class,
\r
873 * @throws org.exolab.castor.xml.ValidationException
\r
874 * if this object is an invalid instance according to the schema
\r
876 public void validate() throws org.exolab.castor.xml.ValidationException
\r
878 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
\r
879 validator.validate(this);
\r