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;
31 * Class JalviewModelSequence.
33 * @version $Revision$ $Date$
35 public class JalviewModelSequence implements java.io.Serializable
38 // --------------------------/
39 // - Class/Member Variables -/
40 // --------------------------/
45 private java.util.Vector _JSeqList;
50 private java.util.Vector _JGroupList;
53 * Field _viewportList.
55 private java.util.Vector _viewportList;
58 * Field _userColoursList.
60 private java.util.Vector _userColoursList;
65 private java.util.Vector _treeList;
68 * Field _featureSettings.
70 private jalview.schemabinding.version2.FeatureSettings _featureSettings;
76 public JalviewModelSequence()
79 this._JSeqList = new java.util.Vector();
80 this._JGroupList = new java.util.Vector();
81 this._viewportList = new java.util.Vector();
82 this._userColoursList = new java.util.Vector();
83 this._treeList = new java.util.Vector();
94 * @throws java.lang.IndexOutOfBoundsException
95 * if the index given is outside the bounds of the collection
97 public void addJGroup(final jalview.schemabinding.version2.JGroup vJGroup)
98 throws java.lang.IndexOutOfBoundsException
100 this._JGroupList.addElement(vJGroup);
108 * @throws java.lang.IndexOutOfBoundsException
109 * if the index given is outside the bounds of the collection
111 public void addJGroup(final int index,
112 final jalview.schemabinding.version2.JGroup vJGroup)
113 throws java.lang.IndexOutOfBoundsException
115 this._JGroupList.add(index, vJGroup);
122 * @throws java.lang.IndexOutOfBoundsException
123 * if the index given is outside the bounds of the collection
125 public void addJSeq(final jalview.schemabinding.version2.JSeq vJSeq)
126 throws java.lang.IndexOutOfBoundsException
128 this._JSeqList.addElement(vJSeq);
136 * @throws java.lang.IndexOutOfBoundsException
137 * if the index given is outside the bounds of the collection
139 public void addJSeq(final int index,
140 final jalview.schemabinding.version2.JSeq vJSeq)
141 throws java.lang.IndexOutOfBoundsException
143 this._JSeqList.add(index, vJSeq);
150 * @throws java.lang.IndexOutOfBoundsException
151 * if the index given is outside the bounds of the collection
153 public void addTree(final jalview.schemabinding.version2.Tree vTree)
154 throws java.lang.IndexOutOfBoundsException
156 this._treeList.addElement(vTree);
164 * @throws java.lang.IndexOutOfBoundsException
165 * if the index given is outside the bounds of the collection
167 public void addTree(final int index,
168 final jalview.schemabinding.version2.Tree vTree)
169 throws java.lang.IndexOutOfBoundsException
171 this._treeList.add(index, vTree);
177 * @param vUserColours
178 * @throws java.lang.IndexOutOfBoundsException
179 * if the index given is outside the bounds of the collection
181 public void addUserColours(
182 final jalview.schemabinding.version2.UserColours vUserColours)
183 throws java.lang.IndexOutOfBoundsException
185 this._userColoursList.addElement(vUserColours);
192 * @param vUserColours
193 * @throws java.lang.IndexOutOfBoundsException
194 * if the index given is outside the bounds of the collection
196 public void addUserColours(final int index,
197 final jalview.schemabinding.version2.UserColours vUserColours)
198 throws java.lang.IndexOutOfBoundsException
200 this._userColoursList.add(index, vUserColours);
207 * @throws java.lang.IndexOutOfBoundsException
208 * if the index given is outside the bounds of the collection
210 public void addViewport(
211 final jalview.schemabinding.version2.Viewport vViewport)
212 throws java.lang.IndexOutOfBoundsException
214 this._viewportList.addElement(vViewport);
222 * @throws java.lang.IndexOutOfBoundsException
223 * if the index given is outside the bounds of the collection
225 public void addViewport(final int index,
226 final jalview.schemabinding.version2.Viewport vViewport)
227 throws java.lang.IndexOutOfBoundsException
229 this._viewportList.add(index, vViewport);
233 * Method enumerateJGroup.
235 * @return an Enumeration over all jalview.schemabinding.version2.JGroup
238 public java.util.Enumeration enumerateJGroup()
240 return this._JGroupList.elements();
244 * Method enumerateJSeq.
246 * @return an Enumeration over all jalview.schemabinding.version2.JSeq
249 public java.util.Enumeration enumerateJSeq()
251 return this._JSeqList.elements();
255 * Method enumerateTree.
257 * @return an Enumeration over all jalview.schemabinding.version2.Tree
260 public java.util.Enumeration enumerateTree()
262 return this._treeList.elements();
266 * Method enumerateUserColours.
268 * @return an Enumeration over all jalview.schemabinding.version2.UserColours
271 public java.util.Enumeration enumerateUserColours()
273 return this._userColoursList.elements();
277 * Method enumerateViewport.
279 * @return an Enumeration over all jalview.schemabinding.version2.Viewport
282 public java.util.Enumeration enumerateViewport()
284 return this._viewportList.elements();
288 * Returns the value of field 'featureSettings'.
290 * @return the value of field 'FeatureSettings'.
292 public jalview.schemabinding.version2.FeatureSettings getFeatureSettings()
294 return this._featureSettings;
301 * @throws java.lang.IndexOutOfBoundsException
302 * if the index given is outside the bounds of the collection
303 * @return the value of the jalview.schemabinding.version2.JGroup at the given
306 public jalview.schemabinding.version2.JGroup getJGroup(final int index)
307 throws java.lang.IndexOutOfBoundsException
309 // check bounds for index
310 if (index < 0 || index >= this._JGroupList.size())
312 throw new IndexOutOfBoundsException("getJGroup: Index value '"
313 + index + "' not in range [0.."
314 + (this._JGroupList.size() - 1) + "]");
317 return (jalview.schemabinding.version2.JGroup) _JGroupList.get(index);
321 * Method getJGroup.Returns the contents of the collection in an Array.
323 * Note: Just in case the collection contents are changing in another thread,
324 * we pass a 0-length Array of the correct type into the API call. This way we
325 * <i>know</i> that the Array returned is of exactly the correct length.
327 * @return this collection as an Array
329 public jalview.schemabinding.version2.JGroup[] getJGroup()
331 jalview.schemabinding.version2.JGroup[] array = new jalview.schemabinding.version2.JGroup[0];
332 return (jalview.schemabinding.version2.JGroup[]) this._JGroupList
337 * Method getJGroupCount.
339 * @return the size of this collection
341 public int getJGroupCount()
343 return this._JGroupList.size();
350 * @throws java.lang.IndexOutOfBoundsException
351 * if the index given is outside the bounds of the collection
352 * @return the value of the jalview.schemabinding.version2.JSeq at the given
355 public jalview.schemabinding.version2.JSeq getJSeq(final int index)
356 throws java.lang.IndexOutOfBoundsException
358 // check bounds for index
359 if (index < 0 || index >= this._JSeqList.size())
361 throw new IndexOutOfBoundsException("getJSeq: Index value '" + index
362 + "' not in range [0.." + (this._JSeqList.size() - 1) + "]");
365 return (jalview.schemabinding.version2.JSeq) _JSeqList.get(index);
369 * Method getJSeq.Returns the contents of the collection in an Array.
371 * Note: Just in case the collection contents are changing in another thread,
372 * we pass a 0-length Array of the correct type into the API call. This way we
373 * <i>know</i> that the Array returned is of exactly the correct length.
375 * @return this collection as an Array
377 public jalview.schemabinding.version2.JSeq[] getJSeq()
379 jalview.schemabinding.version2.JSeq[] array = new jalview.schemabinding.version2.JSeq[0];
380 return (jalview.schemabinding.version2.JSeq[]) this._JSeqList
385 * Method getJSeqCount.
387 * @return the size of this collection
389 public int getJSeqCount()
391 return this._JSeqList.size();
398 * @throws java.lang.IndexOutOfBoundsException
399 * if the index given is outside the bounds of the collection
400 * @return the value of the jalview.schemabinding.version2.Tree at the given
403 public jalview.schemabinding.version2.Tree getTree(final int index)
404 throws java.lang.IndexOutOfBoundsException
406 // check bounds for index
407 if (index < 0 || index >= this._treeList.size())
409 throw new IndexOutOfBoundsException("getTree: Index value '" + index
410 + "' not in range [0.." + (this._treeList.size() - 1) + "]");
413 return (jalview.schemabinding.version2.Tree) _treeList.get(index);
417 * Method getTree.Returns the contents of the collection in an Array.
419 * Note: Just in case the collection contents are changing in another thread,
420 * we pass a 0-length Array of the correct type into the API call. This way we
421 * <i>know</i> that the Array returned is of exactly the correct length.
423 * @return this collection as an Array
425 public jalview.schemabinding.version2.Tree[] getTree()
427 jalview.schemabinding.version2.Tree[] array = new jalview.schemabinding.version2.Tree[0];
428 return (jalview.schemabinding.version2.Tree[]) this._treeList
433 * Method getTreeCount.
435 * @return the size of this collection
437 public int getTreeCount()
439 return this._treeList.size();
443 * Method getUserColours.
446 * @throws java.lang.IndexOutOfBoundsException
447 * if the index given is outside the bounds of the collection
448 * @return the value of the jalview.schemabinding.version2.UserColours at the
451 public jalview.schemabinding.version2.UserColours getUserColours(
452 final int index) throws java.lang.IndexOutOfBoundsException
454 // check bounds for index
455 if (index < 0 || index >= this._userColoursList.size())
457 throw new IndexOutOfBoundsException("getUserColours: Index value '"
458 + index + "' not in range [0.."
459 + (this._userColoursList.size() - 1) + "]");
462 return (jalview.schemabinding.version2.UserColours) _userColoursList
467 * Method getUserColours.Returns the contents of the collection in an Array.
469 * Note: Just in case the collection contents are changing in another thread,
470 * we pass a 0-length Array of the correct type into the API call. This way we
471 * <i>know</i> that the Array returned is of exactly the correct length.
473 * @return this collection as an Array
475 public jalview.schemabinding.version2.UserColours[] getUserColours()
477 jalview.schemabinding.version2.UserColours[] array = new jalview.schemabinding.version2.UserColours[0];
478 return (jalview.schemabinding.version2.UserColours[]) this._userColoursList
483 * Method getUserColoursCount.
485 * @return the size of this collection
487 public int getUserColoursCount()
489 return this._userColoursList.size();
493 * Method getViewport.
496 * @throws java.lang.IndexOutOfBoundsException
497 * if the index given is outside the bounds of the collection
498 * @return the value of the jalview.schemabinding.version2.Viewport at the
501 public jalview.schemabinding.version2.Viewport getViewport(final int index)
502 throws java.lang.IndexOutOfBoundsException
504 // check bounds for index
505 if (index < 0 || index >= this._viewportList.size())
507 throw new IndexOutOfBoundsException("getViewport: Index value '"
508 + index + "' not in range [0.."
509 + (this._viewportList.size() - 1) + "]");
512 return (jalview.schemabinding.version2.Viewport) _viewportList
517 * Method getViewport.Returns the contents of the collection in an Array.
519 * Note: Just in case the collection contents are changing in another thread,
520 * we pass a 0-length Array of the correct type into the API call. This way we
521 * <i>know</i> that the Array returned is of exactly the correct length.
523 * @return this collection as an Array
525 public jalview.schemabinding.version2.Viewport[] getViewport()
527 jalview.schemabinding.version2.Viewport[] array = new jalview.schemabinding.version2.Viewport[0];
528 return (jalview.schemabinding.version2.Viewport[]) this._viewportList
533 * Method getViewportCount.
535 * @return the size of this collection
537 public int getViewportCount()
539 return this._viewportList.size();
545 * @return true if this object is valid according to the schema
547 public boolean isValid()
552 } catch (org.exolab.castor.xml.ValidationException vex)
563 * @throws org.exolab.castor.xml.MarshalException
564 * if object is null or if any SAXException is thrown during
566 * @throws org.exolab.castor.xml.ValidationException
567 * if this object is an invalid instance according to the schema
569 public void marshal(final java.io.Writer out)
570 throws org.exolab.castor.xml.MarshalException,
571 org.exolab.castor.xml.ValidationException
573 Marshaller.marshal(this, out);
580 * @throws java.io.IOException
581 * if an IOException occurs during marshaling
582 * @throws org.exolab.castor.xml.ValidationException
583 * if this object is an invalid instance according to the schema
584 * @throws org.exolab.castor.xml.MarshalException
585 * if object is null or if any SAXException is thrown during
588 public void marshal(final org.xml.sax.ContentHandler handler)
589 throws java.io.IOException,
590 org.exolab.castor.xml.MarshalException,
591 org.exolab.castor.xml.ValidationException
593 Marshaller.marshal(this, handler);
598 public void removeAllJGroup()
600 this._JGroupList.clear();
605 public void removeAllJSeq()
607 this._JSeqList.clear();
612 public void removeAllTree()
614 this._treeList.clear();
619 public void removeAllUserColours()
621 this._userColoursList.clear();
626 public void removeAllViewport()
628 this._viewportList.clear();
632 * Method removeJGroup.
635 * @return true if the object was removed from the collection.
637 public boolean removeJGroup(
638 final jalview.schemabinding.version2.JGroup vJGroup)
640 boolean removed = _JGroupList.remove(vJGroup);
645 * Method removeJGroupAt.
648 * @return the element removed from the collection
650 public jalview.schemabinding.version2.JGroup removeJGroupAt(
653 java.lang.Object obj = this._JGroupList.remove(index);
654 return (jalview.schemabinding.version2.JGroup) obj;
661 * @return true if the object was removed from the collection.
663 public boolean removeJSeq(final jalview.schemabinding.version2.JSeq vJSeq)
665 boolean removed = _JSeqList.remove(vJSeq);
670 * Method removeJSeqAt.
673 * @return the element removed from the collection
675 public jalview.schemabinding.version2.JSeq removeJSeqAt(final int index)
677 java.lang.Object obj = this._JSeqList.remove(index);
678 return (jalview.schemabinding.version2.JSeq) obj;
685 * @return true if the object was removed from the collection.
687 public boolean removeTree(final jalview.schemabinding.version2.Tree vTree)
689 boolean removed = _treeList.remove(vTree);
694 * Method removeTreeAt.
697 * @return the element removed from the collection
699 public jalview.schemabinding.version2.Tree removeTreeAt(final int index)
701 java.lang.Object obj = this._treeList.remove(index);
702 return (jalview.schemabinding.version2.Tree) obj;
706 * Method removeUserColours.
708 * @param vUserColours
709 * @return true if the object was removed from the collection.
711 public boolean removeUserColours(
712 final jalview.schemabinding.version2.UserColours vUserColours)
714 boolean removed = _userColoursList.remove(vUserColours);
719 * Method removeUserColoursAt.
722 * @return the element removed from the collection
724 public jalview.schemabinding.version2.UserColours removeUserColoursAt(
727 java.lang.Object obj = this._userColoursList.remove(index);
728 return (jalview.schemabinding.version2.UserColours) obj;
732 * Method removeViewport.
735 * @return true if the object was removed from the collection.
737 public boolean removeViewport(
738 final jalview.schemabinding.version2.Viewport vViewport)
740 boolean removed = _viewportList.remove(vViewport);
745 * Method removeViewportAt.
748 * @return the element removed from the collection
750 public jalview.schemabinding.version2.Viewport removeViewportAt(
753 java.lang.Object obj = this._viewportList.remove(index);
754 return (jalview.schemabinding.version2.Viewport) obj;
758 * Sets the value of field 'featureSettings'.
760 * @param featureSettings
761 * the value of field 'featureSettings'.
763 public void setFeatureSettings(
764 final jalview.schemabinding.version2.FeatureSettings featureSettings)
766 this._featureSettings = featureSettings;
774 * @throws java.lang.IndexOutOfBoundsException
775 * if the index given is outside the bounds of the collection
777 public void setJGroup(final int index,
778 final jalview.schemabinding.version2.JGroup vJGroup)
779 throws java.lang.IndexOutOfBoundsException
781 // check bounds for index
782 if (index < 0 || index >= this._JGroupList.size())
784 throw new IndexOutOfBoundsException("setJGroup: Index value '"
785 + index + "' not in range [0.."
786 + (this._JGroupList.size() - 1) + "]");
789 this._JGroupList.set(index, vJGroup);
795 * @param vJGroupArray
797 public void setJGroup(
798 final jalview.schemabinding.version2.JGroup[] vJGroupArray)
803 for (int i = 0; i < vJGroupArray.length; i++)
805 this._JGroupList.add(vJGroupArray[i]);
814 * @throws java.lang.IndexOutOfBoundsException
815 * if the index given is outside the bounds of the collection
817 public void setJSeq(final int index,
818 final jalview.schemabinding.version2.JSeq vJSeq)
819 throws java.lang.IndexOutOfBoundsException
821 // check bounds for index
822 if (index < 0 || index >= this._JSeqList.size())
824 throw new IndexOutOfBoundsException("setJSeq: Index value '" + index
825 + "' not in range [0.." + (this._JSeqList.size() - 1) + "]");
828 this._JSeqList.set(index, vJSeq);
836 public void setJSeq(final jalview.schemabinding.version2.JSeq[] vJSeqArray)
841 for (int i = 0; i < vJSeqArray.length; i++)
843 this._JSeqList.add(vJSeqArray[i]);
852 * @throws java.lang.IndexOutOfBoundsException
853 * if the index given is outside the bounds of the collection
855 public void setTree(final int index,
856 final jalview.schemabinding.version2.Tree vTree)
857 throws java.lang.IndexOutOfBoundsException
859 // check bounds for index
860 if (index < 0 || index >= this._treeList.size())
862 throw new IndexOutOfBoundsException("setTree: Index value '" + index
863 + "' not in range [0.." + (this._treeList.size() - 1) + "]");
866 this._treeList.set(index, vTree);
874 public void setTree(final jalview.schemabinding.version2.Tree[] vTreeArray)
879 for (int i = 0; i < vTreeArray.length; i++)
881 this._treeList.add(vTreeArray[i]);
889 * @param vUserColours
890 * @throws java.lang.IndexOutOfBoundsException
891 * if the index given is outside the bounds of the collection
893 public void setUserColours(final int index,
894 final jalview.schemabinding.version2.UserColours vUserColours)
895 throws java.lang.IndexOutOfBoundsException
897 // check bounds for index
898 if (index < 0 || index >= this._userColoursList.size())
900 throw new IndexOutOfBoundsException("setUserColours: Index value '"
901 + index + "' not in range [0.."
902 + (this._userColoursList.size() - 1) + "]");
905 this._userColoursList.set(index, vUserColours);
911 * @param vUserColoursArray
913 public void setUserColours(
914 final jalview.schemabinding.version2.UserColours[] vUserColoursArray)
917 _userColoursList.clear();
919 for (int i = 0; i < vUserColoursArray.length; i++)
921 this._userColoursList.add(vUserColoursArray[i]);
930 * @throws java.lang.IndexOutOfBoundsException
931 * if the index given is outside the bounds of the collection
933 public void setViewport(final int index,
934 final jalview.schemabinding.version2.Viewport vViewport)
935 throws java.lang.IndexOutOfBoundsException
937 // check bounds for index
938 if (index < 0 || index >= this._viewportList.size())
940 throw new IndexOutOfBoundsException("setViewport: Index value '"
941 + index + "' not in range [0.."
942 + (this._viewportList.size() - 1) + "]");
945 this._viewportList.set(index, vViewport);
951 * @param vViewportArray
953 public void setViewport(
954 final jalview.schemabinding.version2.Viewport[] vViewportArray)
957 _viewportList.clear();
959 for (int i = 0; i < vViewportArray.length; i++)
961 this._viewportList.add(vViewportArray[i]);
969 * @throws org.exolab.castor.xml.MarshalException
970 * if object is null or if any SAXException is thrown during
972 * @throws org.exolab.castor.xml.ValidationException
973 * if this object is an invalid instance according to the schema
974 * @return the unmarshaled jalview.schemabinding.version2.JalviewModelSequence
976 public static jalview.schemabinding.version2.JalviewModelSequence unmarshal(
977 final java.io.Reader reader)
978 throws org.exolab.castor.xml.MarshalException,
979 org.exolab.castor.xml.ValidationException
981 return (jalview.schemabinding.version2.JalviewModelSequence) Unmarshaller
983 jalview.schemabinding.version2.JalviewModelSequence.class,
990 * @throws org.exolab.castor.xml.ValidationException
991 * if this object is an invalid instance according to the schema
993 public void validate() throws org.exolab.castor.xml.ValidationException
995 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
996 validator.validate(this);