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