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;
35 * @version $Revision$ $Date$
37 public class JSeq implements java.io.Serializable
40 // --------------------------/
41 // - Class/Member Variables -/
42 // --------------------------/
50 * keeps track of state for field: _colour
52 private boolean _has_colour;
60 * keeps track of state for field: _start
62 private boolean _has_start;
70 * keeps track of state for field: _end
72 private boolean _has_end;
77 private java.lang.String _id;
82 private boolean _hidden;
85 * keeps track of state for field: _hidden
87 private boolean _has_hidden;
90 * Field _featuresList.
92 private java.util.Vector _featuresList;
97 private java.util.Vector _pdbidsList;
100 * Field _hiddenSequencesList.
102 private java.util.Vector _hiddenSequencesList;
111 this._featuresList = new java.util.Vector();
112 this._pdbidsList = new java.util.Vector();
113 this._hiddenSequencesList = new java.util.Vector();
124 * @throws java.lang.IndexOutOfBoundsException
125 * if the index given is outside the bounds of the collection
127 public void addFeatures(
128 final jalview.schemabinding.version2.Features vFeatures)
129 throws java.lang.IndexOutOfBoundsException
131 this._featuresList.addElement(vFeatures);
139 * @throws java.lang.IndexOutOfBoundsException
140 * if the index given is outside the bounds of the collection
142 public void addFeatures(final int index,
143 final jalview.schemabinding.version2.Features vFeatures)
144 throws java.lang.IndexOutOfBoundsException
146 this._featuresList.add(index, vFeatures);
152 * @param vHiddenSequences
153 * @throws java.lang.IndexOutOfBoundsException
154 * if the index given is outside the bounds of the collection
156 public void addHiddenSequences(final int vHiddenSequences)
157 throws java.lang.IndexOutOfBoundsException
159 this._hiddenSequencesList.addElement(new java.lang.Integer(
167 * @param vHiddenSequences
168 * @throws java.lang.IndexOutOfBoundsException
169 * if the index given is outside the bounds of the collection
171 public void addHiddenSequences(final int index, final int vHiddenSequences)
172 throws java.lang.IndexOutOfBoundsException
174 this._hiddenSequencesList.add(index, new java.lang.Integer(
182 * @throws java.lang.IndexOutOfBoundsException
183 * if the index given is outside the bounds of the collection
185 public void addPdbids(final jalview.schemabinding.version2.Pdbids vPdbids)
186 throws java.lang.IndexOutOfBoundsException
188 this._pdbidsList.addElement(vPdbids);
196 * @throws java.lang.IndexOutOfBoundsException
197 * if the index given is outside the bounds of the collection
199 public void addPdbids(final int index,
200 final jalview.schemabinding.version2.Pdbids vPdbids)
201 throws java.lang.IndexOutOfBoundsException
203 this._pdbidsList.add(index, vPdbids);
208 public void deleteColour()
210 this._has_colour = false;
215 public void deleteEnd()
217 this._has_end = false;
222 public void deleteHidden()
224 this._has_hidden = false;
229 public void deleteStart()
231 this._has_start = false;
235 * Method enumerateFeatures.
237 * @return an Enumeration over all jalview.schemabinding.version2.Features
240 public java.util.Enumeration enumerateFeatures()
242 return this._featuresList.elements();
246 * Method enumerateHiddenSequences.
248 * @return an Enumeration over all int elements
250 public java.util.Enumeration enumerateHiddenSequences()
252 return this._hiddenSequencesList.elements();
256 * Method enumeratePdbids.
258 * @return an Enumeration over all jalview.schemabinding.version2.Pdbids
261 public java.util.Enumeration enumeratePdbids()
263 return this._pdbidsList.elements();
267 * Returns the value of field 'colour'.
269 * @return the value of field 'Colour'.
271 public int getColour()
277 * Returns the value of field 'end'.
279 * @return the value of field 'End'.
287 * Method getFeatures.
290 * @throws java.lang.IndexOutOfBoundsException
291 * if the index given is outside the bounds of the collection
292 * @return the value of the jalview.schemabinding.version2.Features at the
295 public jalview.schemabinding.version2.Features getFeatures(final int index)
296 throws java.lang.IndexOutOfBoundsException
298 // check bounds for index
299 if (index < 0 || index >= this._featuresList.size())
301 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
303 Integer.valueOf(index).toString(),
304 Integer.valueOf((this._featuresList.size() - 1)).toString()
308 return (jalview.schemabinding.version2.Features) _featuresList
313 * Method getFeatures.Returns the contents of the collection in an Array.
315 * Note: Just in case the collection contents are changing in another thread,
316 * we pass a 0-length Array of the correct type into the API call. This way we
317 * <i>know</i> that the Array returned is of exactly the correct length.
319 * @return this collection as an Array
321 public jalview.schemabinding.version2.Features[] getFeatures()
323 jalview.schemabinding.version2.Features[] array = new jalview.schemabinding.version2.Features[0];
324 return (jalview.schemabinding.version2.Features[]) this._featuresList
329 * Method getFeaturesCount.
331 * @return the size of this collection
333 public int getFeaturesCount()
335 return this._featuresList.size();
339 * Returns the value of field 'hidden'.
341 * @return the value of field 'Hidden'.
343 public boolean getHidden()
349 * Method getHiddenSequences.
352 * @throws java.lang.IndexOutOfBoundsException
353 * if the index given is outside the bounds of the collection
354 * @return the value of the int at the given index
356 public int getHiddenSequences(final int index)
357 throws java.lang.IndexOutOfBoundsException
359 // check bounds for index
360 if (index < 0 || index >= this._hiddenSequencesList.size())
362 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
363 "getHiddenSequences",
364 Integer.valueOf(index).toString(),
365 Integer.valueOf((this._hiddenSequencesList.size() - 1)).toString()
369 return ((java.lang.Integer) _hiddenSequencesList.get(index)).intValue();
373 * Method getHiddenSequences.Returns the contents of the collection in an
376 * @return this collection as an Array
378 public int[] getHiddenSequences()
380 int size = this._hiddenSequencesList.size();
381 int[] array = new int[size];
382 java.util.Iterator iter = _hiddenSequencesList.iterator();
383 for (int index = 0; index < size; index++)
385 array[index] = ((java.lang.Integer) iter.next()).intValue();
391 * Method getHiddenSequencesCount.
393 * @return the size of this collection
395 public int getHiddenSequencesCount()
397 return this._hiddenSequencesList.size();
401 * Returns the value of field 'id'.
403 * @return the value of field 'Id'.
405 public java.lang.String getId()
414 * @throws java.lang.IndexOutOfBoundsException
415 * if the index given is outside the bounds of the collection
416 * @return the value of the jalview.schemabinding.version2.Pdbids at the given
419 public jalview.schemabinding.version2.Pdbids getPdbids(final int index)
420 throws java.lang.IndexOutOfBoundsException
422 // check bounds for index
423 if (index < 0 || index >= this._pdbidsList.size())
425 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
427 Integer.valueOf(index).toString(),
428 Integer.valueOf((this._pdbidsList.size() - 1)).toString()
432 return (jalview.schemabinding.version2.Pdbids) _pdbidsList.get(index);
436 * Method getPdbids.Returns the contents of the collection in an Array.
438 * Note: Just in case the collection contents are changing in another thread,
439 * we pass a 0-length Array of the correct type into the API call. This way we
440 * <i>know</i> that the Array returned is of exactly the correct length.
442 * @return this collection as an Array
444 public jalview.schemabinding.version2.Pdbids[] getPdbids()
446 jalview.schemabinding.version2.Pdbids[] array = new jalview.schemabinding.version2.Pdbids[0];
447 return (jalview.schemabinding.version2.Pdbids[]) this._pdbidsList
452 * Method getPdbidsCount.
454 * @return the size of this collection
456 public int getPdbidsCount()
458 return this._pdbidsList.size();
462 * Returns the value of field 'start'.
464 * @return the value of field 'Start'.
466 public int getStart()
474 * @return true if at least one Colour has been added
476 public boolean hasColour()
478 return this._has_colour;
484 * @return true if at least one End has been added
486 public boolean hasEnd()
488 return this._has_end;
494 * @return true if at least one Hidden has been added
496 public boolean hasHidden()
498 return this._has_hidden;
504 * @return true if at least one Start has been added
506 public boolean hasStart()
508 return this._has_start;
512 * Returns the value of field 'hidden'.
514 * @return the value of field 'Hidden'.
516 public boolean isHidden()
524 * @return true if this object is valid according to the schema
526 public boolean isValid()
531 } catch (org.exolab.castor.xml.ValidationException vex)
542 * @throws org.exolab.castor.xml.MarshalException
543 * if object is null or if any SAXException is thrown during
545 * @throws org.exolab.castor.xml.ValidationException
546 * if this object is an invalid instance according to the schema
548 public void marshal(final java.io.Writer out)
549 throws org.exolab.castor.xml.MarshalException,
550 org.exolab.castor.xml.ValidationException
552 Marshaller.marshal(this, out);
559 * @throws java.io.IOException
560 * if an IOException occurs during marshaling
561 * @throws org.exolab.castor.xml.ValidationException
562 * if this object is an invalid instance according to the schema
563 * @throws org.exolab.castor.xml.MarshalException
564 * if object is null or if any SAXException is thrown during
567 public void marshal(final org.xml.sax.ContentHandler handler)
568 throws java.io.IOException,
569 org.exolab.castor.xml.MarshalException,
570 org.exolab.castor.xml.ValidationException
572 Marshaller.marshal(this, handler);
577 public void removeAllFeatures()
579 this._featuresList.clear();
584 public void removeAllHiddenSequences()
586 this._hiddenSequencesList.clear();
591 public void removeAllPdbids()
593 this._pdbidsList.clear();
597 * Method removeFeatures.
600 * @return true if the object was removed from the collection.
602 public boolean removeFeatures(
603 final jalview.schemabinding.version2.Features vFeatures)
605 boolean removed = _featuresList.remove(vFeatures);
610 * Method removeFeaturesAt.
613 * @return the element removed from the collection
615 public jalview.schemabinding.version2.Features removeFeaturesAt(
618 java.lang.Object obj = this._featuresList.remove(index);
619 return (jalview.schemabinding.version2.Features) obj;
623 * Method removeHiddenSequences.
625 * @param vHiddenSequences
626 * @return true if the object was removed from the collection.
628 public boolean removeHiddenSequences(final int vHiddenSequences)
630 boolean removed = _hiddenSequencesList.remove(new java.lang.Integer(
636 * Method removeHiddenSequencesAt.
639 * @return the element removed from the collection
641 public int removeHiddenSequencesAt(final int index)
643 java.lang.Object obj = this._hiddenSequencesList.remove(index);
644 return ((java.lang.Integer) obj).intValue();
648 * Method removePdbids.
651 * @return true if the object was removed from the collection.
653 public boolean removePdbids(
654 final jalview.schemabinding.version2.Pdbids vPdbids)
656 boolean removed = _pdbidsList.remove(vPdbids);
661 * Method removePdbidsAt.
664 * @return the element removed from the collection
666 public jalview.schemabinding.version2.Pdbids removePdbidsAt(
669 java.lang.Object obj = this._pdbidsList.remove(index);
670 return (jalview.schemabinding.version2.Pdbids) obj;
674 * Sets the value of field 'colour'.
677 * the value of field 'colour'.
679 public void setColour(final int colour)
681 this._colour = colour;
682 this._has_colour = true;
686 * Sets the value of field 'end'.
689 * the value of field 'end'.
691 public void setEnd(final int end)
694 this._has_end = true;
702 * @throws java.lang.IndexOutOfBoundsException
703 * if the index given is outside the bounds of the collection
705 public void setFeatures(final int index,
706 final jalview.schemabinding.version2.Features vFeatures)
707 throws java.lang.IndexOutOfBoundsException
709 // check bounds for index
710 if (index < 0 || index >= this._featuresList.size())
712 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
714 Integer.valueOf(index).toString(),
715 Integer.valueOf((this._featuresList.size() - 1)).toString()
719 this._featuresList.set(index, vFeatures);
725 * @param vFeaturesArray
727 public void setFeatures(
728 final jalview.schemabinding.version2.Features[] vFeaturesArray)
731 _featuresList.clear();
733 for (int i = 0; i < vFeaturesArray.length; i++)
735 this._featuresList.add(vFeaturesArray[i]);
740 * Sets the value of field 'hidden'.
743 * the value of field 'hidden'.
745 public void setHidden(final boolean hidden)
747 this._hidden = hidden;
748 this._has_hidden = true;
755 * @param vHiddenSequences
756 * @throws java.lang.IndexOutOfBoundsException
757 * if the index given is outside the bounds of the collection
759 public void setHiddenSequences(final int index, final int vHiddenSequences)
760 throws java.lang.IndexOutOfBoundsException
762 // check bounds for index
763 if (index < 0 || index >= this._hiddenSequencesList.size())
765 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
766 "setHiddenSequences",
767 Integer.valueOf(index).toString(),
768 Integer.valueOf((this._hiddenSequencesList.size() - 1)).toString()
772 this._hiddenSequencesList.set(index, new java.lang.Integer(
779 * @param vHiddenSequencesArray
781 public void setHiddenSequences(final int[] vHiddenSequencesArray)
784 _hiddenSequencesList.clear();
786 for (int i = 0; i < vHiddenSequencesArray.length; i++)
788 this._hiddenSequencesList.add(new java.lang.Integer(
789 vHiddenSequencesArray[i]));
794 * Sets the value of field 'id'.
797 * the value of field 'id'.
799 public void setId(final java.lang.String id)
809 * @throws java.lang.IndexOutOfBoundsException
810 * if the index given is outside the bounds of the collection
812 public void setPdbids(final int index,
813 final jalview.schemabinding.version2.Pdbids vPdbids)
814 throws java.lang.IndexOutOfBoundsException
816 // check bounds for index
817 if (index < 0 || index >= this._pdbidsList.size())
819 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
821 Integer.valueOf(index).toString(),
822 Integer.valueOf((this._pdbidsList.size() - 1)).toString()
826 this._pdbidsList.set(index, vPdbids);
832 * @param vPdbidsArray
834 public void setPdbids(
835 final jalview.schemabinding.version2.Pdbids[] vPdbidsArray)
840 for (int i = 0; i < vPdbidsArray.length; i++)
842 this._pdbidsList.add(vPdbidsArray[i]);
847 * Sets the value of field 'start'.
850 * the value of field 'start'.
852 public void setStart(final int start)
855 this._has_start = true;
862 * @throws org.exolab.castor.xml.MarshalException
863 * if object is null or if any SAXException is thrown during
865 * @throws org.exolab.castor.xml.ValidationException
866 * if this object is an invalid instance according to the schema
867 * @return the unmarshaled jalview.schemabinding.version2.JSeq
869 public static jalview.schemabinding.version2.JSeq unmarshal(
870 final java.io.Reader reader)
871 throws org.exolab.castor.xml.MarshalException,
872 org.exolab.castor.xml.ValidationException
874 return (jalview.schemabinding.version2.JSeq) Unmarshaller.unmarshal(
875 jalview.schemabinding.version2.JSeq.class, reader);
881 * @throws org.exolab.castor.xml.ValidationException
882 * if this object is an invalid instance according to the schema
884 public void validate() throws org.exolab.castor.xml.ValidationException
886 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
887 validator.validate(this);