2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)
\r
3 * Copyright (C) 2008 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
100 // ----------------/
\r
101 // - Constructors -/
\r
102 // ----------------/
\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
120 * @throws java.lang.IndexOutOfBoundsException
\r
121 * if the index given is outside the bounds of the collection
\r
123 public void addFeatures(
\r
124 final jalview.schemabinding.version2.Features vFeatures)
\r
125 throws java.lang.IndexOutOfBoundsException
\r
127 this._featuresList.addElement(vFeatures);
\r
135 * @throws java.lang.IndexOutOfBoundsException
\r
136 * if the index given is outside the bounds of the collection
\r
138 public void addFeatures(final int index,
\r
139 final jalview.schemabinding.version2.Features vFeatures)
\r
140 throws java.lang.IndexOutOfBoundsException
\r
142 this._featuresList.add(index, vFeatures);
\r
148 * @param vHiddenSequences
\r
149 * @throws java.lang.IndexOutOfBoundsException
\r
150 * if the index given is outside the bounds of the collection
\r
152 public void addHiddenSequences(final int vHiddenSequences)
\r
153 throws java.lang.IndexOutOfBoundsException
\r
155 this._hiddenSequencesList.addElement(new java.lang.Integer(
\r
156 vHiddenSequences));
\r
163 * @param vHiddenSequences
\r
164 * @throws java.lang.IndexOutOfBoundsException
\r
165 * if the index given is outside the bounds of the collection
\r
167 public void addHiddenSequences(final int index, final int vHiddenSequences)
\r
168 throws java.lang.IndexOutOfBoundsException
\r
170 this._hiddenSequencesList.add(index, new java.lang.Integer(
\r
171 vHiddenSequences));
\r
178 * @throws java.lang.IndexOutOfBoundsException
\r
179 * if the index given is outside the bounds of the collection
\r
181 public void addPdbids(final jalview.schemabinding.version2.Pdbids vPdbids)
\r
182 throws java.lang.IndexOutOfBoundsException
\r
184 this._pdbidsList.addElement(vPdbids);
\r
192 * @throws java.lang.IndexOutOfBoundsException
\r
193 * if the index given is outside the bounds of the collection
\r
195 public void addPdbids(final int index,
\r
196 final jalview.schemabinding.version2.Pdbids vPdbids)
\r
197 throws java.lang.IndexOutOfBoundsException
\r
199 this._pdbidsList.add(index, vPdbids);
\r
204 public void deleteColour()
\r
206 this._has_colour = false;
\r
211 public void deleteEnd()
\r
213 this._has_end = false;
\r
218 public void deleteHidden()
\r
220 this._has_hidden = false;
\r
225 public void deleteStart()
\r
227 this._has_start = false;
\r
231 * Method enumerateFeatures.
\r
233 * @return an Enumeration over all jalview.schemabinding.version2.Features
\r
236 public java.util.Enumeration enumerateFeatures()
\r
238 return this._featuresList.elements();
\r
242 * Method enumerateHiddenSequences.
\r
244 * @return an Enumeration over all int elements
\r
246 public java.util.Enumeration enumerateHiddenSequences()
\r
248 return this._hiddenSequencesList.elements();
\r
252 * Method enumeratePdbids.
\r
254 * @return an Enumeration over all jalview.schemabinding.version2.Pdbids
\r
257 public java.util.Enumeration enumeratePdbids()
\r
259 return this._pdbidsList.elements();
\r
263 * Returns the value of field 'colour'.
\r
265 * @return the value of field 'Colour'.
\r
267 public int getColour()
\r
269 return this._colour;
\r
273 * Returns the value of field 'end'.
\r
275 * @return the value of field 'End'.
\r
277 public int getEnd()
\r
283 * Method getFeatures.
\r
286 * @throws java.lang.IndexOutOfBoundsException
\r
287 * if the index given is outside the bounds of the collection
\r
288 * @return the value of the jalview.schemabinding.version2.Features at the
\r
291 public jalview.schemabinding.version2.Features getFeatures(final int index)
\r
292 throws java.lang.IndexOutOfBoundsException
\r
294 // check bounds for index
\r
295 if (index < 0 || index >= this._featuresList.size())
\r
297 throw new IndexOutOfBoundsException("getFeatures: Index value '"
\r
298 + index + "' not in range [0.."
\r
299 + (this._featuresList.size() - 1) + "]");
\r
302 return (jalview.schemabinding.version2.Features) _featuresList
\r
307 * Method getFeatures.Returns the contents of the collection in an Array.
\r
309 * Note: Just in case the collection contents are changing in another thread,
\r
310 * we pass a 0-length Array of the correct type into the API call. This way we
\r
311 * <i>know</i> that the Array returned is of exactly the correct length.
\r
313 * @return this collection as an Array
\r
315 public jalview.schemabinding.version2.Features[] getFeatures()
\r
317 jalview.schemabinding.version2.Features[] array = new jalview.schemabinding.version2.Features[0];
\r
318 return (jalview.schemabinding.version2.Features[]) this._featuresList
\r
323 * Method getFeaturesCount.
\r
325 * @return the size of this collection
\r
327 public int getFeaturesCount()
\r
329 return this._featuresList.size();
\r
333 * Returns the value of field 'hidden'.
\r
335 * @return the value of field 'Hidden'.
\r
337 public boolean getHidden()
\r
339 return this._hidden;
\r
343 * Method getHiddenSequences.
\r
346 * @throws java.lang.IndexOutOfBoundsException
\r
347 * if the index given is outside the bounds of the collection
\r
348 * @return the value of the int at the given index
\r
350 public int getHiddenSequences(final int index)
\r
351 throws java.lang.IndexOutOfBoundsException
\r
353 // check bounds for index
\r
354 if (index < 0 || index >= this._hiddenSequencesList.size())
\r
356 throw new IndexOutOfBoundsException(
\r
357 "getHiddenSequences: Index value '" + index
\r
358 + "' not in range [0.."
\r
359 + (this._hiddenSequencesList.size() - 1) + "]");
\r
362 return ((java.lang.Integer) _hiddenSequencesList.get(index)).intValue();
\r
366 * Method getHiddenSequences.Returns the contents of the collection in an
\r
369 * @return this collection as an Array
\r
371 public int[] getHiddenSequences()
\r
373 int size = this._hiddenSequencesList.size();
\r
374 int[] array = new int[size];
\r
375 java.util.Iterator iter = _hiddenSequencesList.iterator();
\r
376 for (int index = 0; index < size; index++)
\r
378 array[index] = ((java.lang.Integer) iter.next()).intValue();
\r
384 * Method getHiddenSequencesCount.
\r
386 * @return the size of this collection
\r
388 public int getHiddenSequencesCount()
\r
390 return this._hiddenSequencesList.size();
\r
394 * Returns the value of field 'id'.
\r
396 * @return the value of field 'Id'.
\r
398 public java.lang.String getId()
\r
404 * Method getPdbids.
\r
407 * @throws java.lang.IndexOutOfBoundsException
\r
408 * if the index given is outside the bounds of the collection
\r
409 * @return the value of the jalview.schemabinding.version2.Pdbids at the given
\r
412 public jalview.schemabinding.version2.Pdbids getPdbids(final int index)
\r
413 throws java.lang.IndexOutOfBoundsException
\r
415 // check bounds for index
\r
416 if (index < 0 || index >= this._pdbidsList.size())
\r
418 throw new IndexOutOfBoundsException("getPdbids: Index value '"
\r
419 + index + "' not in range [0.."
\r
420 + (this._pdbidsList.size() - 1) + "]");
\r
423 return (jalview.schemabinding.version2.Pdbids) _pdbidsList.get(index);
\r
427 * Method getPdbids.Returns the contents of the collection in an Array.
\r
429 * Note: Just in case the collection contents are changing in another thread,
\r
430 * we pass a 0-length Array of the correct type into the API call. This way we
\r
431 * <i>know</i> that the Array returned is of exactly the correct length.
\r
433 * @return this collection as an Array
\r
435 public jalview.schemabinding.version2.Pdbids[] getPdbids()
\r
437 jalview.schemabinding.version2.Pdbids[] array = new jalview.schemabinding.version2.Pdbids[0];
\r
438 return (jalview.schemabinding.version2.Pdbids[]) this._pdbidsList
\r
443 * Method getPdbidsCount.
\r
445 * @return the size of this collection
\r
447 public int getPdbidsCount()
\r
449 return this._pdbidsList.size();
\r
453 * Returns the value of field 'start'.
\r
455 * @return the value of field 'Start'.
\r
457 public int getStart()
\r
459 return this._start;
\r
463 * Method hasColour.
\r
465 * @return true if at least one Colour has been added
\r
467 public boolean hasColour()
\r
469 return this._has_colour;
\r
475 * @return true if at least one End has been added
\r
477 public boolean hasEnd()
\r
479 return this._has_end;
\r
483 * Method hasHidden.
\r
485 * @return true if at least one Hidden has been added
\r
487 public boolean hasHidden()
\r
489 return this._has_hidden;
\r
495 * @return true if at least one Start has been added
\r
497 public boolean hasStart()
\r
499 return this._has_start;
\r
503 * Returns the value of field 'hidden'.
\r
505 * @return the value of field 'Hidden'.
\r
507 public boolean isHidden()
\r
509 return this._hidden;
\r
515 * @return true if this object is valid according to the schema
\r
517 public boolean isValid()
\r
522 } catch (org.exolab.castor.xml.ValidationException vex)
\r
533 * @throws org.exolab.castor.xml.MarshalException
\r
534 * if object is null or if any SAXException is thrown during
\r
536 * @throws org.exolab.castor.xml.ValidationException
\r
537 * if this object is an invalid instance according to the
\r
540 public void marshal(final java.io.Writer out)
\r
541 throws org.exolab.castor.xml.MarshalException,
\r
542 org.exolab.castor.xml.ValidationException
\r
544 Marshaller.marshal(this, out);
\r
551 * @throws java.io.IOException
\r
552 * if an IOException occurs during marshaling
\r
553 * @throws org.exolab.castor.xml.ValidationException
\r
554 * if this object is an invalid instance according to the
\r
556 * @throws org.exolab.castor.xml.MarshalException
\r
557 * if object is null or if any SAXException is thrown during
\r
560 public void marshal(final org.xml.sax.ContentHandler handler)
\r
561 throws java.io.IOException,
\r
562 org.exolab.castor.xml.MarshalException,
\r
563 org.exolab.castor.xml.ValidationException
\r
565 Marshaller.marshal(this, handler);
\r
570 public void removeAllFeatures()
\r
572 this._featuresList.clear();
\r
577 public void removeAllHiddenSequences()
\r
579 this._hiddenSequencesList.clear();
\r
584 public void removeAllPdbids()
\r
586 this._pdbidsList.clear();
\r
590 * Method removeFeatures.
\r
593 * @return true if the object was removed from the collection.
\r
595 public boolean removeFeatures(
\r
596 final jalview.schemabinding.version2.Features vFeatures)
\r
598 boolean removed = _featuresList.remove(vFeatures);
\r
603 * Method removeFeaturesAt.
\r
606 * @return the element removed from the collection
\r
608 public jalview.schemabinding.version2.Features removeFeaturesAt(
\r
611 java.lang.Object obj = this._featuresList.remove(index);
\r
612 return (jalview.schemabinding.version2.Features) obj;
\r
616 * Method removeHiddenSequences.
\r
618 * @param vHiddenSequences
\r
619 * @return true if the object was removed from the collection.
\r
621 public boolean removeHiddenSequences(final int vHiddenSequences)
\r
623 boolean removed = _hiddenSequencesList.remove(new java.lang.Integer(
\r
624 vHiddenSequences));
\r
629 * Method removeHiddenSequencesAt.
\r
632 * @return the element removed from the collection
\r
634 public int removeHiddenSequencesAt(final int index)
\r
636 java.lang.Object obj = this._hiddenSequencesList.remove(index);
\r
637 return ((java.lang.Integer) obj).intValue();
\r
641 * Method removePdbids.
\r
644 * @return true if the object was removed from the collection.
\r
646 public boolean removePdbids(
\r
647 final jalview.schemabinding.version2.Pdbids vPdbids)
\r
649 boolean removed = _pdbidsList.remove(vPdbids);
\r
654 * Method removePdbidsAt.
\r
657 * @return the element removed from the collection
\r
659 public jalview.schemabinding.version2.Pdbids removePdbidsAt(
\r
662 java.lang.Object obj = this._pdbidsList.remove(index);
\r
663 return (jalview.schemabinding.version2.Pdbids) obj;
\r
667 * Sets the value of field 'colour'.
\r
670 * the value of field 'colour'.
\r
672 public void setColour(final int colour)
\r
674 this._colour = colour;
\r
675 this._has_colour = true;
\r
679 * Sets the value of field 'end'.
\r
682 * the value of field 'end'.
\r
684 public void setEnd(final int end)
\r
687 this._has_end = true;
\r
695 * @throws java.lang.IndexOutOfBoundsException
\r
696 * if the index given is outside the bounds of the collection
\r
698 public void setFeatures(final int index,
\r
699 final jalview.schemabinding.version2.Features vFeatures)
\r
700 throws java.lang.IndexOutOfBoundsException
\r
702 // check bounds for index
\r
703 if (index < 0 || index >= this._featuresList.size())
\r
705 throw new IndexOutOfBoundsException("setFeatures: Index value '"
\r
706 + index + "' not in range [0.."
\r
707 + (this._featuresList.size() - 1) + "]");
\r
710 this._featuresList.set(index, vFeatures);
\r
716 * @param vFeaturesArray
\r
718 public void setFeatures(
\r
719 final jalview.schemabinding.version2.Features[] vFeaturesArray)
\r
722 _featuresList.clear();
\r
724 for (int i = 0; i < vFeaturesArray.length; i++)
\r
726 this._featuresList.add(vFeaturesArray[i]);
\r
731 * Sets the value of field 'hidden'.
\r
734 * the value of field 'hidden'.
\r
736 public void setHidden(final boolean hidden)
\r
738 this._hidden = hidden;
\r
739 this._has_hidden = true;
\r
746 * @param vHiddenSequences
\r
747 * @throws java.lang.IndexOutOfBoundsException
\r
748 * if the index given is outside the bounds of the collection
\r
750 public void setHiddenSequences(final int index, final int vHiddenSequences)
\r
751 throws java.lang.IndexOutOfBoundsException
\r
753 // check bounds for index
\r
754 if (index < 0 || index >= this._hiddenSequencesList.size())
\r
756 throw new IndexOutOfBoundsException(
\r
757 "setHiddenSequences: Index value '" + index
\r
758 + "' not in range [0.."
\r
759 + (this._hiddenSequencesList.size() - 1) + "]");
\r
762 this._hiddenSequencesList.set(index, new java.lang.Integer(
\r
763 vHiddenSequences));
\r
769 * @param vHiddenSequencesArray
\r
771 public void setHiddenSequences(final int[] vHiddenSequencesArray)
\r
774 _hiddenSequencesList.clear();
\r
776 for (int i = 0; i < vHiddenSequencesArray.length; i++)
\r
778 this._hiddenSequencesList.add(new java.lang.Integer(
\r
779 vHiddenSequencesArray[i]));
\r
784 * Sets the value of field 'id'.
\r
787 * the value of field 'id'.
\r
789 public void setId(final java.lang.String id)
\r
799 * @throws java.lang.IndexOutOfBoundsException
\r
800 * if the index given is outside the bounds of the collection
\r
802 public void setPdbids(final int index,
\r
803 final jalview.schemabinding.version2.Pdbids vPdbids)
\r
804 throws java.lang.IndexOutOfBoundsException
\r
806 // check bounds for index
\r
807 if (index < 0 || index >= this._pdbidsList.size())
\r
809 throw new IndexOutOfBoundsException("setPdbids: Index value '"
\r
810 + index + "' not in range [0.."
\r
811 + (this._pdbidsList.size() - 1) + "]");
\r
814 this._pdbidsList.set(index, vPdbids);
\r
820 * @param vPdbidsArray
\r
822 public void setPdbids(
\r
823 final jalview.schemabinding.version2.Pdbids[] vPdbidsArray)
\r
826 _pdbidsList.clear();
\r
828 for (int i = 0; i < vPdbidsArray.length; i++)
\r
830 this._pdbidsList.add(vPdbidsArray[i]);
\r
835 * Sets the value of field 'start'.
\r
838 * the value of field 'start'.
\r
840 public void setStart(final int start)
\r
842 this._start = start;
\r
843 this._has_start = true;
\r
847 * Method unmarshal.
\r
850 * @throws org.exolab.castor.xml.MarshalException
\r
851 * if object is null or if any SAXException is thrown during
\r
853 * @throws org.exolab.castor.xml.ValidationException
\r
854 * if this object is an invalid instance according to the
\r
856 * @return the unmarshaled jalview.schemabinding.version2.JSeq
\r
858 public static jalview.schemabinding.version2.JSeq unmarshal(
\r
859 final java.io.Reader reader)
\r
860 throws org.exolab.castor.xml.MarshalException,
\r
861 org.exolab.castor.xml.ValidationException
\r
863 return (jalview.schemabinding.version2.JSeq) Unmarshaller.unmarshal(
\r
864 jalview.schemabinding.version2.JSeq.class, reader);
\r
870 * @throws org.exolab.castor.xml.ValidationException
\r
871 * if this object is an invalid instance according to the
\r
874 public void validate() throws org.exolab.castor.xml.ValidationException
\r
876 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
\r
877 validator.validate(this);
\r