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