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;
33 * Class JalviewModelSequence.
35 * @version $Revision$ $Date$
37 public class JalviewModelSequence implements java.io.Serializable
40 // --------------------------/
41 // - Class/Member Variables -/
42 // --------------------------/
47 private java.util.Vector _JSeqList;
52 private java.util.Vector _JGroupList;
55 * Field _viewportList.
57 private java.util.Vector _viewportList;
60 * Field _userColoursList.
62 private java.util.Vector _userColoursList;
67 private java.util.Vector _treeList;
70 * Field _featureSettings.
72 private jalview.schemabinding.version2.FeatureSettings _featureSettings;
78 public JalviewModelSequence()
81 this._JSeqList = new java.util.Vector();
82 this._JGroupList = new java.util.Vector();
83 this._viewportList = new java.util.Vector();
84 this._userColoursList = new java.util.Vector();
85 this._treeList = new java.util.Vector();
96 * @throws java.lang.IndexOutOfBoundsException
97 * if the index given is outside the bounds of the collection
99 public void addJGroup(final jalview.schemabinding.version2.JGroup vJGroup)
100 throws java.lang.IndexOutOfBoundsException
102 this._JGroupList.addElement(vJGroup);
110 * @throws java.lang.IndexOutOfBoundsException
111 * if the index given is outside the bounds of the collection
113 public void addJGroup(final int index,
114 final jalview.schemabinding.version2.JGroup vJGroup)
115 throws java.lang.IndexOutOfBoundsException
117 this._JGroupList.add(index, vJGroup);
124 * @throws java.lang.IndexOutOfBoundsException
125 * if the index given is outside the bounds of the collection
127 public void addJSeq(final jalview.schemabinding.version2.JSeq vJSeq)
128 throws java.lang.IndexOutOfBoundsException
130 this._JSeqList.addElement(vJSeq);
138 * @throws java.lang.IndexOutOfBoundsException
139 * if the index given is outside the bounds of the collection
141 public void addJSeq(final int index,
142 final jalview.schemabinding.version2.JSeq vJSeq)
143 throws java.lang.IndexOutOfBoundsException
145 this._JSeqList.add(index, vJSeq);
152 * @throws java.lang.IndexOutOfBoundsException
153 * if the index given is outside the bounds of the collection
155 public void addTree(final jalview.schemabinding.version2.Tree vTree)
156 throws java.lang.IndexOutOfBoundsException
158 this._treeList.addElement(vTree);
166 * @throws java.lang.IndexOutOfBoundsException
167 * if the index given is outside the bounds of the collection
169 public void addTree(final int index,
170 final jalview.schemabinding.version2.Tree vTree)
171 throws java.lang.IndexOutOfBoundsException
173 this._treeList.add(index, vTree);
179 * @param vUserColours
180 * @throws java.lang.IndexOutOfBoundsException
181 * if the index given is outside the bounds of the collection
183 public void addUserColours(
184 final jalview.schemabinding.version2.UserColours vUserColours)
185 throws java.lang.IndexOutOfBoundsException
187 this._userColoursList.addElement(vUserColours);
194 * @param vUserColours
195 * @throws java.lang.IndexOutOfBoundsException
196 * if the index given is outside the bounds of the collection
198 public void addUserColours(final int index,
199 final jalview.schemabinding.version2.UserColours vUserColours)
200 throws java.lang.IndexOutOfBoundsException
202 this._userColoursList.add(index, vUserColours);
209 * @throws java.lang.IndexOutOfBoundsException
210 * if the index given is outside the bounds of the collection
212 public void addViewport(
213 final jalview.schemabinding.version2.Viewport vViewport)
214 throws java.lang.IndexOutOfBoundsException
216 this._viewportList.addElement(vViewport);
224 * @throws java.lang.IndexOutOfBoundsException
225 * if the index given is outside the bounds of the collection
227 public void addViewport(final int index,
228 final jalview.schemabinding.version2.Viewport vViewport)
229 throws java.lang.IndexOutOfBoundsException
231 this._viewportList.add(index, vViewport);
235 * Method enumerateJGroup.
237 * @return an Enumeration over all jalview.schemabinding.version2.JGroup
240 public java.util.Enumeration enumerateJGroup()
242 return this._JGroupList.elements();
246 * Method enumerateJSeq.
248 * @return an Enumeration over all jalview.schemabinding.version2.JSeq
251 public java.util.Enumeration enumerateJSeq()
253 return this._JSeqList.elements();
257 * Method enumerateTree.
259 * @return an Enumeration over all jalview.schemabinding.version2.Tree
262 public java.util.Enumeration enumerateTree()
264 return this._treeList.elements();
268 * Method enumerateUserColours.
270 * @return an Enumeration over all jalview.schemabinding.version2.UserColours
273 public java.util.Enumeration enumerateUserColours()
275 return this._userColoursList.elements();
279 * Method enumerateViewport.
281 * @return an Enumeration over all jalview.schemabinding.version2.Viewport
284 public java.util.Enumeration enumerateViewport()
286 return this._viewportList.elements();
290 * Returns the value of field 'featureSettings'.
292 * @return the value of field 'FeatureSettings'.
294 public jalview.schemabinding.version2.FeatureSettings getFeatureSettings()
296 return this._featureSettings;
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.JGroup at the given
308 public jalview.schemabinding.version2.JGroup getJGroup(final int index)
309 throws java.lang.IndexOutOfBoundsException
311 // check bounds for index
312 if (index < 0 || index >= this._JGroupList.size())
314 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
316 Integer.valueOf(index).toString(),
317 Integer.valueOf((this._JGroupList.size() - 1)).toString()
321 return (jalview.schemabinding.version2.JGroup) _JGroupList.get(index);
325 * Method getJGroup.Returns the contents of the collection in an Array.
327 * Note: Just in case the collection contents are changing in another thread,
328 * we pass a 0-length Array of the correct type into the API call. This way we
329 * <i>know</i> that the Array returned is of exactly the correct length.
331 * @return this collection as an Array
333 public jalview.schemabinding.version2.JGroup[] getJGroup()
335 jalview.schemabinding.version2.JGroup[] array = new jalview.schemabinding.version2.JGroup[0];
336 return (jalview.schemabinding.version2.JGroup[]) this._JGroupList
341 * Method getJGroupCount.
343 * @return the size of this collection
345 public int getJGroupCount()
347 return this._JGroupList.size();
354 * @throws java.lang.IndexOutOfBoundsException
355 * if the index given is outside the bounds of the collection
356 * @return the value of the jalview.schemabinding.version2.JSeq at the given
359 public jalview.schemabinding.version2.JSeq getJSeq(final int index)
360 throws java.lang.IndexOutOfBoundsException
362 // check bounds for index
363 if (index < 0 || index >= this._JSeqList.size())
365 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
367 Integer.valueOf(index).toString(),
368 Integer.valueOf((this._JSeqList.size() - 1)).toString()
372 return (jalview.schemabinding.version2.JSeq) _JSeqList.get(index);
376 * Method getJSeq.Returns the contents of the collection in an Array.
378 * Note: Just in case the collection contents are changing in another thread,
379 * we pass a 0-length Array of the correct type into the API call. This way we
380 * <i>know</i> that the Array returned is of exactly the correct length.
382 * @return this collection as an Array
384 public jalview.schemabinding.version2.JSeq[] getJSeq()
386 jalview.schemabinding.version2.JSeq[] array = new jalview.schemabinding.version2.JSeq[0];
387 return (jalview.schemabinding.version2.JSeq[]) this._JSeqList
392 * Method getJSeqCount.
394 * @return the size of this collection
396 public int getJSeqCount()
398 return this._JSeqList.size();
405 * @throws java.lang.IndexOutOfBoundsException
406 * if the index given is outside the bounds of the collection
407 * @return the value of the jalview.schemabinding.version2.Tree at the given
410 public jalview.schemabinding.version2.Tree getTree(final int index)
411 throws java.lang.IndexOutOfBoundsException
413 // check bounds for index
414 if (index < 0 || index >= this._treeList.size())
416 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
418 Integer.valueOf(index).toString(),
419 Integer.valueOf((this._treeList.size() - 1)).toString()
423 return (jalview.schemabinding.version2.Tree) _treeList.get(index);
427 * Method getTree.Returns the contents of the collection in an Array.
429 * Note: Just in case the collection contents are changing in another thread,
430 * we pass a 0-length Array of the correct type into the API call. This way we
431 * <i>know</i> that the Array returned is of exactly the correct length.
433 * @return this collection as an Array
435 public jalview.schemabinding.version2.Tree[] getTree()
437 jalview.schemabinding.version2.Tree[] array = new jalview.schemabinding.version2.Tree[0];
438 return (jalview.schemabinding.version2.Tree[]) this._treeList
443 * Method getTreeCount.
445 * @return the size of this collection
447 public int getTreeCount()
449 return this._treeList.size();
453 * Method getUserColours.
456 * @throws java.lang.IndexOutOfBoundsException
457 * if the index given is outside the bounds of the collection
458 * @return the value of the jalview.schemabinding.version2.UserColours at the
461 public jalview.schemabinding.version2.UserColours getUserColours(
462 final int index) throws java.lang.IndexOutOfBoundsException
464 // check bounds for index
465 if (index < 0 || index >= this._userColoursList.size())
467 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
469 Integer.valueOf(index).toString(),
470 Integer.valueOf((this._userColoursList.size() - 1)).toString()
474 return (jalview.schemabinding.version2.UserColours) _userColoursList
479 * Method getUserColours.Returns the contents of the collection in an Array.
481 * Note: Just in case the collection contents are changing in another thread,
482 * we pass a 0-length Array of the correct type into the API call. This way we
483 * <i>know</i> that the Array returned is of exactly the correct length.
485 * @return this collection as an Array
487 public jalview.schemabinding.version2.UserColours[] getUserColours()
489 jalview.schemabinding.version2.UserColours[] array = new jalview.schemabinding.version2.UserColours[0];
490 return (jalview.schemabinding.version2.UserColours[]) this._userColoursList
495 * Method getUserColoursCount.
497 * @return the size of this collection
499 public int getUserColoursCount()
501 return this._userColoursList.size();
505 * Method getViewport.
508 * @throws java.lang.IndexOutOfBoundsException
509 * if the index given is outside the bounds of the collection
510 * @return the value of the jalview.schemabinding.version2.Viewport at the
513 public jalview.schemabinding.version2.Viewport getViewport(final int index)
514 throws java.lang.IndexOutOfBoundsException
516 // check bounds for index
517 if (index < 0 || index >= this._viewportList.size())
519 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
521 Integer.valueOf(index).toString(),
522 Integer.valueOf((this._viewportList.size() - 1)).toString()
526 return (jalview.schemabinding.version2.Viewport) _viewportList
531 * Method getViewport.Returns the contents of the collection in an Array.
533 * Note: Just in case the collection contents are changing in another thread,
534 * we pass a 0-length Array of the correct type into the API call. This way we
535 * <i>know</i> that the Array returned is of exactly the correct length.
537 * @return this collection as an Array
539 public jalview.schemabinding.version2.Viewport[] getViewport()
541 jalview.schemabinding.version2.Viewport[] array = new jalview.schemabinding.version2.Viewport[0];
542 return (jalview.schemabinding.version2.Viewport[]) this._viewportList
547 * Method getViewportCount.
549 * @return the size of this collection
551 public int getViewportCount()
553 return this._viewportList.size();
559 * @return true if this object is valid according to the schema
561 public boolean isValid()
566 } catch (org.exolab.castor.xml.ValidationException vex)
577 * @throws org.exolab.castor.xml.MarshalException
578 * if object is null or if any SAXException is thrown during
580 * @throws org.exolab.castor.xml.ValidationException
581 * if this object is an invalid instance according to the schema
583 public void marshal(final java.io.Writer out)
584 throws org.exolab.castor.xml.MarshalException,
585 org.exolab.castor.xml.ValidationException
587 Marshaller.marshal(this, out);
594 * @throws java.io.IOException
595 * if an IOException occurs during marshaling
596 * @throws org.exolab.castor.xml.ValidationException
597 * if this object is an invalid instance according to the schema
598 * @throws org.exolab.castor.xml.MarshalException
599 * if object is null or if any SAXException is thrown during
602 public void marshal(final org.xml.sax.ContentHandler handler)
603 throws java.io.IOException,
604 org.exolab.castor.xml.MarshalException,
605 org.exolab.castor.xml.ValidationException
607 Marshaller.marshal(this, handler);
612 public void removeAllJGroup()
614 this._JGroupList.clear();
619 public void removeAllJSeq()
621 this._JSeqList.clear();
626 public void removeAllTree()
628 this._treeList.clear();
633 public void removeAllUserColours()
635 this._userColoursList.clear();
640 public void removeAllViewport()
642 this._viewportList.clear();
646 * Method removeJGroup.
649 * @return true if the object was removed from the collection.
651 public boolean removeJGroup(
652 final jalview.schemabinding.version2.JGroup vJGroup)
654 boolean removed = _JGroupList.remove(vJGroup);
659 * Method removeJGroupAt.
662 * @return the element removed from the collection
664 public jalview.schemabinding.version2.JGroup removeJGroupAt(
667 java.lang.Object obj = this._JGroupList.remove(index);
668 return (jalview.schemabinding.version2.JGroup) obj;
675 * @return true if the object was removed from the collection.
677 public boolean removeJSeq(final jalview.schemabinding.version2.JSeq vJSeq)
679 boolean removed = _JSeqList.remove(vJSeq);
684 * Method removeJSeqAt.
687 * @return the element removed from the collection
689 public jalview.schemabinding.version2.JSeq removeJSeqAt(final int index)
691 java.lang.Object obj = this._JSeqList.remove(index);
692 return (jalview.schemabinding.version2.JSeq) obj;
699 * @return true if the object was removed from the collection.
701 public boolean removeTree(final jalview.schemabinding.version2.Tree vTree)
703 boolean removed = _treeList.remove(vTree);
708 * Method removeTreeAt.
711 * @return the element removed from the collection
713 public jalview.schemabinding.version2.Tree removeTreeAt(final int index)
715 java.lang.Object obj = this._treeList.remove(index);
716 return (jalview.schemabinding.version2.Tree) obj;
720 * Method removeUserColours.
722 * @param vUserColours
723 * @return true if the object was removed from the collection.
725 public boolean removeUserColours(
726 final jalview.schemabinding.version2.UserColours vUserColours)
728 boolean removed = _userColoursList.remove(vUserColours);
733 * Method removeUserColoursAt.
736 * @return the element removed from the collection
738 public jalview.schemabinding.version2.UserColours removeUserColoursAt(
741 java.lang.Object obj = this._userColoursList.remove(index);
742 return (jalview.schemabinding.version2.UserColours) obj;
746 * Method removeViewport.
749 * @return true if the object was removed from the collection.
751 public boolean removeViewport(
752 final jalview.schemabinding.version2.Viewport vViewport)
754 boolean removed = _viewportList.remove(vViewport);
759 * Method removeViewportAt.
762 * @return the element removed from the collection
764 public jalview.schemabinding.version2.Viewport removeViewportAt(
767 java.lang.Object obj = this._viewportList.remove(index);
768 return (jalview.schemabinding.version2.Viewport) obj;
772 * Sets the value of field 'featureSettings'.
774 * @param featureSettings
775 * the value of field 'featureSettings'.
777 public void setFeatureSettings(
778 final jalview.schemabinding.version2.FeatureSettings featureSettings)
780 this._featureSettings = featureSettings;
788 * @throws java.lang.IndexOutOfBoundsException
789 * if the index given is outside the bounds of the collection
791 public void setJGroup(final int index,
792 final jalview.schemabinding.version2.JGroup vJGroup)
793 throws java.lang.IndexOutOfBoundsException
795 // check bounds for index
796 if (index < 0 || index >= this._JGroupList.size())
798 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
800 Integer.valueOf(index).toString(),
801 Integer.valueOf((this._JGroupList.size() - 1)).toString()
805 this._JGroupList.set(index, vJGroup);
811 * @param vJGroupArray
813 public void setJGroup(
814 final jalview.schemabinding.version2.JGroup[] vJGroupArray)
819 for (int i = 0; i < vJGroupArray.length; i++)
821 this._JGroupList.add(vJGroupArray[i]);
830 * @throws java.lang.IndexOutOfBoundsException
831 * if the index given is outside the bounds of the collection
833 public void setJSeq(final int index,
834 final jalview.schemabinding.version2.JSeq vJSeq)
835 throws java.lang.IndexOutOfBoundsException
837 // check bounds for index
838 if (index < 0 || index >= this._JSeqList.size())
840 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
842 Integer.valueOf(index).toString(),
843 Integer.valueOf((this._JSeqList.size() - 1)).toString()
847 this._JSeqList.set(index, vJSeq);
855 public void setJSeq(final jalview.schemabinding.version2.JSeq[] vJSeqArray)
860 for (int i = 0; i < vJSeqArray.length; i++)
862 this._JSeqList.add(vJSeqArray[i]);
871 * @throws java.lang.IndexOutOfBoundsException
872 * if the index given is outside the bounds of the collection
874 public void setTree(final int index,
875 final jalview.schemabinding.version2.Tree vTree)
876 throws java.lang.IndexOutOfBoundsException
878 // check bounds for index
879 if (index < 0 || index >= this._treeList.size())
881 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
883 Integer.valueOf(index).toString(),
884 Integer.valueOf((this._treeList.size() - 1)).toString()
888 this._treeList.set(index, vTree);
896 public void setTree(final jalview.schemabinding.version2.Tree[] vTreeArray)
901 for (int i = 0; i < vTreeArray.length; i++)
903 this._treeList.add(vTreeArray[i]);
911 * @param vUserColours
912 * @throws java.lang.IndexOutOfBoundsException
913 * if the index given is outside the bounds of the collection
915 public void setUserColours(final int index,
916 final jalview.schemabinding.version2.UserColours vUserColours)
917 throws java.lang.IndexOutOfBoundsException
919 // check bounds for index
920 if (index < 0 || index >= this._userColoursList.size())
922 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
924 Integer.valueOf(index).toString(),
925 Integer.valueOf((this._userColoursList.size() - 1)).toString()
929 this._userColoursList.set(index, vUserColours);
935 * @param vUserColoursArray
937 public void setUserColours(
938 final jalview.schemabinding.version2.UserColours[] vUserColoursArray)
941 _userColoursList.clear();
943 for (int i = 0; i < vUserColoursArray.length; i++)
945 this._userColoursList.add(vUserColoursArray[i]);
954 * @throws java.lang.IndexOutOfBoundsException
955 * if the index given is outside the bounds of the collection
957 public void setViewport(final int index,
958 final jalview.schemabinding.version2.Viewport vViewport)
959 throws java.lang.IndexOutOfBoundsException
961 // check bounds for index
962 if (index < 0 || index >= this._viewportList.size())
964 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
966 Integer.valueOf(index).toString(),
967 Integer.valueOf((this._viewportList.size() - 1)).toString()
971 this._viewportList.set(index, vViewport);
977 * @param vViewportArray
979 public void setViewport(
980 final jalview.schemabinding.version2.Viewport[] vViewportArray)
983 _viewportList.clear();
985 for (int i = 0; i < vViewportArray.length; i++)
987 this._viewportList.add(vViewportArray[i]);
995 * @throws org.exolab.castor.xml.MarshalException
996 * if object is null or if any SAXException is thrown during
998 * @throws org.exolab.castor.xml.ValidationException
999 * if this object is an invalid instance according to the schema
1000 * @return the unmarshaled jalview.schemabinding.version2.JalviewModelSequence
1002 public static jalview.schemabinding.version2.JalviewModelSequence unmarshal(
1003 final java.io.Reader reader)
1004 throws org.exolab.castor.xml.MarshalException,
1005 org.exolab.castor.xml.ValidationException
1007 return (jalview.schemabinding.version2.JalviewModelSequence) Unmarshaller
1009 jalview.schemabinding.version2.JalviewModelSequence.class,
1016 * @throws org.exolab.castor.xml.ValidationException
1017 * if this object is an invalid instance according to the schema
1019 public void validate() throws org.exolab.castor.xml.ValidationException
1021 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
1022 validator.validate(this);