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;
31 * @version $Revision$ $Date$
33 public class JSeq implements java.io.Serializable
36 // --------------------------/
37 // - Class/Member Variables -/
38 // --------------------------/
46 * keeps track of state for field: _colour
48 private boolean _has_colour;
56 * keeps track of state for field: _start
58 private boolean _has_start;
66 * keeps track of state for field: _end
68 private boolean _has_end;
73 private java.lang.String _id;
78 private boolean _hidden;
81 * keeps track of state for field: _hidden
83 private boolean _has_hidden;
86 * Field _featuresList.
88 private java.util.Vector _featuresList;
93 private java.util.Vector _pdbidsList;
96 * Field _hiddenSequencesList.
98 private java.util.Vector _hiddenSequencesList;
107 this._featuresList = new java.util.Vector();
108 this._pdbidsList = new java.util.Vector();
109 this._hiddenSequencesList = new java.util.Vector();
120 * @throws java.lang.IndexOutOfBoundsException
121 * if the index given is outside the bounds of the collection
123 public void addFeatures(
124 final jalview.schemabinding.version2.Features vFeatures)
125 throws java.lang.IndexOutOfBoundsException
127 this._featuresList.addElement(vFeatures);
135 * @throws java.lang.IndexOutOfBoundsException
136 * if the index given is outside the bounds of the collection
138 public void addFeatures(final int index,
139 final jalview.schemabinding.version2.Features vFeatures)
140 throws java.lang.IndexOutOfBoundsException
142 this._featuresList.add(index, vFeatures);
148 * @param vHiddenSequences
149 * @throws java.lang.IndexOutOfBoundsException
150 * if the index given is outside the bounds of the collection
152 public void addHiddenSequences(final int vHiddenSequences)
153 throws java.lang.IndexOutOfBoundsException
155 this._hiddenSequencesList.addElement(new java.lang.Integer(
163 * @param vHiddenSequences
164 * @throws java.lang.IndexOutOfBoundsException
165 * if the index given is outside the bounds of the collection
167 public void addHiddenSequences(final int index, final int vHiddenSequences)
168 throws java.lang.IndexOutOfBoundsException
170 this._hiddenSequencesList.add(index, new java.lang.Integer(
178 * @throws java.lang.IndexOutOfBoundsException
179 * if the index given is outside the bounds of the collection
181 public void addPdbids(final jalview.schemabinding.version2.Pdbids vPdbids)
182 throws java.lang.IndexOutOfBoundsException
184 this._pdbidsList.addElement(vPdbids);
192 * @throws java.lang.IndexOutOfBoundsException
193 * if the index given is outside the bounds of the collection
195 public void addPdbids(final int index,
196 final jalview.schemabinding.version2.Pdbids vPdbids)
197 throws java.lang.IndexOutOfBoundsException
199 this._pdbidsList.add(index, vPdbids);
204 public void deleteColour()
206 this._has_colour = false;
211 public void deleteEnd()
213 this._has_end = false;
218 public void deleteHidden()
220 this._has_hidden = false;
225 public void deleteStart()
227 this._has_start = false;
231 * Method enumerateFeatures.
233 * @return an Enumeration over all jalview.schemabinding.version2.Features
236 public java.util.Enumeration enumerateFeatures()
238 return this._featuresList.elements();
242 * Method enumerateHiddenSequences.
244 * @return an Enumeration over all int elements
246 public java.util.Enumeration enumerateHiddenSequences()
248 return this._hiddenSequencesList.elements();
252 * Method enumeratePdbids.
254 * @return an Enumeration over all jalview.schemabinding.version2.Pdbids
257 public java.util.Enumeration enumeratePdbids()
259 return this._pdbidsList.elements();
263 * Returns the value of field 'colour'.
265 * @return the value of field 'Colour'.
267 public int getColour()
273 * Returns the value of field 'end'.
275 * @return the value of field 'End'.
283 * Method getFeatures.
286 * @throws java.lang.IndexOutOfBoundsException
287 * if the index given is outside the bounds of the collection
288 * @return the value of the jalview.schemabinding.version2.Features at the
291 public jalview.schemabinding.version2.Features getFeatures(final int index)
292 throws java.lang.IndexOutOfBoundsException
294 // check bounds for index
295 if (index < 0 || index >= this._featuresList.size())
297 throw new IndexOutOfBoundsException("getFeatures: Index value '"
298 + index + "' not in range [0.."
299 + (this._featuresList.size() - 1) + "]");
302 return (jalview.schemabinding.version2.Features) _featuresList
307 * Method getFeatures.Returns the contents of the collection in an Array.
309 * Note: Just in case the collection contents are changing in another thread,
310 * we pass a 0-length Array of the correct type into the API call. This way we
311 * <i>know</i> that the Array returned is of exactly the correct length.
313 * @return this collection as an Array
315 public jalview.schemabinding.version2.Features[] getFeatures()
317 jalview.schemabinding.version2.Features[] array = new jalview.schemabinding.version2.Features[0];
318 return (jalview.schemabinding.version2.Features[]) this._featuresList
323 * Method getFeaturesCount.
325 * @return the size of this collection
327 public int getFeaturesCount()
329 return this._featuresList.size();
333 * Returns the value of field 'hidden'.
335 * @return the value of field 'Hidden'.
337 public boolean getHidden()
343 * Method getHiddenSequences.
346 * @throws java.lang.IndexOutOfBoundsException
347 * if the index given is outside the bounds of the collection
348 * @return the value of the int at the given index
350 public int getHiddenSequences(final int index)
351 throws java.lang.IndexOutOfBoundsException
353 // check bounds for index
354 if (index < 0 || index >= this._hiddenSequencesList.size())
356 throw new IndexOutOfBoundsException(
357 "getHiddenSequences: Index value '" + index
358 + "' not in range [0.."
359 + (this._hiddenSequencesList.size() - 1) + "]");
362 return ((java.lang.Integer) _hiddenSequencesList.get(index)).intValue();
366 * Method getHiddenSequences.Returns the contents of the collection in an
369 * @return this collection as an Array
371 public int[] getHiddenSequences()
373 int size = this._hiddenSequencesList.size();
374 int[] array = new int[size];
375 java.util.Iterator iter = _hiddenSequencesList.iterator();
376 for (int index = 0; index < size; index++)
378 array[index] = ((java.lang.Integer) iter.next()).intValue();
384 * Method getHiddenSequencesCount.
386 * @return the size of this collection
388 public int getHiddenSequencesCount()
390 return this._hiddenSequencesList.size();
394 * Returns the value of field 'id'.
396 * @return the value of field 'Id'.
398 public java.lang.String getId()
407 * @throws java.lang.IndexOutOfBoundsException
408 * if the index given is outside the bounds of the collection
409 * @return the value of the jalview.schemabinding.version2.Pdbids at the given
412 public jalview.schemabinding.version2.Pdbids getPdbids(final int index)
413 throws java.lang.IndexOutOfBoundsException
415 // check bounds for index
416 if (index < 0 || index >= this._pdbidsList.size())
418 throw new IndexOutOfBoundsException("getPdbids: Index value '"
419 + index + "' not in range [0.."
420 + (this._pdbidsList.size() - 1) + "]");
423 return (jalview.schemabinding.version2.Pdbids) _pdbidsList.get(index);
427 * Method getPdbids.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.Pdbids[] getPdbids()
437 jalview.schemabinding.version2.Pdbids[] array = new jalview.schemabinding.version2.Pdbids[0];
438 return (jalview.schemabinding.version2.Pdbids[]) this._pdbidsList
443 * Method getPdbidsCount.
445 * @return the size of this collection
447 public int getPdbidsCount()
449 return this._pdbidsList.size();
453 * Returns the value of field 'start'.
455 * @return the value of field 'Start'.
457 public int getStart()
465 * @return true if at least one Colour has been added
467 public boolean hasColour()
469 return this._has_colour;
475 * @return true if at least one End has been added
477 public boolean hasEnd()
479 return this._has_end;
485 * @return true if at least one Hidden has been added
487 public boolean hasHidden()
489 return this._has_hidden;
495 * @return true if at least one Start has been added
497 public boolean hasStart()
499 return this._has_start;
503 * Returns the value of field 'hidden'.
505 * @return the value of field 'Hidden'.
507 public boolean isHidden()
515 * @return true if this object is valid according to the schema
517 public boolean isValid()
522 } catch (org.exolab.castor.xml.ValidationException vex)
533 * @throws org.exolab.castor.xml.MarshalException
534 * if object is null or if any SAXException is thrown during
536 * @throws org.exolab.castor.xml.ValidationException
537 * if this object is an invalid instance according to the schema
539 public void marshal(final java.io.Writer out)
540 throws org.exolab.castor.xml.MarshalException,
541 org.exolab.castor.xml.ValidationException
543 Marshaller.marshal(this, out);
550 * @throws java.io.IOException
551 * if an IOException occurs during marshaling
552 * @throws org.exolab.castor.xml.ValidationException
553 * if this object is an invalid instance according to the schema
554 * @throws org.exolab.castor.xml.MarshalException
555 * if object is null or if any SAXException is thrown during
558 public void marshal(final org.xml.sax.ContentHandler handler)
559 throws java.io.IOException,
560 org.exolab.castor.xml.MarshalException,
561 org.exolab.castor.xml.ValidationException
563 Marshaller.marshal(this, handler);
568 public void removeAllFeatures()
570 this._featuresList.clear();
575 public void removeAllHiddenSequences()
577 this._hiddenSequencesList.clear();
582 public void removeAllPdbids()
584 this._pdbidsList.clear();
588 * Method removeFeatures.
591 * @return true if the object was removed from the collection.
593 public boolean removeFeatures(
594 final jalview.schemabinding.version2.Features vFeatures)
596 boolean removed = _featuresList.remove(vFeatures);
601 * Method removeFeaturesAt.
604 * @return the element removed from the collection
606 public jalview.schemabinding.version2.Features removeFeaturesAt(
609 java.lang.Object obj = this._featuresList.remove(index);
610 return (jalview.schemabinding.version2.Features) obj;
614 * Method removeHiddenSequences.
616 * @param vHiddenSequences
617 * @return true if the object was removed from the collection.
619 public boolean removeHiddenSequences(final int vHiddenSequences)
621 boolean removed = _hiddenSequencesList.remove(new java.lang.Integer(
627 * Method removeHiddenSequencesAt.
630 * @return the element removed from the collection
632 public int removeHiddenSequencesAt(final int index)
634 java.lang.Object obj = this._hiddenSequencesList.remove(index);
635 return ((java.lang.Integer) obj).intValue();
639 * Method removePdbids.
642 * @return true if the object was removed from the collection.
644 public boolean removePdbids(
645 final jalview.schemabinding.version2.Pdbids vPdbids)
647 boolean removed = _pdbidsList.remove(vPdbids);
652 * Method removePdbidsAt.
655 * @return the element removed from the collection
657 public jalview.schemabinding.version2.Pdbids removePdbidsAt(
660 java.lang.Object obj = this._pdbidsList.remove(index);
661 return (jalview.schemabinding.version2.Pdbids) obj;
665 * Sets the value of field 'colour'.
668 * the value of field 'colour'.
670 public void setColour(final int colour)
672 this._colour = colour;
673 this._has_colour = true;
677 * Sets the value of field 'end'.
680 * the value of field 'end'.
682 public void setEnd(final int end)
685 this._has_end = true;
693 * @throws java.lang.IndexOutOfBoundsException
694 * if the index given is outside the bounds of the collection
696 public void setFeatures(final int index,
697 final jalview.schemabinding.version2.Features vFeatures)
698 throws java.lang.IndexOutOfBoundsException
700 // check bounds for index
701 if (index < 0 || index >= this._featuresList.size())
703 throw new IndexOutOfBoundsException("setFeatures: Index value '"
704 + index + "' not in range [0.."
705 + (this._featuresList.size() - 1) + "]");
708 this._featuresList.set(index, vFeatures);
714 * @param vFeaturesArray
716 public void setFeatures(
717 final jalview.schemabinding.version2.Features[] vFeaturesArray)
720 _featuresList.clear();
722 for (int i = 0; i < vFeaturesArray.length; i++)
724 this._featuresList.add(vFeaturesArray[i]);
729 * Sets the value of field 'hidden'.
732 * the value of field 'hidden'.
734 public void setHidden(final boolean hidden)
736 this._hidden = hidden;
737 this._has_hidden = true;
744 * @param vHiddenSequences
745 * @throws java.lang.IndexOutOfBoundsException
746 * if the index given is outside the bounds of the collection
748 public void setHiddenSequences(final int index, final int vHiddenSequences)
749 throws java.lang.IndexOutOfBoundsException
751 // check bounds for index
752 if (index < 0 || index >= this._hiddenSequencesList.size())
754 throw new IndexOutOfBoundsException(
755 "setHiddenSequences: Index value '" + index
756 + "' not in range [0.."
757 + (this._hiddenSequencesList.size() - 1) + "]");
760 this._hiddenSequencesList.set(index, new java.lang.Integer(
767 * @param vHiddenSequencesArray
769 public void setHiddenSequences(final int[] vHiddenSequencesArray)
772 _hiddenSequencesList.clear();
774 for (int i = 0; i < vHiddenSequencesArray.length; i++)
776 this._hiddenSequencesList.add(new java.lang.Integer(
777 vHiddenSequencesArray[i]));
782 * Sets the value of field 'id'.
785 * the value of field 'id'.
787 public void setId(final java.lang.String id)
797 * @throws java.lang.IndexOutOfBoundsException
798 * if the index given is outside the bounds of the collection
800 public void setPdbids(final int index,
801 final jalview.schemabinding.version2.Pdbids vPdbids)
802 throws java.lang.IndexOutOfBoundsException
804 // check bounds for index
805 if (index < 0 || index >= this._pdbidsList.size())
807 throw new IndexOutOfBoundsException("setPdbids: Index value '"
808 + index + "' not in range [0.."
809 + (this._pdbidsList.size() - 1) + "]");
812 this._pdbidsList.set(index, vPdbids);
818 * @param vPdbidsArray
820 public void setPdbids(
821 final jalview.schemabinding.version2.Pdbids[] vPdbidsArray)
826 for (int i = 0; i < vPdbidsArray.length; i++)
828 this._pdbidsList.add(vPdbidsArray[i]);
833 * Sets the value of field 'start'.
836 * the value of field 'start'.
838 public void setStart(final int start)
841 this._has_start = true;
848 * @throws org.exolab.castor.xml.MarshalException
849 * if object is null or if any SAXException is thrown during
851 * @throws org.exolab.castor.xml.ValidationException
852 * if this object is an invalid instance according to the schema
853 * @return the unmarshaled jalview.schemabinding.version2.JSeq
855 public static jalview.schemabinding.version2.JSeq unmarshal(
856 final java.io.Reader reader)
857 throws org.exolab.castor.xml.MarshalException,
858 org.exolab.castor.xml.ValidationException
860 return (jalview.schemabinding.version2.JSeq) Unmarshaller.unmarshal(
861 jalview.schemabinding.version2.JSeq.class, reader);
867 * @throws org.exolab.castor.xml.ValidationException
868 * if this object is an invalid instance according to the schema
870 public void validate() throws org.exolab.castor.xml.ValidationException
872 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
873 validator.validate(this);