2 * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)
\r
3 * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
\r
5 * This program is free software; you can redistribute it and/or
\r
6 * modify it under the terms of the GNU General Public License
\r
7 * as published by the Free Software Foundation; either version 2
\r
8 * of the License, or (at your option) any later version.
\r
10 * This program is distributed in the hope that it will be useful,
\r
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 * GNU General Public License for more details.
\r
15 * You should have received a copy of the GNU General Public License
\r
16 * along with this program; if not, write to the Free Software
\r
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
\r
19 package jalview.schemabinding.version2;
\r
21 //---------------------------------/
\r
22 //- Imported classes and packages -/
\r
23 //---------------------------------/
\r
25 import org.exolab.castor.xml.Marshaller;
\r
26 import org.exolab.castor.xml.Unmarshaller;
\r
31 * @version $Revision$ $Date$
\r
33 public class JSeq implements java.io.Serializable {
\r
36 //--------------------------/
\r
37 //- Class/Member Variables -/
\r
38 //--------------------------/
\r
43 private int _colour;
\r
46 * keeps track of state for field: _colour
\r
48 private boolean _has_colour;
\r
56 * keeps track of state for field: _start
\r
58 private boolean _has_start;
\r
66 * keeps track of state for field: _end
\r
68 private boolean _has_end;
\r
73 private java.lang.String _id;
\r
78 private boolean _hidden;
\r
81 * keeps track of state for field: _hidden
\r
83 private boolean _has_hidden;
\r
86 * Field _featuresList.
\r
88 private java.util.Vector _featuresList;
\r
91 * Field _pdbidsList.
\r
93 private java.util.Vector _pdbidsList;
\r
96 * Field _hiddenSequencesList.
\r
98 private java.util.Vector _hiddenSequencesList;
\r
101 //----------------/
\r
102 //- Constructors -/
\r
103 //----------------/
\r
107 this._featuresList = new java.util.Vector();
\r
108 this._pdbidsList = new java.util.Vector();
\r
109 this._hiddenSequencesList = new java.util.Vector();
\r
121 * @throws java.lang.IndexOutOfBoundsException if the index
\r
122 * given is outside the bounds of the collection
\r
124 public void addFeatures(
\r
125 final jalview.schemabinding.version2.Features vFeatures)
\r
126 throws java.lang.IndexOutOfBoundsException {
\r
127 this._featuresList.addElement(vFeatures);
\r
135 * @throws java.lang.IndexOutOfBoundsException if the index
\r
136 * given is outside the bounds of the collection
\r
138 public void addFeatures(
\r
140 final jalview.schemabinding.version2.Features vFeatures)
\r
141 throws java.lang.IndexOutOfBoundsException {
\r
142 this._featuresList.add(index, vFeatures);
\r
148 * @param vHiddenSequences
\r
149 * @throws java.lang.IndexOutOfBoundsException if the index
\r
150 * given is outside the bounds of the collection
\r
152 public void addHiddenSequences(
\r
153 final int vHiddenSequences)
\r
154 throws java.lang.IndexOutOfBoundsException {
\r
155 this._hiddenSequencesList.addElement(new java.lang.Integer(vHiddenSequences));
\r
162 * @param vHiddenSequences
\r
163 * @throws java.lang.IndexOutOfBoundsException if the index
\r
164 * given is outside the bounds of the collection
\r
166 public void addHiddenSequences(
\r
168 final int vHiddenSequences)
\r
169 throws java.lang.IndexOutOfBoundsException {
\r
170 this._hiddenSequencesList.add(index, new java.lang.Integer(vHiddenSequences));
\r
177 * @throws java.lang.IndexOutOfBoundsException if the index
\r
178 * given is outside the bounds of the collection
\r
180 public void addPdbids(
\r
181 final jalview.schemabinding.version2.Pdbids vPdbids)
\r
182 throws java.lang.IndexOutOfBoundsException {
\r
183 this._pdbidsList.addElement(vPdbids);
\r
191 * @throws java.lang.IndexOutOfBoundsException if the index
\r
192 * given is outside the bounds of the collection
\r
194 public void addPdbids(
\r
196 final jalview.schemabinding.version2.Pdbids vPdbids)
\r
197 throws java.lang.IndexOutOfBoundsException {
\r
198 this._pdbidsList.add(index, vPdbids);
\r
203 public void deleteColour(
\r
205 this._has_colour= false;
\r
210 public void deleteEnd(
\r
212 this._has_end= false;
\r
217 public void deleteHidden(
\r
219 this._has_hidden= false;
\r
224 public void deleteStart(
\r
226 this._has_start= false;
\r
230 * Method enumerateFeatures.
\r
232 * @return an Enumeration over all
\r
233 * jalview.schemabinding.version2.Features elements
\r
235 public java.util.Enumeration enumerateFeatures(
\r
237 return this._featuresList.elements();
\r
241 * Method enumerateHiddenSequences.
\r
243 * @return an Enumeration over all int elements
\r
245 public java.util.Enumeration enumerateHiddenSequences(
\r
247 return this._hiddenSequencesList.elements();
\r
251 * Method enumeratePdbids.
\r
253 * @return an Enumeration over all
\r
254 * jalview.schemabinding.version2.Pdbids elements
\r
256 public java.util.Enumeration enumeratePdbids(
\r
258 return this._pdbidsList.elements();
\r
262 * Returns the value of field 'colour'.
\r
264 * @return the value of field 'Colour'.
\r
266 public int getColour(
\r
268 return this._colour;
\r
272 * Returns the value of field 'end'.
\r
274 * @return the value of field 'End'.
\r
282 * Method getFeatures.
\r
285 * @throws java.lang.IndexOutOfBoundsException if the index
\r
286 * given is outside the bounds of the collection
\r
287 * @return the value of the
\r
288 * jalview.schemabinding.version2.Features at the given index
\r
290 public jalview.schemabinding.version2.Features getFeatures(
\r
292 throws java.lang.IndexOutOfBoundsException {
\r
293 // check bounds for index
\r
294 if (index < 0 || index >= this._featuresList.size()) {
\r
295 throw new IndexOutOfBoundsException("getFeatures: Index value '" + index + "' not in range [0.." + (this._featuresList.size() - 1) + "]");
\r
298 return (jalview.schemabinding.version2.Features) _featuresList.get(index);
\r
302 * Method getFeatures.Returns the contents of the collection in
\r
303 * an Array. <p>Note: Just in case the collection contents
\r
304 * are changing in another thread, we pass a 0-length Array of
\r
305 * the correct type into the API call. This way we <i>know</i>
\r
306 * that the Array returned is of exactly the correct length.
\r
308 * @return this collection as an Array
\r
310 public jalview.schemabinding.version2.Features[] getFeatures(
\r
312 jalview.schemabinding.version2.Features[] array = new jalview.schemabinding.version2.Features[0];
\r
313 return (jalview.schemabinding.version2.Features[]) this._featuresList.toArray(array);
\r
317 * Method getFeaturesCount.
\r
319 * @return the size of this collection
\r
321 public int getFeaturesCount(
\r
323 return this._featuresList.size();
\r
327 * Returns the value of field 'hidden'.
\r
329 * @return the value of field 'Hidden'.
\r
331 public boolean getHidden(
\r
333 return this._hidden;
\r
337 * Method getHiddenSequences.
\r
340 * @throws java.lang.IndexOutOfBoundsException if the index
\r
341 * given is outside the bounds of the collection
\r
342 * @return the value of the int at the given index
\r
344 public int getHiddenSequences(
\r
346 throws java.lang.IndexOutOfBoundsException {
\r
347 // check bounds for index
\r
348 if (index < 0 || index >= this._hiddenSequencesList.size()) {
\r
349 throw new IndexOutOfBoundsException("getHiddenSequences: Index value '" + index + "' not in range [0.." + (this._hiddenSequencesList.size() - 1) + "]");
\r
352 return ((java.lang.Integer) _hiddenSequencesList.get(index)).intValue();
\r
356 * Method getHiddenSequences.Returns the contents of the
\r
357 * collection in an Array.
\r
359 * @return this collection as an Array
\r
361 public int[] getHiddenSequences(
\r
363 int size = this._hiddenSequencesList.size();
\r
364 int[] array = new int[size];
\r
365 java.util.Iterator iter = _hiddenSequencesList.iterator();
\r
366 for (int index = 0; index < size; index++) {
\r
367 array[index] = ((java.lang.Integer) iter.next()).intValue();
\r
373 * Method getHiddenSequencesCount.
\r
375 * @return the size of this collection
\r
377 public int getHiddenSequencesCount(
\r
379 return this._hiddenSequencesList.size();
\r
383 * Returns the value of field 'id'.
\r
385 * @return the value of field 'Id'.
\r
387 public java.lang.String getId(
\r
393 * Method getPdbids.
\r
396 * @throws java.lang.IndexOutOfBoundsException if the index
\r
397 * given is outside the bounds of the collection
\r
398 * @return the value of the
\r
399 * jalview.schemabinding.version2.Pdbids at the given index
\r
401 public jalview.schemabinding.version2.Pdbids getPdbids(
\r
403 throws java.lang.IndexOutOfBoundsException {
\r
404 // check bounds for index
\r
405 if (index < 0 || index >= this._pdbidsList.size()) {
\r
406 throw new IndexOutOfBoundsException("getPdbids: Index value '" + index + "' not in range [0.." + (this._pdbidsList.size() - 1) + "]");
\r
409 return (jalview.schemabinding.version2.Pdbids) _pdbidsList.get(index);
\r
413 * Method getPdbids.Returns the contents of the collection in
\r
414 * an Array. <p>Note: Just in case the collection contents
\r
415 * are changing in another thread, we pass a 0-length Array of
\r
416 * the correct type into the API call. This way we <i>know</i>
\r
417 * that the Array returned is of exactly the correct length.
\r
419 * @return this collection as an Array
\r
421 public jalview.schemabinding.version2.Pdbids[] getPdbids(
\r
423 jalview.schemabinding.version2.Pdbids[] array = new jalview.schemabinding.version2.Pdbids[0];
\r
424 return (jalview.schemabinding.version2.Pdbids[]) this._pdbidsList.toArray(array);
\r
428 * Method getPdbidsCount.
\r
430 * @return the size of this collection
\r
432 public int getPdbidsCount(
\r
434 return this._pdbidsList.size();
\r
438 * Returns the value of field 'start'.
\r
440 * @return the value of field 'Start'.
\r
442 public int getStart(
\r
444 return this._start;
\r
448 * Method hasColour.
\r
450 * @return true if at least one Colour has been added
\r
452 public boolean hasColour(
\r
454 return this._has_colour;
\r
460 * @return true if at least one End has been added
\r
462 public boolean hasEnd(
\r
464 return this._has_end;
\r
468 * Method hasHidden.
\r
470 * @return true if at least one Hidden has been added
\r
472 public boolean hasHidden(
\r
474 return this._has_hidden;
\r
480 * @return true if at least one Start has been added
\r
482 public boolean hasStart(
\r
484 return this._has_start;
\r
488 * Returns the value of field 'hidden'.
\r
490 * @return the value of field 'Hidden'.
\r
492 public boolean isHidden(
\r
494 return this._hidden;
\r
500 * @return true if this object is valid according to the schema
\r
502 public boolean isValid(
\r
506 } catch (org.exolab.castor.xml.ValidationException vex) {
\r
516 * @throws org.exolab.castor.xml.MarshalException if object is
\r
517 * null or if any SAXException is thrown during marshaling
\r
518 * @throws org.exolab.castor.xml.ValidationException if this
\r
519 * object is an invalid instance according to the schema
\r
521 public void marshal(
\r
522 final java.io.Writer out)
\r
523 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
\r
524 Marshaller.marshal(this, out);
\r
531 * @throws java.io.IOException if an IOException occurs during
\r
533 * @throws org.exolab.castor.xml.ValidationException if this
\r
534 * object is an invalid instance according to the schema
\r
535 * @throws org.exolab.castor.xml.MarshalException if object is
\r
536 * null or if any SAXException is thrown during marshaling
\r
538 public void marshal(
\r
539 final org.xml.sax.ContentHandler handler)
\r
540 throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
\r
541 Marshaller.marshal(this, handler);
\r
546 public void removeAllFeatures(
\r
548 this._featuresList.clear();
\r
553 public void removeAllHiddenSequences(
\r
555 this._hiddenSequencesList.clear();
\r
560 public void removeAllPdbids(
\r
562 this._pdbidsList.clear();
\r
566 * Method removeFeatures.
\r
569 * @return true if the object was removed from the collection.
\r
571 public boolean removeFeatures(
\r
572 final jalview.schemabinding.version2.Features vFeatures) {
\r
573 boolean removed = _featuresList.remove(vFeatures);
\r
578 * Method removeFeaturesAt.
\r
581 * @return the element removed from the collection
\r
583 public jalview.schemabinding.version2.Features removeFeaturesAt(
\r
585 java.lang.Object obj = this._featuresList.remove(index);
\r
586 return (jalview.schemabinding.version2.Features) obj;
\r
590 * Method removeHiddenSequences.
\r
592 * @param vHiddenSequences
\r
593 * @return true if the object was removed from the collection.
\r
595 public boolean removeHiddenSequences(
\r
596 final int vHiddenSequences) {
\r
597 boolean removed = _hiddenSequencesList.remove(new java.lang.Integer(vHiddenSequences));
\r
602 * Method removeHiddenSequencesAt.
\r
605 * @return the element removed from the collection
\r
607 public int removeHiddenSequencesAt(
\r
609 java.lang.Object obj = this._hiddenSequencesList.remove(index);
\r
610 return ((java.lang.Integer) obj).intValue();
\r
614 * Method removePdbids.
\r
617 * @return true if the object was removed from the collection.
\r
619 public boolean removePdbids(
\r
620 final jalview.schemabinding.version2.Pdbids vPdbids) {
\r
621 boolean removed = _pdbidsList.remove(vPdbids);
\r
626 * Method removePdbidsAt.
\r
629 * @return the element removed from the collection
\r
631 public jalview.schemabinding.version2.Pdbids removePdbidsAt(
\r
633 java.lang.Object obj = this._pdbidsList.remove(index);
\r
634 return (jalview.schemabinding.version2.Pdbids) obj;
\r
638 * Sets the value of field 'colour'.
\r
640 * @param colour the value of field 'colour'.
\r
642 public void setColour(
\r
643 final int colour) {
\r
644 this._colour = colour;
\r
645 this._has_colour = true;
\r
649 * Sets the value of field 'end'.
\r
651 * @param end the value of field 'end'.
\r
653 public void setEnd(
\r
656 this._has_end = true;
\r
664 * @throws java.lang.IndexOutOfBoundsException if the index
\r
665 * given is outside the bounds of the collection
\r
667 public void setFeatures(
\r
669 final jalview.schemabinding.version2.Features vFeatures)
\r
670 throws java.lang.IndexOutOfBoundsException {
\r
671 // check bounds for index
\r
672 if (index < 0 || index >= this._featuresList.size()) {
\r
673 throw new IndexOutOfBoundsException("setFeatures: Index value '" + index + "' not in range [0.." + (this._featuresList.size() - 1) + "]");
\r
676 this._featuresList.set(index, vFeatures);
\r
682 * @param vFeaturesArray
\r
684 public void setFeatures(
\r
685 final jalview.schemabinding.version2.Features[] vFeaturesArray) {
\r
687 _featuresList.clear();
\r
689 for (int i = 0; i < vFeaturesArray.length; i++) {
\r
690 this._featuresList.add(vFeaturesArray[i]);
\r
695 * Sets the value of field 'hidden'.
\r
697 * @param hidden the value of field 'hidden'.
\r
699 public void setHidden(
\r
700 final boolean hidden) {
\r
701 this._hidden = hidden;
\r
702 this._has_hidden = true;
\r
709 * @param vHiddenSequences
\r
710 * @throws java.lang.IndexOutOfBoundsException if the index
\r
711 * given is outside the bounds of the collection
\r
713 public void setHiddenSequences(
\r
715 final int vHiddenSequences)
\r
716 throws java.lang.IndexOutOfBoundsException {
\r
717 // check bounds for index
\r
718 if (index < 0 || index >= this._hiddenSequencesList.size()) {
\r
719 throw new IndexOutOfBoundsException("setHiddenSequences: Index value '" + index + "' not in range [0.." + (this._hiddenSequencesList.size() - 1) + "]");
\r
722 this._hiddenSequencesList.set(index, new java.lang.Integer(vHiddenSequences));
\r
728 * @param vHiddenSequencesArray
\r
730 public void setHiddenSequences(
\r
731 final int[] vHiddenSequencesArray) {
\r
733 _hiddenSequencesList.clear();
\r
735 for (int i = 0; i < vHiddenSequencesArray.length; i++) {
\r
736 this._hiddenSequencesList.add(new java.lang.Integer(vHiddenSequencesArray[i]));
\r
741 * Sets the value of field 'id'.
\r
743 * @param id the value of field 'id'.
\r
746 final java.lang.String id) {
\r
755 * @throws java.lang.IndexOutOfBoundsException if the index
\r
756 * given is outside the bounds of the collection
\r
758 public void setPdbids(
\r
760 final jalview.schemabinding.version2.Pdbids vPdbids)
\r
761 throws java.lang.IndexOutOfBoundsException {
\r
762 // check bounds for index
\r
763 if (index < 0 || index >= this._pdbidsList.size()) {
\r
764 throw new IndexOutOfBoundsException("setPdbids: Index value '" + index + "' not in range [0.." + (this._pdbidsList.size() - 1) + "]");
\r
767 this._pdbidsList.set(index, vPdbids);
\r
773 * @param vPdbidsArray
\r
775 public void setPdbids(
\r
776 final jalview.schemabinding.version2.Pdbids[] vPdbidsArray) {
\r
778 _pdbidsList.clear();
\r
780 for (int i = 0; i < vPdbidsArray.length; i++) {
\r
781 this._pdbidsList.add(vPdbidsArray[i]);
\r
786 * Sets the value of field 'start'.
\r
788 * @param start the value of field 'start'.
\r
790 public void setStart(
\r
792 this._start = start;
\r
793 this._has_start = true;
\r
797 * Method unmarshal.
\r
800 * @throws org.exolab.castor.xml.MarshalException if object is
\r
801 * null or if any SAXException is thrown during marshaling
\r
802 * @throws org.exolab.castor.xml.ValidationException if this
\r
803 * object is an invalid instance according to the schema
\r
804 * @return the unmarshaled jalview.schemabinding.version2.JSeq
\r
806 public static jalview.schemabinding.version2.JSeq unmarshal(
\r
807 final java.io.Reader reader)
\r
808 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
\r
809 return (jalview.schemabinding.version2.JSeq) Unmarshaller.unmarshal(jalview.schemabinding.version2.JSeq.class, reader);
\r
815 * @throws org.exolab.castor.xml.ValidationException if this
\r
816 * object is an invalid instance according to the schema
\r
818 public void validate(
\r
820 throws org.exolab.castor.xml.ValidationException {
\r
821 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
\r
822 validator.validate(this);
\r