2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6)
\r
3 * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
\r
5 * This file is part of Jalview.
\r
7 * Jalview is free software: you can redistribute it and/or
\r
8 * modify it under the terms of the GNU General Public License
\r
9 * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
\r
11 * Jalview is distributed in the hope that it will be useful, but
\r
12 * WITHOUT ANY WARRANTY; without even the implied warranty
\r
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
\r
14 * PURPOSE. See the GNU General Public License for more details.
\r
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
\r
18 package jalview.schemabinding.version2;
\r
20 //---------------------------------/
\r
21 //- Imported classes and packages -/
\r
22 //---------------------------------/
\r
24 import org.exolab.castor.xml.Marshaller;
\r
25 import org.exolab.castor.xml.Unmarshaller;
\r
30 * @version $Revision$ $Date$
\r
32 public class JSeq implements java.io.Serializable
\r
35 // --------------------------/
\r
36 // - Class/Member Variables -/
\r
37 // --------------------------/
\r
42 private int _colour;
\r
45 * keeps track of state for field: _colour
\r
47 private boolean _has_colour;
\r
55 * keeps track of state for field: _start
\r
57 private boolean _has_start;
\r
65 * keeps track of state for field: _end
\r
67 private boolean _has_end;
\r
72 private java.lang.String _id;
\r
77 private boolean _hidden;
\r
80 * keeps track of state for field: _hidden
\r
82 private boolean _has_hidden;
\r
85 * Field _featuresList.
\r
87 private java.util.Vector _featuresList;
\r
90 * Field _pdbidsList.
\r
92 private java.util.Vector _pdbidsList;
\r
95 * Field _hiddenSequencesList.
\r
97 private java.util.Vector _hiddenSequencesList;
\r
99 // ----------------/
\r
100 // - Constructors -/
\r
101 // ----------------/
\r
106 this._featuresList = new java.util.Vector();
\r
107 this._pdbidsList = new java.util.Vector();
\r
108 this._hiddenSequencesList = new java.util.Vector();
\r
119 * @throws java.lang.IndexOutOfBoundsException
\r
120 * if the index given is outside the bounds of the collection
\r
122 public void addFeatures(
\r
123 final jalview.schemabinding.version2.Features vFeatures)
\r
124 throws java.lang.IndexOutOfBoundsException
\r
126 this._featuresList.addElement(vFeatures);
\r
134 * @throws java.lang.IndexOutOfBoundsException
\r
135 * if the index given is outside the bounds of the collection
\r
137 public void addFeatures(final int index,
\r
138 final jalview.schemabinding.version2.Features vFeatures)
\r
139 throws java.lang.IndexOutOfBoundsException
\r
141 this._featuresList.add(index, vFeatures);
\r
147 * @param vHiddenSequences
\r
148 * @throws java.lang.IndexOutOfBoundsException
\r
149 * if the index given is outside the bounds of the collection
\r
151 public void addHiddenSequences(final int vHiddenSequences)
\r
152 throws java.lang.IndexOutOfBoundsException
\r
154 this._hiddenSequencesList.addElement(new java.lang.Integer(
\r
155 vHiddenSequences));
\r
162 * @param vHiddenSequences
\r
163 * @throws java.lang.IndexOutOfBoundsException
\r
164 * if the index given is outside the bounds of the collection
\r
166 public void addHiddenSequences(final int index, final int vHiddenSequences)
\r
167 throws java.lang.IndexOutOfBoundsException
\r
169 this._hiddenSequencesList.add(index, new java.lang.Integer(
\r
170 vHiddenSequences));
\r
177 * @throws java.lang.IndexOutOfBoundsException
\r
178 * if the index given is outside the bounds of the collection
\r
180 public void addPdbids(final jalview.schemabinding.version2.Pdbids vPdbids)
\r
181 throws java.lang.IndexOutOfBoundsException
\r
183 this._pdbidsList.addElement(vPdbids);
\r
191 * @throws java.lang.IndexOutOfBoundsException
\r
192 * if the index given is outside the bounds of the collection
\r
194 public void addPdbids(final int index,
\r
195 final jalview.schemabinding.version2.Pdbids vPdbids)
\r
196 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 jalview.schemabinding.version2.Features
\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 jalview.schemabinding.version2.Pdbids
\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
276 public int getEnd()
\r
282 * Method getFeatures.
\r
285 * @throws java.lang.IndexOutOfBoundsException
\r
286 * if the index given is outside the bounds of the collection
\r
287 * @return the value of the jalview.schemabinding.version2.Features at the
\r
290 public jalview.schemabinding.version2.Features getFeatures(final int index)
\r
291 throws java.lang.IndexOutOfBoundsException
\r
293 // check bounds for index
\r
294 if (index < 0 || index >= this._featuresList.size())
\r
296 throw new IndexOutOfBoundsException("getFeatures: Index value '"
\r
297 + index + "' not in range [0.."
\r
298 + (this._featuresList.size() - 1) + "]");
\r
301 return (jalview.schemabinding.version2.Features) _featuresList
\r
306 * Method getFeatures.Returns the contents of the collection in an Array.
\r
308 * Note: Just in case the collection contents are changing in another thread,
\r
309 * we pass a 0-length Array of the correct type into the API call. This way we
\r
310 * <i>know</i> that the Array returned is of exactly the correct length.
\r
312 * @return this collection as an Array
\r
314 public jalview.schemabinding.version2.Features[] getFeatures()
\r
316 jalview.schemabinding.version2.Features[] array = new jalview.schemabinding.version2.Features[0];
\r
317 return (jalview.schemabinding.version2.Features[]) this._featuresList
\r
322 * Method getFeaturesCount.
\r
324 * @return the size of this collection
\r
326 public int getFeaturesCount()
\r
328 return this._featuresList.size();
\r
332 * Returns the value of field 'hidden'.
\r
334 * @return the value of field 'Hidden'.
\r
336 public boolean getHidden()
\r
338 return this._hidden;
\r
342 * Method getHiddenSequences.
\r
345 * @throws java.lang.IndexOutOfBoundsException
\r
346 * if the index given is outside the bounds of the collection
\r
347 * @return the value of the int at the given index
\r
349 public int getHiddenSequences(final int index)
\r
350 throws java.lang.IndexOutOfBoundsException
\r
352 // check bounds for index
\r
353 if (index < 0 || index >= this._hiddenSequencesList.size())
\r
355 throw new IndexOutOfBoundsException(
\r
356 "getHiddenSequences: Index value '" + index
\r
357 + "' not in range [0.."
\r
358 + (this._hiddenSequencesList.size() - 1) + "]");
\r
361 return ((java.lang.Integer) _hiddenSequencesList.get(index)).intValue();
\r
365 * Method getHiddenSequences.Returns the contents of the collection in an
\r
368 * @return this collection as an Array
\r
370 public int[] getHiddenSequences()
\r
372 int size = this._hiddenSequencesList.size();
\r
373 int[] array = new int[size];
\r
374 java.util.Iterator iter = _hiddenSequencesList.iterator();
\r
375 for (int index = 0; index < size; index++)
\r
377 array[index] = ((java.lang.Integer) iter.next()).intValue();
\r
383 * Method getHiddenSequencesCount.
\r
385 * @return the size of this collection
\r
387 public int getHiddenSequencesCount()
\r
389 return this._hiddenSequencesList.size();
\r
393 * Returns the value of field 'id'.
\r
395 * @return the value of field 'Id'.
\r
397 public java.lang.String getId()
\r
403 * Method getPdbids.
\r
406 * @throws java.lang.IndexOutOfBoundsException
\r
407 * if the index given is outside the bounds of the collection
\r
408 * @return the value of the jalview.schemabinding.version2.Pdbids at the given
\r
411 public jalview.schemabinding.version2.Pdbids getPdbids(final int index)
\r
412 throws java.lang.IndexOutOfBoundsException
\r
414 // check bounds for index
\r
415 if (index < 0 || index >= this._pdbidsList.size())
\r
417 throw new IndexOutOfBoundsException("getPdbids: Index value '"
\r
418 + index + "' not in range [0.."
\r
419 + (this._pdbidsList.size() - 1) + "]");
\r
422 return (jalview.schemabinding.version2.Pdbids) _pdbidsList.get(index);
\r
426 * Method getPdbids.Returns the contents of the collection in an Array.
\r
428 * Note: Just in case the collection contents are changing in another thread,
\r
429 * we pass a 0-length Array of the correct type into the API call. This way we
\r
430 * <i>know</i> that the Array returned is of exactly the correct length.
\r
432 * @return this collection as an Array
\r
434 public jalview.schemabinding.version2.Pdbids[] getPdbids()
\r
436 jalview.schemabinding.version2.Pdbids[] array = new jalview.schemabinding.version2.Pdbids[0];
\r
437 return (jalview.schemabinding.version2.Pdbids[]) this._pdbidsList
\r
442 * Method getPdbidsCount.
\r
444 * @return the size of this collection
\r
446 public int getPdbidsCount()
\r
448 return this._pdbidsList.size();
\r
452 * Returns the value of field 'start'.
\r
454 * @return the value of field 'Start'.
\r
456 public int getStart()
\r
458 return this._start;
\r
462 * Method hasColour.
\r
464 * @return true if at least one Colour has been added
\r
466 public boolean hasColour()
\r
468 return this._has_colour;
\r
474 * @return true if at least one End has been added
\r
476 public boolean hasEnd()
\r
478 return this._has_end;
\r
482 * Method hasHidden.
\r
484 * @return true if at least one Hidden has been added
\r
486 public boolean hasHidden()
\r
488 return this._has_hidden;
\r
494 * @return true if at least one Start has been added
\r
496 public boolean hasStart()
\r
498 return this._has_start;
\r
502 * Returns the value of field 'hidden'.
\r
504 * @return the value of field 'Hidden'.
\r
506 public boolean isHidden()
\r
508 return this._hidden;
\r
514 * @return true if this object is valid according to the schema
\r
516 public boolean isValid()
\r
521 } catch (org.exolab.castor.xml.ValidationException vex)
\r
532 * @throws org.exolab.castor.xml.MarshalException
\r
533 * if object is null or if any SAXException is thrown during
\r
535 * @throws org.exolab.castor.xml.ValidationException
\r
536 * if this object is an invalid instance according to the schema
\r
538 public void marshal(final java.io.Writer out)
\r
539 throws org.exolab.castor.xml.MarshalException,
\r
540 org.exolab.castor.xml.ValidationException
\r
542 Marshaller.marshal(this, out);
\r
549 * @throws java.io.IOException
\r
550 * if an IOException occurs during marshaling
\r
551 * @throws org.exolab.castor.xml.ValidationException
\r
552 * if this object is an invalid instance according to the schema
\r
553 * @throws org.exolab.castor.xml.MarshalException
\r
554 * if object is null or if any SAXException is thrown during
\r
557 public void marshal(final org.xml.sax.ContentHandler handler)
\r
558 throws java.io.IOException,
\r
559 org.exolab.castor.xml.MarshalException,
\r
560 org.exolab.castor.xml.ValidationException
\r
562 Marshaller.marshal(this, handler);
\r
567 public void removeAllFeatures()
\r
569 this._featuresList.clear();
\r
574 public void removeAllHiddenSequences()
\r
576 this._hiddenSequencesList.clear();
\r
581 public void removeAllPdbids()
\r
583 this._pdbidsList.clear();
\r
587 * Method removeFeatures.
\r
590 * @return true if the object was removed from the collection.
\r
592 public boolean removeFeatures(
\r
593 final jalview.schemabinding.version2.Features vFeatures)
\r
595 boolean removed = _featuresList.remove(vFeatures);
\r
600 * Method removeFeaturesAt.
\r
603 * @return the element removed from the collection
\r
605 public jalview.schemabinding.version2.Features removeFeaturesAt(
\r
608 java.lang.Object obj = this._featuresList.remove(index);
\r
609 return (jalview.schemabinding.version2.Features) obj;
\r
613 * Method removeHiddenSequences.
\r
615 * @param vHiddenSequences
\r
616 * @return true if the object was removed from the collection.
\r
618 public boolean removeHiddenSequences(final int vHiddenSequences)
\r
620 boolean removed = _hiddenSequencesList.remove(new java.lang.Integer(
\r
621 vHiddenSequences));
\r
626 * Method removeHiddenSequencesAt.
\r
629 * @return the element removed from the collection
\r
631 public int removeHiddenSequencesAt(final int index)
\r
633 java.lang.Object obj = this._hiddenSequencesList.remove(index);
\r
634 return ((java.lang.Integer) obj).intValue();
\r
638 * Method removePdbids.
\r
641 * @return true if the object was removed from the collection.
\r
643 public boolean removePdbids(
\r
644 final jalview.schemabinding.version2.Pdbids vPdbids)
\r
646 boolean removed = _pdbidsList.remove(vPdbids);
\r
651 * Method removePdbidsAt.
\r
654 * @return the element removed from the collection
\r
656 public jalview.schemabinding.version2.Pdbids removePdbidsAt(
\r
659 java.lang.Object obj = this._pdbidsList.remove(index);
\r
660 return (jalview.schemabinding.version2.Pdbids) obj;
\r
664 * Sets the value of field 'colour'.
\r
667 * the value of field 'colour'.
\r
669 public void setColour(final int colour)
\r
671 this._colour = colour;
\r
672 this._has_colour = true;
\r
676 * Sets the value of field 'end'.
\r
679 * the value of field 'end'.
\r
681 public void setEnd(final int end)
\r
684 this._has_end = true;
\r
692 * @throws java.lang.IndexOutOfBoundsException
\r
693 * if the index given is outside the bounds of the collection
\r
695 public void setFeatures(final int index,
\r
696 final jalview.schemabinding.version2.Features vFeatures)
\r
697 throws java.lang.IndexOutOfBoundsException
\r
699 // check bounds for index
\r
700 if (index < 0 || index >= this._featuresList.size())
\r
702 throw new IndexOutOfBoundsException("setFeatures: Index value '"
\r
703 + index + "' not in range [0.."
\r
704 + (this._featuresList.size() - 1) + "]");
\r
707 this._featuresList.set(index, vFeatures);
\r
713 * @param vFeaturesArray
\r
715 public void setFeatures(
\r
716 final jalview.schemabinding.version2.Features[] vFeaturesArray)
\r
719 _featuresList.clear();
\r
721 for (int i = 0; i < vFeaturesArray.length; i++)
\r
723 this._featuresList.add(vFeaturesArray[i]);
\r
728 * Sets the value of field 'hidden'.
\r
731 * the value of field 'hidden'.
\r
733 public void setHidden(final boolean hidden)
\r
735 this._hidden = hidden;
\r
736 this._has_hidden = true;
\r
743 * @param vHiddenSequences
\r
744 * @throws java.lang.IndexOutOfBoundsException
\r
745 * if the index given is outside the bounds of the collection
\r
747 public void setHiddenSequences(final int index, final int vHiddenSequences)
\r
748 throws java.lang.IndexOutOfBoundsException
\r
750 // check bounds for index
\r
751 if (index < 0 || index >= this._hiddenSequencesList.size())
\r
753 throw new IndexOutOfBoundsException(
\r
754 "setHiddenSequences: Index value '" + index
\r
755 + "' not in range [0.."
\r
756 + (this._hiddenSequencesList.size() - 1) + "]");
\r
759 this._hiddenSequencesList.set(index, new java.lang.Integer(
\r
760 vHiddenSequences));
\r
766 * @param vHiddenSequencesArray
\r
768 public void setHiddenSequences(final int[] vHiddenSequencesArray)
\r
771 _hiddenSequencesList.clear();
\r
773 for (int i = 0; i < vHiddenSequencesArray.length; i++)
\r
775 this._hiddenSequencesList.add(new java.lang.Integer(
\r
776 vHiddenSequencesArray[i]));
\r
781 * Sets the value of field 'id'.
\r
784 * the value of field 'id'.
\r
786 public void setId(final java.lang.String id)
\r
796 * @throws java.lang.IndexOutOfBoundsException
\r
797 * if the index given is outside the bounds of the collection
\r
799 public void setPdbids(final int index,
\r
800 final jalview.schemabinding.version2.Pdbids vPdbids)
\r
801 throws java.lang.IndexOutOfBoundsException
\r
803 // check bounds for index
\r
804 if (index < 0 || index >= this._pdbidsList.size())
\r
806 throw new IndexOutOfBoundsException("setPdbids: Index value '"
\r
807 + index + "' not in range [0.."
\r
808 + (this._pdbidsList.size() - 1) + "]");
\r
811 this._pdbidsList.set(index, vPdbids);
\r
817 * @param vPdbidsArray
\r
819 public void setPdbids(
\r
820 final jalview.schemabinding.version2.Pdbids[] vPdbidsArray)
\r
823 _pdbidsList.clear();
\r
825 for (int i = 0; i < vPdbidsArray.length; i++)
\r
827 this._pdbidsList.add(vPdbidsArray[i]);
\r
832 * Sets the value of field 'start'.
\r
835 * the value of field 'start'.
\r
837 public void setStart(final int start)
\r
839 this._start = start;
\r
840 this._has_start = true;
\r
844 * Method unmarshal.
\r
847 * @throws org.exolab.castor.xml.MarshalException
\r
848 * if object is null or if any SAXException is thrown during
\r
850 * @throws org.exolab.castor.xml.ValidationException
\r
851 * if this object is an invalid instance according to the schema
\r
852 * @return the unmarshaled jalview.schemabinding.version2.JSeq
\r
854 public static jalview.schemabinding.version2.JSeq unmarshal(
\r
855 final java.io.Reader reader)
\r
856 throws org.exolab.castor.xml.MarshalException,
\r
857 org.exolab.castor.xml.ValidationException
\r
859 return (jalview.schemabinding.version2.JSeq) Unmarshaller.unmarshal(
\r
860 jalview.schemabinding.version2.JSeq.class, reader);
\r
866 * @throws org.exolab.castor.xml.ValidationException
\r
867 * if this object is an invalid instance according to the schema
\r
869 public void validate() throws org.exolab.castor.xml.ValidationException
\r
871 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
\r
872 validator.validate(this);
\r