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;
29 * Class JalviewModelSequence.
31 * @version $Revision$ $Date$
33 public class JalviewModelSequence implements java.io.Serializable
36 // --------------------------/
37 // - Class/Member Variables -/
38 // --------------------------/
43 private java.util.Vector _JSeqList;
48 private java.util.Vector _JGroupList;
51 * Field _viewportList.
53 private java.util.Vector _viewportList;
56 * Field _userColoursList.
58 private java.util.Vector _userColoursList;
63 private java.util.Vector _treeList;
66 * Field _featureSettings.
68 private jalview.schemabinding.version2.FeatureSettings _featureSettings;
74 public JalviewModelSequence()
77 this._JSeqList = new java.util.Vector();
78 this._JGroupList = new java.util.Vector();
79 this._viewportList = new java.util.Vector();
80 this._userColoursList = new java.util.Vector();
81 this._treeList = new java.util.Vector();
92 * @throws java.lang.IndexOutOfBoundsException
93 * if the index given is outside the bounds of the collection
95 public void addJGroup(final jalview.schemabinding.version2.JGroup vJGroup)
96 throws java.lang.IndexOutOfBoundsException
98 this._JGroupList.addElement(vJGroup);
106 * @throws java.lang.IndexOutOfBoundsException
107 * if the index given is outside the bounds of the collection
109 public void addJGroup(final int index,
110 final jalview.schemabinding.version2.JGroup vJGroup)
111 throws java.lang.IndexOutOfBoundsException
113 this._JGroupList.add(index, vJGroup);
120 * @throws java.lang.IndexOutOfBoundsException
121 * if the index given is outside the bounds of the collection
123 public void addJSeq(final jalview.schemabinding.version2.JSeq vJSeq)
124 throws java.lang.IndexOutOfBoundsException
126 this._JSeqList.addElement(vJSeq);
134 * @throws java.lang.IndexOutOfBoundsException
135 * if the index given is outside the bounds of the collection
137 public void addJSeq(final int index,
138 final jalview.schemabinding.version2.JSeq vJSeq)
139 throws java.lang.IndexOutOfBoundsException
141 this._JSeqList.add(index, vJSeq);
148 * @throws java.lang.IndexOutOfBoundsException
149 * if the index given is outside the bounds of the collection
151 public void addTree(final jalview.schemabinding.version2.Tree vTree)
152 throws java.lang.IndexOutOfBoundsException
154 this._treeList.addElement(vTree);
162 * @throws java.lang.IndexOutOfBoundsException
163 * if the index given is outside the bounds of the collection
165 public void addTree(final int index,
166 final jalview.schemabinding.version2.Tree vTree)
167 throws java.lang.IndexOutOfBoundsException
169 this._treeList.add(index, vTree);
175 * @param vUserColours
176 * @throws java.lang.IndexOutOfBoundsException
177 * if the index given is outside the bounds of the collection
179 public void addUserColours(
180 final jalview.schemabinding.version2.UserColours vUserColours)
181 throws java.lang.IndexOutOfBoundsException
183 this._userColoursList.addElement(vUserColours);
190 * @param vUserColours
191 * @throws java.lang.IndexOutOfBoundsException
192 * if the index given is outside the bounds of the collection
194 public void addUserColours(final int index,
195 final jalview.schemabinding.version2.UserColours vUserColours)
196 throws java.lang.IndexOutOfBoundsException
198 this._userColoursList.add(index, vUserColours);
205 * @throws java.lang.IndexOutOfBoundsException
206 * if the index given is outside the bounds of the collection
208 public void addViewport(
209 final jalview.schemabinding.version2.Viewport vViewport)
210 throws java.lang.IndexOutOfBoundsException
212 this._viewportList.addElement(vViewport);
220 * @throws java.lang.IndexOutOfBoundsException
221 * if the index given is outside the bounds of the collection
223 public void addViewport(final int index,
224 final jalview.schemabinding.version2.Viewport vViewport)
225 throws java.lang.IndexOutOfBoundsException
227 this._viewportList.add(index, vViewport);
231 * Method enumerateJGroup.
233 * @return an Enumeration over all jalview.schemabinding.version2.JGroup
236 public java.util.Enumeration enumerateJGroup()
238 return this._JGroupList.elements();
242 * Method enumerateJSeq.
244 * @return an Enumeration over all jalview.schemabinding.version2.JSeq
247 public java.util.Enumeration enumerateJSeq()
249 return this._JSeqList.elements();
253 * Method enumerateTree.
255 * @return an Enumeration over all jalview.schemabinding.version2.Tree
258 public java.util.Enumeration enumerateTree()
260 return this._treeList.elements();
264 * Method enumerateUserColours.
266 * @return an Enumeration over all jalview.schemabinding.version2.UserColours
269 public java.util.Enumeration enumerateUserColours()
271 return this._userColoursList.elements();
275 * Method enumerateViewport.
277 * @return an Enumeration over all jalview.schemabinding.version2.Viewport
280 public java.util.Enumeration enumerateViewport()
282 return this._viewportList.elements();
286 * Returns the value of field 'featureSettings'.
288 * @return the value of field 'FeatureSettings'.
290 public jalview.schemabinding.version2.FeatureSettings getFeatureSettings()
292 return this._featureSettings;
299 * @throws java.lang.IndexOutOfBoundsException
300 * if the index given is outside the bounds of the collection
301 * @return the value of the jalview.schemabinding.version2.JGroup at the given
304 public jalview.schemabinding.version2.JGroup getJGroup(final int index)
305 throws java.lang.IndexOutOfBoundsException
307 // check bounds for index
308 if (index < 0 || index >= this._JGroupList.size())
310 throw new IndexOutOfBoundsException("getJGroup: Index value '"
311 + index + "' not in range [0.."
312 + (this._JGroupList.size() - 1) + "]");
315 return (jalview.schemabinding.version2.JGroup) _JGroupList.get(index);
319 * Method getJGroup.Returns the contents of the collection in an Array.
321 * Note: Just in case the collection contents are changing in another thread,
322 * we pass a 0-length Array of the correct type into the API call. This way we
323 * <i>know</i> that the Array returned is of exactly the correct length.
325 * @return this collection as an Array
327 public jalview.schemabinding.version2.JGroup[] getJGroup()
329 jalview.schemabinding.version2.JGroup[] array = new jalview.schemabinding.version2.JGroup[0];
330 return (jalview.schemabinding.version2.JGroup[]) this._JGroupList
335 * Method getJGroupCount.
337 * @return the size of this collection
339 public int getJGroupCount()
341 return this._JGroupList.size();
348 * @throws java.lang.IndexOutOfBoundsException
349 * if the index given is outside the bounds of the collection
350 * @return the value of the jalview.schemabinding.version2.JSeq at the given
353 public jalview.schemabinding.version2.JSeq getJSeq(final int index)
354 throws java.lang.IndexOutOfBoundsException
356 // check bounds for index
357 if (index < 0 || index >= this._JSeqList.size())
359 throw new IndexOutOfBoundsException("getJSeq: Index value '" + index
360 + "' not in range [0.." + (this._JSeqList.size() - 1) + "]");
363 return (jalview.schemabinding.version2.JSeq) _JSeqList.get(index);
367 * Method getJSeq.Returns the contents of the collection in an Array.
369 * Note: Just in case the collection contents are changing in another thread,
370 * we pass a 0-length Array of the correct type into the API call. This way we
371 * <i>know</i> that the Array returned is of exactly the correct length.
373 * @return this collection as an Array
375 public jalview.schemabinding.version2.JSeq[] getJSeq()
377 jalview.schemabinding.version2.JSeq[] array = new jalview.schemabinding.version2.JSeq[0];
378 return (jalview.schemabinding.version2.JSeq[]) this._JSeqList
383 * Method getJSeqCount.
385 * @return the size of this collection
387 public int getJSeqCount()
389 return this._JSeqList.size();
396 * @throws java.lang.IndexOutOfBoundsException
397 * if the index given is outside the bounds of the collection
398 * @return the value of the jalview.schemabinding.version2.Tree at the given
401 public jalview.schemabinding.version2.Tree getTree(final int index)
402 throws java.lang.IndexOutOfBoundsException
404 // check bounds for index
405 if (index < 0 || index >= this._treeList.size())
407 throw new IndexOutOfBoundsException("getTree: Index value '" + index
408 + "' not in range [0.." + (this._treeList.size() - 1) + "]");
411 return (jalview.schemabinding.version2.Tree) _treeList.get(index);
415 * Method getTree.Returns the contents of the collection in an Array.
417 * Note: Just in case the collection contents are changing in another thread,
418 * we pass a 0-length Array of the correct type into the API call. This way we
419 * <i>know</i> that the Array returned is of exactly the correct length.
421 * @return this collection as an Array
423 public jalview.schemabinding.version2.Tree[] getTree()
425 jalview.schemabinding.version2.Tree[] array = new jalview.schemabinding.version2.Tree[0];
426 return (jalview.schemabinding.version2.Tree[]) this._treeList
431 * Method getTreeCount.
433 * @return the size of this collection
435 public int getTreeCount()
437 return this._treeList.size();
441 * Method getUserColours.
444 * @throws java.lang.IndexOutOfBoundsException
445 * if the index given is outside the bounds of the collection
446 * @return the value of the jalview.schemabinding.version2.UserColours at the
449 public jalview.schemabinding.version2.UserColours getUserColours(
450 final int index) throws java.lang.IndexOutOfBoundsException
452 // check bounds for index
453 if (index < 0 || index >= this._userColoursList.size())
455 throw new IndexOutOfBoundsException("getUserColours: Index value '"
456 + index + "' not in range [0.."
457 + (this._userColoursList.size() - 1) + "]");
460 return (jalview.schemabinding.version2.UserColours) _userColoursList
465 * Method getUserColours.Returns the contents of the collection in an Array.
467 * Note: Just in case the collection contents are changing in another thread,
468 * we pass a 0-length Array of the correct type into the API call. This way we
469 * <i>know</i> that the Array returned is of exactly the correct length.
471 * @return this collection as an Array
473 public jalview.schemabinding.version2.UserColours[] getUserColours()
475 jalview.schemabinding.version2.UserColours[] array = new jalview.schemabinding.version2.UserColours[0];
476 return (jalview.schemabinding.version2.UserColours[]) this._userColoursList
481 * Method getUserColoursCount.
483 * @return the size of this collection
485 public int getUserColoursCount()
487 return this._userColoursList.size();
491 * Method getViewport.
494 * @throws java.lang.IndexOutOfBoundsException
495 * if the index given is outside the bounds of the collection
496 * @return the value of the jalview.schemabinding.version2.Viewport at the
499 public jalview.schemabinding.version2.Viewport getViewport(final int index)
500 throws java.lang.IndexOutOfBoundsException
502 // check bounds for index
503 if (index < 0 || index >= this._viewportList.size())
505 throw new IndexOutOfBoundsException("getViewport: Index value '"
506 + index + "' not in range [0.."
507 + (this._viewportList.size() - 1) + "]");
510 return (jalview.schemabinding.version2.Viewport) _viewportList
515 * Method getViewport.Returns the contents of the collection in an Array.
517 * Note: Just in case the collection contents are changing in another thread,
518 * we pass a 0-length Array of the correct type into the API call. This way we
519 * <i>know</i> that the Array returned is of exactly the correct length.
521 * @return this collection as an Array
523 public jalview.schemabinding.version2.Viewport[] getViewport()
525 jalview.schemabinding.version2.Viewport[] array = new jalview.schemabinding.version2.Viewport[0];
526 return (jalview.schemabinding.version2.Viewport[]) this._viewportList
531 * Method getViewportCount.
533 * @return the size of this collection
535 public int getViewportCount()
537 return this._viewportList.size();
543 * @return true if this object is valid according to the schema
545 public boolean isValid()
550 } catch (org.exolab.castor.xml.ValidationException vex)
561 * @throws org.exolab.castor.xml.MarshalException
562 * if object is null or if any SAXException is thrown during
564 * @throws org.exolab.castor.xml.ValidationException
565 * if this object is an invalid instance according to the schema
567 public void marshal(final java.io.Writer out)
568 throws org.exolab.castor.xml.MarshalException,
569 org.exolab.castor.xml.ValidationException
571 Marshaller.marshal(this, out);
578 * @throws java.io.IOException
579 * if an IOException occurs during marshaling
580 * @throws org.exolab.castor.xml.ValidationException
581 * if this object is an invalid instance according to the schema
582 * @throws org.exolab.castor.xml.MarshalException
583 * if object is null or if any SAXException is thrown during
586 public void marshal(final org.xml.sax.ContentHandler handler)
587 throws java.io.IOException,
588 org.exolab.castor.xml.MarshalException,
589 org.exolab.castor.xml.ValidationException
591 Marshaller.marshal(this, handler);
596 public void removeAllJGroup()
598 this._JGroupList.clear();
603 public void removeAllJSeq()
605 this._JSeqList.clear();
610 public void removeAllTree()
612 this._treeList.clear();
617 public void removeAllUserColours()
619 this._userColoursList.clear();
624 public void removeAllViewport()
626 this._viewportList.clear();
630 * Method removeJGroup.
633 * @return true if the object was removed from the collection.
635 public boolean removeJGroup(
636 final jalview.schemabinding.version2.JGroup vJGroup)
638 boolean removed = _JGroupList.remove(vJGroup);
643 * Method removeJGroupAt.
646 * @return the element removed from the collection
648 public jalview.schemabinding.version2.JGroup removeJGroupAt(
651 java.lang.Object obj = this._JGroupList.remove(index);
652 return (jalview.schemabinding.version2.JGroup) obj;
659 * @return true if the object was removed from the collection.
661 public boolean removeJSeq(final jalview.schemabinding.version2.JSeq vJSeq)
663 boolean removed = _JSeqList.remove(vJSeq);
668 * Method removeJSeqAt.
671 * @return the element removed from the collection
673 public jalview.schemabinding.version2.JSeq removeJSeqAt(final int index)
675 java.lang.Object obj = this._JSeqList.remove(index);
676 return (jalview.schemabinding.version2.JSeq) obj;
683 * @return true if the object was removed from the collection.
685 public boolean removeTree(final jalview.schemabinding.version2.Tree vTree)
687 boolean removed = _treeList.remove(vTree);
692 * Method removeTreeAt.
695 * @return the element removed from the collection
697 public jalview.schemabinding.version2.Tree removeTreeAt(final int index)
699 java.lang.Object obj = this._treeList.remove(index);
700 return (jalview.schemabinding.version2.Tree) obj;
704 * Method removeUserColours.
706 * @param vUserColours
707 * @return true if the object was removed from the collection.
709 public boolean removeUserColours(
710 final jalview.schemabinding.version2.UserColours vUserColours)
712 boolean removed = _userColoursList.remove(vUserColours);
717 * Method removeUserColoursAt.
720 * @return the element removed from the collection
722 public jalview.schemabinding.version2.UserColours removeUserColoursAt(
725 java.lang.Object obj = this._userColoursList.remove(index);
726 return (jalview.schemabinding.version2.UserColours) obj;
730 * Method removeViewport.
733 * @return true if the object was removed from the collection.
735 public boolean removeViewport(
736 final jalview.schemabinding.version2.Viewport vViewport)
738 boolean removed = _viewportList.remove(vViewport);
743 * Method removeViewportAt.
746 * @return the element removed from the collection
748 public jalview.schemabinding.version2.Viewport removeViewportAt(
751 java.lang.Object obj = this._viewportList.remove(index);
752 return (jalview.schemabinding.version2.Viewport) obj;
756 * Sets the value of field 'featureSettings'.
758 * @param featureSettings
759 * the value of field 'featureSettings'.
761 public void setFeatureSettings(
762 final jalview.schemabinding.version2.FeatureSettings featureSettings)
764 this._featureSettings = featureSettings;
772 * @throws java.lang.IndexOutOfBoundsException
773 * if the index given is outside the bounds of the collection
775 public void setJGroup(final int index,
776 final jalview.schemabinding.version2.JGroup vJGroup)
777 throws java.lang.IndexOutOfBoundsException
779 // check bounds for index
780 if (index < 0 || index >= this._JGroupList.size())
782 throw new IndexOutOfBoundsException("setJGroup: Index value '"
783 + index + "' not in range [0.."
784 + (this._JGroupList.size() - 1) + "]");
787 this._JGroupList.set(index, vJGroup);
793 * @param vJGroupArray
795 public void setJGroup(
796 final jalview.schemabinding.version2.JGroup[] vJGroupArray)
801 for (int i = 0; i < vJGroupArray.length; i++)
803 this._JGroupList.add(vJGroupArray[i]);
812 * @throws java.lang.IndexOutOfBoundsException
813 * if the index given is outside the bounds of the collection
815 public void setJSeq(final int index,
816 final jalview.schemabinding.version2.JSeq vJSeq)
817 throws java.lang.IndexOutOfBoundsException
819 // check bounds for index
820 if (index < 0 || index >= this._JSeqList.size())
822 throw new IndexOutOfBoundsException("setJSeq: Index value '" + index
823 + "' not in range [0.." + (this._JSeqList.size() - 1) + "]");
826 this._JSeqList.set(index, vJSeq);
834 public void setJSeq(final jalview.schemabinding.version2.JSeq[] vJSeqArray)
839 for (int i = 0; i < vJSeqArray.length; i++)
841 this._JSeqList.add(vJSeqArray[i]);
850 * @throws java.lang.IndexOutOfBoundsException
851 * if the index given is outside the bounds of the collection
853 public void setTree(final int index,
854 final jalview.schemabinding.version2.Tree vTree)
855 throws java.lang.IndexOutOfBoundsException
857 // check bounds for index
858 if (index < 0 || index >= this._treeList.size())
860 throw new IndexOutOfBoundsException("setTree: Index value '" + index
861 + "' not in range [0.." + (this._treeList.size() - 1) + "]");
864 this._treeList.set(index, vTree);
872 public void setTree(final jalview.schemabinding.version2.Tree[] vTreeArray)
877 for (int i = 0; i < vTreeArray.length; i++)
879 this._treeList.add(vTreeArray[i]);
887 * @param vUserColours
888 * @throws java.lang.IndexOutOfBoundsException
889 * if the index given is outside the bounds of the collection
891 public void setUserColours(final int index,
892 final jalview.schemabinding.version2.UserColours vUserColours)
893 throws java.lang.IndexOutOfBoundsException
895 // check bounds for index
896 if (index < 0 || index >= this._userColoursList.size())
898 throw new IndexOutOfBoundsException("setUserColours: Index value '"
899 + index + "' not in range [0.."
900 + (this._userColoursList.size() - 1) + "]");
903 this._userColoursList.set(index, vUserColours);
909 * @param vUserColoursArray
911 public void setUserColours(
912 final jalview.schemabinding.version2.UserColours[] vUserColoursArray)
915 _userColoursList.clear();
917 for (int i = 0; i < vUserColoursArray.length; i++)
919 this._userColoursList.add(vUserColoursArray[i]);
928 * @throws java.lang.IndexOutOfBoundsException
929 * if the index given is outside the bounds of the collection
931 public void setViewport(final int index,
932 final jalview.schemabinding.version2.Viewport vViewport)
933 throws java.lang.IndexOutOfBoundsException
935 // check bounds for index
936 if (index < 0 || index >= this._viewportList.size())
938 throw new IndexOutOfBoundsException("setViewport: Index value '"
939 + index + "' not in range [0.."
940 + (this._viewportList.size() - 1) + "]");
943 this._viewportList.set(index, vViewport);
949 * @param vViewportArray
951 public void setViewport(
952 final jalview.schemabinding.version2.Viewport[] vViewportArray)
955 _viewportList.clear();
957 for (int i = 0; i < vViewportArray.length; i++)
959 this._viewportList.add(vViewportArray[i]);
967 * @throws org.exolab.castor.xml.MarshalException
968 * if object is null or if any SAXException is thrown during
970 * @throws org.exolab.castor.xml.ValidationException
971 * if this object is an invalid instance according to the schema
972 * @return the unmarshaled jalview.schemabinding.version2.JalviewModelSequence
974 public static jalview.schemabinding.version2.JalviewModelSequence unmarshal(
975 final java.io.Reader reader)
976 throws org.exolab.castor.xml.MarshalException,
977 org.exolab.castor.xml.ValidationException
979 return (jalview.schemabinding.version2.JalviewModelSequence) Unmarshaller
981 jalview.schemabinding.version2.JalviewModelSequence.class,
988 * @throws org.exolab.castor.xml.ValidationException
989 * if this object is an invalid instance according to the schema
991 public void validate() throws org.exolab.castor.xml.ValidationException
993 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
994 validator.validate(this);